Exemple #1
0
  @Override
  public IndexIterator iter(final IndexToken token) {
    final int id = values.id(token.get());
    if (id == 0) return IndexIterator.EMPTY;

    final int len = lenList.get(id);
    final int[] ids = idsList.get(id), pres;
    if (data.meta.updindex) {
      final IntList tmp = new IntList();
      for (int i = 0; i < len; ++i) tmp.add(data.pre(ids[i]));
      pres = tmp.sort().finish();
    } else {
      pres = ids;
    }

    return new IndexIterator() {
      int p;

      @Override
      public boolean more() {
        return p < len;
      }

      @Override
      public int pre() {
        return pres[p++];
      }

      @Override
      public int size() {
        return len;
      }
    };
  }
Exemple #2
0
  @Override
  public synchronized int costs(final IndexToken it) {
    final byte[] tok = it.get();
    if (tok.length > data.meta.maxlen) return Integer.MAX_VALUE;

    // estimate costs for queries which stretch over multiple index entries
    final FTOpt opt = ((FTLexer) it).ftOpt();
    if (opt.is(FZ) || opt.is(WC)) return Math.max(1, data.meta.size >> 4);

    return entry(tok).size;
  }
Exemple #3
0
  @Override
  public synchronized IndexIterator iter(final IndexToken it) {
    final byte[] tok = it.get();

    // wildcard search
    final FTLexer lexer = (FTLexer) it;
    final FTOpt opt = lexer.ftOpt();
    if (opt.is(WC)) return wc(tok);

    // fuzzy search
    if (opt.is(FZ)) return fuzzy(tok, lexer.lserror(tok));

    // return cached or new result
    final IndexEntry e = entry(tok);
    return e.size > 0 ? iter(e.offset, e.size, inZ, tok) : FTIndexIterator.FTEMPTY;
  }
Exemple #4
0
 /**
  * Returns the number of indexed pre references for the specified token.
  *
  * @param token text to be found
  * @return number of hits
  */
 public final int count(final IndexToken token) {
   return index(token.type()).count(token);
 }
Exemple #5
0
 /**
  * Returns the indexed pre references for the specified token.
  *
  * @param token index token reference
  * @return array of sorted pre values
  */
 public final IndexIterator iter(final IndexToken token) {
   return index(token.type()).iter(token);
 }
Exemple #6
0
 @Override
 public int costs(final IndexToken it) {
   return lenList.get(values.id(it.get()));
 }