Пример #1
0
 // TODO: maybe we could add bulk-add method to
 // Builder?  Takes FST and unions it w/ current
 // FST.
 private void append(Builder<BytesRef> builder, FST<BytesRef> subIndex) throws IOException {
   final BytesRefFSTEnum<BytesRef> subIndexEnum = new BytesRefFSTEnum<BytesRef>(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);
   }
 }
 @Override
 public boolean seekExact(BytesRef text) throws IOException {
   if (in.seekExact(text) == null) {
     return false;
   } else {
     return true;
   }
 }
Пример #3
0
 @Override
 public SeekStatus seekCeil(BytesRef target) throws IOException {
   updateEnum(fstEnum.seekCeil(target));
   if (term == null) {
     return SeekStatus.END;
   } else {
     return term.equals(target) ? SeekStatus.FOUND : SeekStatus.NOT_FOUND;
   }
 }
 @Override
 public BytesRef next() throws IOException {
   InputOutput<Long> io = in.next();
   if (io == null) {
     return null;
   } else {
     return io.input;
   }
 }
Пример #5
0
 @Override
 public BytesRef next() throws IOException {
   if (seekPending) { // previously positioned, but termOutputs not fetched
     seekPending = false;
     SeekStatus status = seekCeil(term);
     assert status == SeekStatus.FOUND; // must positioned on valid term
   }
   updateEnum(fstEnum.next());
   return term;
 }
 @Override
 public SeekStatus seekCeil(BytesRef text) throws IOException {
   if (in.seekCeil(text) == null) {
     return SeekStatus.END;
   } else if (term().equals(text)) {
     // TODO: add SeekStatus to FSTEnum like in https://issues.apache.org/jira/browse/LUCENE-3729
     // to remove this comparision?
     return SeekStatus.FOUND;
   } else {
     return SeekStatus.NOT_FOUND;
   }
 }
 @Override
 public void seekExact(long ord) throws IOException {
   // TODO: would be better to make this simpler and faster.
   // but we dont want to introduce a bug that corrupts our enum state!
   bytesReader.setPosition(0);
   fst.getFirstArc(firstArc);
   IntsRef output = Util.getByOutput(fst, ord, bytesReader, firstArc, scratchArc, scratchInts);
   BytesRefBuilder scratchBytes = new BytesRefBuilder();
   scratchBytes.clear();
   Util.toBytesRef(output, scratchBytes);
   // TODO: we could do this lazily, better to try to push into FSTEnum though?
   in.seekExact(scratchBytes.get());
 }
Пример #8
0
 @Override
 public boolean seekExact(BytesRef target) throws IOException {
   updateEnum(fstEnum.seekExact(target));
   return term != null;
 }
 @Override
 public long ord() throws IOException {
   return in.current().output;
 }
 @Override
 public BytesRef term() throws IOException {
   return in.current().input;
 }