private void append(Builder<BytesRef> builder, FST<BytesRef> subIndex, IntsRefBuilder scratchIntsRef) throws IOException { final BytesRefFSTEnum<BytesRef> subIndexEnum = new BytesRefFSTEnum<>(subIndex); BytesRefFSTEnum.InputOutput<BytesRef> indexEnt; while((indexEnt = subIndexEnum.next()) != null) { //if (DEBUG) { // System.out.println(" add sub=" + indexEnt.input + " " + indexEnt.input + " output=" + indexEnt.output); //} builder.add(Util.toIntsRef(indexEnt.input, scratchIntsRef), indexEnt.output); } } }
SegmentTermsEnum() throws IOException { this.fstEnum = new BytesRefFSTEnum<>(index); this.decoded = false; this.seekPending = false; }
@Override public BytesRef next() throws IOException { //System.out.println("te.next"); current = fstEnum.next(); if (current == null) { //System.out.println(" END"); return null; } didDecode = false; //System.out.println(" term=" + field.name + ":" + current.input.utf8ToString()); return current.input; }
/** Seeks to smallest term that's >= target. */ public InputOutput<T> seekCeil(BytesRef target) throws IOException { this.target = target; targetLength = target.length; super.doSeekCeil(); return setResult(); }
@Override public SeekStatus seekCeil(BytesRef text) throws IOException { //System.out.println("seek to text=" + text.utf8ToString()); final BytesRefFSTEnum.InputOutput<PairOutputs.Pair<Long,PairOutputs.Pair<Long,Long>>> result = fstEnum.seekCeil(text); if (result == null) { //System.out.println(" end"); return SeekStatus.END; } else { //System.out.println(" got text=" + term.utf8ToString()); PairOutputs.Pair<Long,PairOutputs.Pair<Long,Long>> pair1 = result.output; PairOutputs.Pair<Long,Long> pair2 = pair1.output2; docsStart = pair1.output1; docFreq = pair2.output1.intValue(); totalTermFreq = pair2.output2; if (result.input.equals(text)) { //System.out.println(" match docsStart=" + docsStart); return SeekStatus.FOUND; } else { //System.out.println(" not match docsStart=" + docsStart); return SeekStatus.NOT_FOUND; } } }
@Override public boolean seekExact(BytesRef text) throws IOException { //System.out.println("te.seekExact text=" + field.name + ":" + text.utf8ToString() + " this=" + this); current = fstEnum.seekExact(text); didDecode = false; return current != null; }
@Override public BytesRef term() { return fstEnum.current().input; }
SegmentTermsEnum() throws IOException { super(); this.fstEnum = new BytesRefFSTEnum<>(dict); this.decoded = false; this.seekPending = false; this.meta = null; }
@Override public BytesRef next() throws IOException { InputOutput<Long> io = in.next(); if (io == null) { return null; } else { return io.input; } }
/** Seeks to biggest term that's <= target. */ public InputOutput<T> seekFloor(BytesRef target) throws IOException { this.target = target; targetLength = target.length; super.doSeekFloor(); return setResult(); }
@Override public SeekStatus seekCeil(BytesRef text) throws IOException { //System.out.println("te.seek text=" + field.name + ":" + text.utf8ToString() + " this=" + this); current = fstEnum.seekCeil(text); if (current == null) { return SeekStatus.END; } else { // System.out.println(" got term=" + current.input.utf8ToString()); // for(int i=0;i<current.output.length;i++) { // System.out.println(" " + Integer.toHexString(current.output.bytes[i]&0xFF)); // } didDecode = false; if (text.equals(current.input)) { //System.out.println(" found!"); return SeekStatus.FOUND; } else { //System.out.println(" not found: " + current.input.utf8ToString()); return SeekStatus.NOT_FOUND; } } }
@Override public boolean seekExact(BytesRef text) throws IOException { if (in.seekExact(text) == null) { return false; } else { return true; } }
@Override public long ord() throws IOException { return in.current().output; }
private void append(Builder<BytesRef> builder, FST<BytesRef> subIndex, IntsRefBuilder scratchIntsRef) throws IOException { final BytesRefFSTEnum<BytesRef> subIndexEnum = new BytesRefFSTEnum<>(subIndex); BytesRefFSTEnum.InputOutput<BytesRef> indexEnt; while((indexEnt = subIndexEnum.next()) != null) { //if (DEBUG) { // System.out.println(" add sub=" + indexEnt.input + " " + indexEnt.input + " output=" + indexEnt.output); //} builder.add(Util.toIntsRef(indexEnt.input, scratchIntsRef), indexEnt.output); } } }
public SimpleTextTermsEnum(FST<PairOutputs.Pair<Long,PairOutputs.Pair<Long,Long>>> fst, IndexOptions indexOptions) { this.indexOptions = indexOptions; fstEnum = new BytesRefFSTEnum<>(fst); }
@Override public BytesRef next() throws IOException { InputOutput<Long> io = in.next(); if (io == null) { return null; } else { return io.input; } }
/** Seeks to exactly this term, returning null if the term * doesn't exist. This is faster than using {@link * #seekFloor} or {@link #seekCeil} because it * short-circuits as soon the match is not found. */ public InputOutput<T> seekExact(BytesRef target) throws IOException { this.target = target; targetLength = target.length; if (super.doSeekExact()) { assert upto == 1+target.length; return setResult(); } else { return null; } }
@Override public long lookupTerm(BytesRef key) { try { InputOutput<Long> o = fstEnum.seekCeil(key); if (o == null) { return -getValueCount()-1; } else if (o.input.equals(key)) { return o.output.intValue(); } else { return -o.output-1; } } catch (IOException bogus) { throw new RuntimeException(bogus); } }