@Override public int compare(int i, int j) { final int segmentNumberI = i / this.recordsPerSegment; final int segmentOffsetI = (i % this.recordsPerSegment) * this.recordSize; final int segmentNumberJ = j / this.recordsPerSegment; final int segmentOffsetJ = (j % this.recordsPerSegment) * this.recordSize; return compare(segmentNumberI, segmentOffsetI, segmentNumberJ, segmentOffsetJ); }
@Override public T getRecord(int logicalPosition) throws IOException { return getRecord(serializer.createInstance(), logicalPosition); }
/** * Resets the sort buffer back to the state where it is empty. All contained data is discarded. */ @Override public void reset() { // reset all offsets this.numRecords = 0; this.currentSortBufferOffset = 0; this.sortBufferBytes = 0; // return all memory this.freeMemory.addAll(this.sortBuffer); this.sortBuffer.clear(); // grab first buffers this.currentSortBufferSegment = nextMemorySegment(); this.sortBuffer.add(this.currentSortBufferSegment); this.outView.set(this.currentSortBufferSegment); }
@Override public InMemorySorter<T> create(List<MemorySegment> sortSegments) { final TypeSerializer<T> typeSerializer = typeSerializerFactory.getSerializer(); final TypeComparator<T> duplicateTypeComparator = typeComparator.duplicate(); if (useFixedLengthRecordSorter) { return new FixedLengthRecordSorter<>(typeSerializer, duplicateTypeComparator, sortSegments); } else { return new NormalizedKeySorter<>(typeSerializer, duplicateTypeComparator, sortSegments); } } }
if (memoryAvailable()) { this.currentSortBufferSegment = nextMemorySegment(); this.sortBuffer.add(this.currentSortBufferSegment); this.outView.set(this.currentSortBufferSegment);
@Override public void writeToOutput(ChannelWriterOutputView output, LargeRecordHandler<T> largeRecordsOutput) throws IOException { writeToOutput(output); }
@Override public void swap(int i, int j) { final int segmentNumberI = i / this.recordsPerSegment; final int segmentOffsetI = (i % this.recordsPerSegment) * this.recordSize; final int segmentNumberJ = j / this.recordsPerSegment; final int segmentOffsetJ = (j % this.recordsPerSegment) * this.recordSize; swap(segmentNumberI, segmentOffsetI, segmentNumberJ, segmentOffsetJ); }
private final TypeComparator<T> comp = comparator; private final int numTotal = size(); private final int numPerSegment = recordsPerSegment;
@Override public InMemorySorter<T> create(List<MemorySegment> sortSegments) { final TypeSerializer<T> typeSerializer = typeSerializerFactory.getSerializer(); final TypeComparator<T> duplicateTypeComparator = typeComparator.duplicate(); if (useFixedLengthRecordSorter) { return new FixedLengthRecordSorter<>(typeSerializer, duplicateTypeComparator, sortSegments); } else { return new NormalizedKeySorter<>(typeSerializer, duplicateTypeComparator, sortSegments); } } }
if (memoryAvailable()) { this.currentSortBufferSegment = nextMemorySegment(); this.sortBuffer.add(this.currentSortBufferSegment); this.outView.set(this.currentSortBufferSegment);
@Override public void writeToOutput(ChannelWriterOutputView output, LargeRecordHandler<T> largeRecordsOutput) throws IOException { writeToOutput(output); }
@Override public void swap(int i, int j) { final int segmentNumberI = i / this.recordsPerSegment; final int segmentOffsetI = (i % this.recordsPerSegment) * this.recordSize; final int segmentNumberJ = j / this.recordsPerSegment; final int segmentOffsetJ = (j % this.recordsPerSegment) * this.recordSize; swap(segmentNumberI, segmentOffsetI, segmentNumberJ, segmentOffsetJ); }
private final TypeComparator<T> comp = comparator; private final int numTotal = size(); private final int numPerSegment = recordsPerSegment;
serializer.getLength() > 0 && serializer.getLength() <= THRESHOLD_FOR_IN_PLACE_SORTING) buffer = new FixedLengthRecordSorter<E>(serializerFactory.getSerializer(), comp, sortSegments); } else { buffer = new NormalizedKeySorter<E>(serializerFactory.getSerializer(), comp, sortSegments);
if (memoryAvailable()) { this.currentSortBufferSegment = nextMemorySegment(); this.sortBuffer.add(this.currentSortBufferSegment); this.outView.set(this.currentSortBufferSegment);
/** * Resets the sort buffer back to the state where it is empty. All contained data is discarded. */ @Override public void reset() { // reset all offsets this.numRecords = 0; this.currentSortBufferOffset = 0; this.sortBufferBytes = 0; // return all memory this.freeMemory.addAll(this.sortBuffer); this.sortBuffer.clear(); // grab first buffers this.currentSortBufferSegment = nextMemorySegment(); this.sortBuffer.add(this.currentSortBufferSegment); this.outView.set(this.currentSortBufferSegment); }
@Override public void writeToOutput(ChannelWriterOutputView output, LargeRecordHandler<T> largeRecordsOutput) throws IOException { writeToOutput(output); }
@Override public int compare(int i, int j) { final int segmentNumberI = i / this.recordsPerSegment; final int segmentOffsetI = (i % this.recordsPerSegment) * this.recordSize; final int segmentNumberJ = j / this.recordsPerSegment; final int segmentOffsetJ = (j % this.recordsPerSegment) * this.recordSize; return compare(segmentNumberI, segmentOffsetI, segmentNumberJ, segmentOffsetJ); }
@Override public void swap(int i, int j) { final int segmentNumberI = i / this.recordsPerSegment; final int segmentOffsetI = (i % this.recordsPerSegment) * this.recordSize; final int segmentNumberJ = j / this.recordsPerSegment; final int segmentOffsetJ = (j % this.recordsPerSegment) * this.recordSize; swap(segmentNumberI, segmentOffsetI, segmentNumberJ, segmentOffsetJ); }
@Override public T getRecord(int logicalPosition) throws IOException { return getRecord(serializer.createInstance(), logicalPosition); }