public void reset() { if (consumer != null) { consumer.freeArray(array); // the call to consumer.allocateArray may trigger a spill which in turn access this instance // and eventually re-enter this method and try to free the array again. by setting the array // to null and its length to 0 we effectively make the spill code-path a no-op. setting the // array to null also indicates that it has already been de-allocated which prevents a double // de-allocation in free(). array = null; usableCapacity = 0; pos = 0; nullBoundaryPos = 0; array = consumer.allocateArray(initialSize); usableCapacity = getUsableCapacity(); } pos = 0; nullBoundaryPos = 0; }
public void reset() { if (consumer != null) { consumer.freeArray(array); // the call to consumer.allocateArray may trigger a spill which in turn access this instance // and eventually re-enter this method and try to free the array again. by setting the array // to null and its length to 0 we effectively make the spill code-path a no-op. setting the // array to null also indicates that it has already been de-allocated which prevents a double // de-allocation in free(). array = null; usableCapacity = 0; pos = 0; nullBoundaryPos = 0; array = consumer.allocateArray(initialSize); usableCapacity = getUsableCapacity(); } pos = 0; nullBoundaryPos = 0; }
public void reset() { if (consumer != null) { consumer.freeArray(array); // the call to consumer.allocateArray may trigger a spill // which in turn access this instance and eventually re-enter this method // and try to free the array again. // By setting the array to null and its length to 0 // we effectively make the spill code-path a no-op. // Setting the array to null also indicates that it has already been // de-allocated which prevents a double de-allocation in free(). array = null; usableCapacity = 0; pos = 0; nullBoundaryPos = 0; array = consumer.allocateArray(initialSize); usableCapacity = getUsableCapacity(); } pos = 0; nullBoundaryPos = 0; }
public UnsafeInMemorySorter( final MemoryConsumer consumer, final TaskMemoryManager memoryManager, final RecordComparator recordComparator, final PrefixComparator prefixComparator, LongArray array, boolean canUseRadixSort) { this.consumer = consumer; this.memoryManager = memoryManager; this.initialSize = array.size(); if (recordComparator != null) { this.sortComparator = new SortComparator(recordComparator, prefixComparator, memoryManager); if (canUseRadixSort && prefixComparator instanceof PrefixComparators.RadixSortSupport) { this.radixSortSupport = (PrefixComparators.RadixSortSupport)prefixComparator; } else { this.radixSortSupport = null; } } else { this.sortComparator = null; this.radixSortSupport = null; } this.array = array; this.usableCapacity = getUsableCapacity(); }
public UnsafeInMemorySorter( final MemoryConsumer consumer, final TaskMemoryManager memoryManager, final RecordComparator recordComparator, final PrefixComparator prefixComparator, LongArray array, boolean canUseRadixSort) { this.consumer = consumer; this.memoryManager = memoryManager; this.initialSize = array.size(); if (recordComparator != null) { this.sortComparator = new SortComparator(recordComparator, prefixComparator, memoryManager); if (canUseRadixSort && prefixComparator instanceof PrefixComparators.RadixSortSupport) { this.radixSortSupport = (PrefixComparators.RadixSortSupport)prefixComparator; } else { this.radixSortSupport = null; } } else { this.sortComparator = null; this.radixSortSupport = null; } this.array = array; this.usableCapacity = getUsableCapacity(); }
public UnsafeInMemorySorter( final MemoryConsumer consumer, final TaskMemoryManager memoryManager, final RecordComparator recordComparator, final PrefixComparator prefixComparator, LongArray array, boolean canUseRadixSort) { this.consumer = consumer; this.memoryManager = memoryManager; this.initialSize = array.size(); if (recordComparator != null) { this.sortComparator = new SortComparator(recordComparator, prefixComparator, memoryManager); if (canUseRadixSort && prefixComparator instanceof PrefixComparators.RadixSortSupport) { this.radixSortSupport = (PrefixComparators.RadixSortSupport)prefixComparator; } else { this.radixSortSupport = null; } } else { this.sortComparator = null; this.radixSortSupport = null; } this.array = array; this.usableCapacity = getUsableCapacity(); }
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(), pos * 8L); consumer.freeArray(array); array = newArray; usableCapacity = getUsableCapacity(); }
public void expandPointerArray(LongArray newArray) { if (newArray.size() < array.size()) { throw new SparkOutOfMemoryError("Not enough memory to grow pointer array"); } Platform.copyMemory( array.getBaseObject(), array.getBaseOffset(), newArray.getBaseObject(), newArray.getBaseOffset(), pos * 8L); consumer.freeArray(array); array = newArray; usableCapacity = getUsableCapacity(); }
public void expandPointerArray(LongArray newArray) { if (newArray.size() < array.size()) { throw new SparkOutOfMemoryError("Not enough memory to grow pointer array"); } Platform.copyMemory( array.getBaseObject(), array.getBaseOffset(), newArray.getBaseObject(), newArray.getBaseOffset(), pos * 8L); consumer.freeArray(array); array = newArray; usableCapacity = getUsableCapacity(); }