private void expandArray(int shardId){
  int newNumShards=Math.max((int)Math.ceil(numShards * SHARD_GROWTH_FACTOR),shardId + 1);
  Preconditions.checkArgument(newNumShards * shardLength < Integer.MAX_VALUE,"Exceeded the max storage capacity for ShardedBigIntArray");
  int[][] newArray=new int[newNumShards][];
  System.arraycopy(readerAccessibleInfo.array,0,newArray,0,readerAccessibleInfo.array.length);
  readerAccessibleInfo=new ReaderAccessibleInfo(newArray);
  numShards=newNumShards;
}

private void expandArray ( int shardId ) { int newNumShards = Math . max ( ( int ) Math . ceil ( numShards * SHARD_GROWTH_FACTOR ) , shardId + 1 ) ; Preconditions . checkArgument ( newNumShards * shardLength < Integer . MAX_VALUE , "Exceeded the max storage capacity for ShardedBigIntArray" ) ; int [ ] [ ] newArray = new int [ newNumShards ] [ ] ; System . arraycopy ( readerAccessibleInfo . array , 0 , newArray , 0 , readerAccessibleInfo . array . length ) ; readerAccessibleInfo = new ReaderAccessibleInfo ( newArray ) ; numShards = newNumShards ; }
synchronization comment : this method works fine without needing synchronization between the writer and the readers due to the wrapping of the arrays in readeraccessibleinfo . see the publication safety comment in those objects .
