private int calculateSegmentSize(int factor,int segmentSizeOld){
  DatabaseKelp db=_table.database();
  long segmentFactor=_tableLength / db.getSegmentSizeMin();
  long segmentFactorNew=segmentFactor / factor;
  if (segmentFactorNew > 0) {
    int bit=63 - Long.numberOfLeadingZeros(segmentFactorNew);
    bit&=~0x1;
    long segmentFactorPower=(1 << bit);
    if (segmentFactorPower < segmentFactorNew) {
      segmentFactorNew=4 * segmentFactorPower;
    }
  }
  long segmentSizeNew=segmentFactorNew * db.getSegmentSizeMin();
  segmentSizeNew=Math.max(db.getSegmentSizeMin(),segmentSizeNew);
  long segmentSizeBlob=_blobSizeMax * 4;
  while (segmentSizeNew < segmentSizeBlob) {
    segmentSizeNew*=4;
  }
  segmentSizeNew=Math.min(db.getSegmentSizeMax(),segmentSizeNew);
  return (int)Math.max(segmentSizeNew,segmentSizeOld);
}

private int calculateSegmentSize ( int factor , int segmentSizeOld ) { DatabaseKelp db = _table . database ( ) ; long segmentFactor = _tableLength / db . getSegmentSizeMin ( ) ; long segmentFactorNew = segmentFactor / factor ; if ( segmentFactorNew > 0 ) { int bit = 63 - Long . numberOfLeadingZeros ( segmentFactorNew ) ; bit &= ~ 0x1 ; long segmentFactorPower = ( 1 << bit ) ; if ( segmentFactorPower < segmentFactorNew ) { segmentFactorNew = 4 * segmentFactorPower ; } } long segmentSizeNew = segmentFactorNew * db . getSegmentSizeMin ( ) ; segmentSizeNew = Math . max ( db . getSegmentSizeMin ( ) , segmentSizeNew ) ; long segmentSizeBlob = _blobSizeMax * 4 ; while ( segmentSizeNew < segmentSizeBlob ) { segmentSizeNew *= 4 ; } segmentSizeNew = Math . min ( db . getSegmentSizeMax ( ) , segmentSizeNew ) ; return ( int ) Math . max ( segmentSizeNew , segmentSizeOld ) ; }
calculate the dynamic segment size . the new segment size is a fraction of the current table size .
