コード例 #1
0
  /**
   * This load a chunk (just the document ids!) and decompress it
   *
   * @throws IOException
   */
  protected final void load() throws IOException {

    chunkSize = (numberOfEntries > chunkSize) ? chunkSize : numberOfEntries;

    idsCodec.decompress(input, ids, chunkSize);
    Delta.inverseDelta(ids, chunkSize);

    currentPosting = -1;
    blkCnt = 0;

    decompressed = false;
  }
コード例 #2
0
  /**
   * Read the posting components from the chunk
   *
   * @param pos the posting to load (as index in the internal arrays)
   * @throws IOException
   */
  protected final void get(final int pos) throws IOException {

    if (!decompressed) decompress();

    id = ids[pos];
    tf = tfs[pos];

    if (fieldsCount > 0) {

      for (int j = 0; j < fieldsCount; j++)
        fields[j] = fieldsMatrix[j][pos] - 1; // -1, to deal with gamma and unary codec
    }
    if (hasBlocks > 0) {

      bf = bfs[pos];
      for (int i = currentPosting + 1; i < pos; i++) blkCnt += bfs[i];
      blocks = Arrays.copyOfRange(blocksMatrix, blkCnt, blkCnt + bf);
      Delta.inverseDelta(blocks, blocks.length);
      blkCnt += bf; // <-- because currentPosting may start from -1
    }

    numberOfEntries -= pos - currentPosting;
    currentPosting = pos;
  }