示例#1
0
文件: FTIndex.java 项目: fpapai/basex
  /**
   * Constructor, initializing the index structure.
   *
   * @param data data reference
   * @throws IOException I/O Exception
   */
  public FTIndex(final Data data) throws IOException {
    super(data, true);

    // cache token length index
    inY = new DataAccess(data.meta.dbfile(DATAFTX + 'y'));
    inZ = new DataAccess(data.meta.dbfile(DATAFTX + 'z'));
    inX = new DataAccess(data.meta.dbfile(DATAFTX + 'x'));
    tp = new int[data.meta.maxlen + 3];
    final int tl = tp.length;
    for (int i = 0; i < tl; ++i) tp[i] = -1;
    int is = inX.readNum();
    while (--is >= 0) {
      int p = inX.readNum();
      final int r;
      if (p < tl) {
        r = inX.read4();
      } else {
        // legacy issue (7.0.2 -> 7.1)
        r = p << 24 | (inX.read1() & 0xFF) << 16 | (inX.read1() & 0xFF) << 8 | inX.read1() & 0xFF;
        p = p >> 8 | 0x40;
      }
      tp[p] = r;
    }
    tp[tl - 1] = (int) inY.length();
  }
示例#2
0
文件: FTList.java 项目: fpapai/basex
  /**
   * Returns next token.
   *
   * @return byte[] token
   */
  private byte[] token() {
    if (tp[tp.length - 1] == ptok) return EMPTY;
    if (tp[ntl] == ptok || ntl == 0) {
      ++ctl;
      while (tp[ctl] == -1) ++ctl;
      ntl = ctl + 1;
      while (tp[ntl] == -1) ++ntl;
    }
    if (ctl == tp.length) return EMPTY;

    final byte[] t = str.readBytes(ptok, ctl);
    // skip pointer
    size = str.read4(str.cursor() + 5);
    // position will always fit in an integer...
    ptok = (int) str.cursor();
    return t;
  }
示例#3
0
文件: FTList.java 项目: fpapai/basex
 /**
  * Constructor, initializing the index structure.
  *
  * @param data data
  * @param prefix prefix
  * @throws IOException I/O exception
  */
 FTList(final Data data, final int prefix) throws IOException {
   files = data.meta.dbfile(DATAFTX + prefix + 'y');
   filed = data.meta.dbfile(DATAFTX + prefix + 'z');
   str = new DataAccess(files);
   dat = new DataAccess(filed);
   tp = new int[data.meta.maxlen + 3];
   final int tl = tp.length;
   for (int t = 0; t < tl; t++) tp[t] = -1;
   sizes = data.meta.dbfile(DATAFTX + prefix + 'x');
   try (final DataAccess li = new DataAccess(sizes)) {
     int is = li.readNum();
     while (--is >= 0) {
       final int p = li.readNum();
       tp[p] = li.read4();
     }
     tp[tl - 1] = (int) str.length();
   }
   next();
 }
示例#4
0
文件: FTIndex.java 项目: fpapai/basex
 /**
  * Reads the size of ftdata from disk.
  *
  * @param pt pointer on token
  * @param lt length of the token
  * @return size of the ftdata
  */
 private int size(final long pt, final int lt) {
   return inY.read4(pt + lt + 5);
 }