示例#1
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;
  }
示例#2
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;
      }
    };
  }
示例#3
0
文件: FTIndex.java 项目: fpapai/basex
  @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;
  }
示例#4
0
文件: FTIndex.java 项目: fpapai/basex
  @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;
  }
示例#5
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);
 }
示例#6
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);
 }
示例#7
0
 @Override
 public int costs(final IndexToken it) {
   return lenList.get(values.id(it.get()));
 }
示例#8
0
 @Override
 public int count(final IndexToken it) {
   final int i = id(it.get());
   return i == 0 ? 0 : len[i];
 }