public void arrayCopy()

in graphjet-core/src/main/java/com/twitter/graphjet/hashing/ShardedBigIntArray.java [196:243]


  public void arrayCopy(int[] src, int srcPos, int desPos, int length, boolean updateStats) {
    int shard = desPos >> shardLengthNumBits;
    int offset = desPos & offsetMask;
    // we may need more shards
    if (shard >= numShards) {
      expandArray(shard);
    }

    // the shard's memory may not have been allocated yet
    if (readerAccessibleInfo.array[shard] == null) {
      allocateMemoryForShard(shard);
    }

    if (offset + length <= shardLength) {
      System.arraycopy(
        src,
        srcPos,
        readerAccessibleInfo.array[shard],
        offset,
        length
      );
    } else {
      System.arraycopy(
        src,
        srcPos,
        readerAccessibleInfo.array[shard],
        offset,
        shardLength - offset
      );

      int deltaLength = shardLength - offset;

      // if current shard does not have enough space to hold all elements in this batch, add them to
      // the next shard(s) recursively
      arrayCopy(
        src,
        srcPos + deltaLength,
        desPos + deltaLength,
        length - deltaLength,
        false /*updateStats*/
      );
    }

    if (updateStats) {
      numStoredEntries += length;
      numArrayEntries.incr(length);
    }
  }