public void expandPointerArray(LongArray newArray) {
        if (newArray.size() < array.size()) {
            throw new OutOfMemoryError("Not enough memory to grow pointer array");
        }
        Platform.copyMemory(
                array.getBaseObject(),
                array.getBaseOffset(),
                newArray.getBaseObject(),
                newArray.getBaseOffset(),
                array.size() * 8L);
        consumer.freeArray(array);
        array = newArray;
    }
@return the number of records that have been inserted into this sorter.
indexr-query-opt/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeInMemorySorter.java