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 IndexIterator iter(final IndexToken tok) {
    final byte k = tok.type() == IndexType.TEXT ? Data.TEXT : Data.ATTR;
    final int i = id(tok.get());
    if (i > 0) {
      final int[] pres = ids[i];
      final int s = len[i];
      if (s > 0) {
        return new IndexIterator() {
          int p;

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

          @Override
          public int next() {
            while (more() && data.kind(pres[p++]) != k) ;
            return pres[p - 1];
          }
        };
      }
    }
    return IndexIterator.EMPTY;
  }
Exemple #3
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 #4
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 #5
0
 @Override
 public int costs(final IndexToken it) {
   return lenList.get(values.id(it.get()));
 }
Exemple #6
0
 @Override
 public int count(final IndexToken it) {
   final int i = id(it.get());
   return i == 0 ? 0 : len[i];
 }