private boolean actuallyFits(int powerTwo) throws IOException
  {
    long lastValueOffset = 0;
    long currentValueOffset = 0;
    long valueBytesWritten = valuesOut.size();
    long headerIndex = 0;
    long bagSize = 1L << powerTwo;

    while (lastValueOffset < valueBytesWritten) {

      if (headerIndex >= numWritten) {
        return true;
      } else if (headerIndex + bagSize <= numWritten) {
        currentValueOffset = headerOutLong.getLong(Ints.checkedCast(headerIndex + bagSize - 1));
      } else if (numWritten < headerIndex + bagSize) {
        currentValueOffset = headerOutLong.getLong(numWritten - 1);
      }

      if (currentValueOffset - lastValueOffset <= fileSizeLimit) {
        lastValueOffset = currentValueOffset;
        headerIndex = headerIndex + bagSize;
      } else {
        return false;
      }
    }
    return true;
  }
private boolean actuallyFits ( int powerTwo ) throws IOException { long lastValueOffset = 0 ; long currentValueOffset = 0 ; long valueBytesWritten = valuesOut . size ( ) ; long headerIndex = 0 ; long bagSize = 1L << powerTwo ; while ( lastValueOffset < valueBytesWritten ) { if ( headerIndex >= numWritten ) { return true ; } else if ( headerIndex + bagSize <= numWritten ) { currentValueOffset = headerOutLong . getLong ( Ints . checkedCast ( headerIndex + bagSize - 1 ) ) ; } else if ( numWritten < headerIndex + bagSize ) { currentValueOffset = headerOutLong . getLong ( numWritten - 1 ) ; } if ( currentValueOffset - lastValueOffset <= fileSizeLimit ) { lastValueOffset = currentValueOffset ; headerIndex = headerIndex + bagSize ; } else { return false ; } } return true ; }
Checks if candidate value splits can divide value file in such a way no object/element crosses the value splits.

@param powerTwo   candidate value split expressed as power of 2.

@return true if candidate value split can hold all splits.

@throws IOException