예제 #1
0
  public Slice finish() {
    if (!finished) {
      finished = true;

      if (entryCount > 0) {
        restartPositions.write(block);
        block.writeInt(restartPositions.size());
      } else {
        block.writeInt(0);
      }
    }
    return block.slice();
  }
예제 #2
0
  public int currentSizeEstimate() {
    // no need to estimate if closed
    if (finished) {
      return block.size();
    }

    // no records is just a single int
    if (block.size() == 0) {
      return SIZE_OF_INT;
    }

    return block.size()
        + // raw data buffer
        restartPositions.size() * SIZE_OF_INT
        + // restart positions
        SIZE_OF_INT; // restart position size
  }