test_class.declarator: SEED = 649180756312423613L
test_class.modifier: private static final
test_class.original_string: private static final long SEED = 649180756312423613L;
test_class.type: long
test_class.var_name: SEED
test_class.declarator: SEED2 = 97652436586326573L
test_class.modifier: private static final
test_class.original_string: private static final long SEED2 = 97652436586326573L;
test_class.type: long
test_class.var_name: SEED2
test_class.declarator: KEY_MAX = Integer.MAX_VALUE
test_class.modifier: private static final
test_class.original_string: private static final int KEY_MAX = Integer.MAX_VALUE;
test_class.type: int
test_class.var_name: KEY_MAX
test_class.declarator: VALUE_LENGTH = 118
test_class.modifier: private static final
test_class.original_string: private static final int VALUE_LENGTH = 118;
test_class.type: int
test_class.var_name: VALUE_LENGTH
test_class.declarator: MEMORY_SIZE = 1024 * 1024 * 64
test_class.modifier: private static final
test_class.original_string: private static final int MEMORY_SIZE = 1024 * 1024 * 64;
test_class.type: int
test_class.var_name: MEMORY_SIZE
test_class.declarator: MEMORY_PAGE_SIZE = 32 * 1024
test_class.modifier: private static final
test_class.original_string: private static final int MEMORY_PAGE_SIZE = 32 * 1024;
test_class.type: int
test_class.var_name: MEMORY_PAGE_SIZE
test_class.declarator: memoryManager
test_class.modifier: private
test_class.original_string: private MemoryManager memoryManager;
test_class.type: MemoryManager
test_class.var_name: memoryManager
test_class.file: flink-runtime/src/test/java/org/apache/flink/runtime/operators/sort/NormalizedKeySorterTest.java
test_class.identifier: NormalizedKeySorterTest
test_case.body: @Test
  	public void testCompare() throws Exception {
  		final int numSegments = MEMORY_SIZE / MEMORY_PAGE_SIZE;
  		final List<MemorySegment> memory = this.memoryManager.allocatePages(new DummyInvokable(), numSegments);
  		
  		NormalizedKeySorter<Tuple2<Integer, String>> sorter = newSortBuffer(memory);
  		TestData.TupleGenerator generator = new TestData.TupleGenerator(SEED, KEY_MAX, VALUE_LENGTH, KeyMode.SORTED,
  			ValueMode.RANDOM_LENGTH);
  		
  		// write the records
  		Tuple2<Integer, String> record = new Tuple2<>();
  		int num = -1;
  		do {
  			generator.next(record);
  			num++;
  		}
  		while (sorter.write(record));
  		
  		// compare random elements
  		Random rnd = new Random(SEED << 1);
  		for (int i = 0; i < 2 * num; i++) {
  			int pos1 = rnd.nextInt(num);
  			int pos2 = rnd.nextInt(num);
  			
  			int cmp = sorter.compare(pos1, pos2);
  			
  			if (pos1 < pos2) {
  				Assert.assertTrue(cmp <= 0);
  			}
  			else {
  				Assert.assertTrue(cmp >= 0);
  			}
  		}
  		
  		// release the memory occupied by the buffers
  		sorter.dispose();
  		this.memoryManager.release(memory);
  	}
test_case.class_method_signature: NormalizedKeySorterTest.testCompare()
test_case.full_signature: @Test public void testCompare()
test_case.identifier: testCompare
test_case.invocations: allocatePages newSortBuffer next write nextInt nextInt compare assertTrue assertTrue dispose release
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCompare()
focal_class.declarator: LOG = LoggerFactory.getLogger(NormalizedKeySorter.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(NormalizedKeySorter.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: OFFSET_LEN = 8
focal_class.modifier: private static final
focal_class.original_string: private static final int OFFSET_LEN = 8;
focal_class.type: int
focal_class.var_name: OFFSET_LEN
focal_class.declarator: DEFAULT_MAX_NORMALIZED_KEY_LEN = 16
focal_class.modifier: private static final
focal_class.original_string: private static final int DEFAULT_MAX_NORMALIZED_KEY_LEN = 16;
focal_class.type: int
focal_class.var_name: DEFAULT_MAX_NORMALIZED_KEY_LEN
focal_class.declarator: MAX_NORMALIZED_KEY_LEN_PER_ELEMENT = 8
focal_class.modifier: private static final
focal_class.original_string: private static final int MAX_NORMALIZED_KEY_LEN_PER_ELEMENT = 8;
focal_class.type: int
focal_class.var_name: MAX_NORMALIZED_KEY_LEN_PER_ELEMENT
focal_class.declarator: MIN_REQUIRED_BUFFERS = 3
focal_class.modifier: private static final
focal_class.original_string: private static final int MIN_REQUIRED_BUFFERS = 3;
focal_class.type: int
focal_class.var_name: MIN_REQUIRED_BUFFERS
focal_class.declarator: LARGE_RECORD_THRESHOLD = 10 * 1024 * 1024
focal_class.modifier: private static final
focal_class.original_string: private static final int LARGE_RECORD_THRESHOLD = 10 * 1024 * 1024;
focal_class.type: int
focal_class.var_name: LARGE_RECORD_THRESHOLD
focal_class.declarator: LARGE_RECORD_TAG = 1L << 63
focal_class.modifier: private static final
focal_class.original_string: private static final long LARGE_RECORD_TAG = 1L << 63;
focal_class.type: long
focal_class.var_name: LARGE_RECORD_TAG
focal_class.declarator: POINTER_MASK = LARGE_RECORD_TAG - 1
focal_class.modifier: private static final
focal_class.original_string: private static final long POINTER_MASK = LARGE_RECORD_TAG - 1;
focal_class.type: long
focal_class.var_name: POINTER_MASK
focal_class.declarator: swapBuffer
focal_class.modifier: private final
focal_class.original_string: private final byte[] swapBuffer;
focal_class.type: byte[]
focal_class.var_name: swapBuffer
focal_class.declarator: serializer
focal_class.modifier: private final
focal_class.original_string: private final TypeSerializer<T> serializer;
focal_class.type: TypeSerializer<T>
focal_class.var_name: serializer
focal_class.declarator: comparator
focal_class.modifier: private final
focal_class.original_string: private final TypeComparator<T> comparator;
focal_class.type: TypeComparator<T>
focal_class.var_name: comparator
focal_class.declarator: recordCollector
focal_class.modifier: private final
focal_class.original_string: private final SimpleCollectingOutputView recordCollector;
focal_class.type: SimpleCollectingOutputView
focal_class.var_name: recordCollector
focal_class.declarator: recordBuffer
focal_class.modifier: private final
focal_class.original_string: private final RandomAccessInputView recordBuffer;
focal_class.type: RandomAccessInputView
focal_class.var_name: recordBuffer
focal_class.declarator: recordBufferForComparison
focal_class.modifier: private final
focal_class.original_string: private final RandomAccessInputView recordBufferForComparison;
focal_class.type: RandomAccessInputView
focal_class.var_name: recordBufferForComparison
focal_class.declarator: currentSortIndexSegment
focal_class.modifier: private
focal_class.original_string: private MemorySegment currentSortIndexSegment;
focal_class.type: MemorySegment
focal_class.var_name: currentSortIndexSegment
focal_class.declarator: freeMemory
focal_class.modifier: private final
focal_class.original_string: private final ArrayList<MemorySegment> freeMemory;
focal_class.type: ArrayList<MemorySegment>
focal_class.var_name: freeMemory
focal_class.declarator: sortIndex
focal_class.modifier: private final
focal_class.original_string: private final ArrayList<MemorySegment> sortIndex;
focal_class.type: ArrayList<MemorySegment>
focal_class.var_name: sortIndex
focal_class.declarator: recordBufferSegments
focal_class.modifier: private final
focal_class.original_string: private final ArrayList<MemorySegment> recordBufferSegments;
focal_class.type: ArrayList<MemorySegment>
focal_class.var_name: recordBufferSegments
focal_class.declarator: currentDataBufferOffset
focal_class.modifier: private
focal_class.original_string: private long currentDataBufferOffset;
focal_class.type: long
focal_class.var_name: currentDataBufferOffset
focal_class.declarator: sortIndexBytes
focal_class.modifier: private
focal_class.original_string: private long sortIndexBytes;
focal_class.type: long
focal_class.var_name: sortIndexBytes
focal_class.declarator: currentSortIndexOffset
focal_class.modifier: private
focal_class.original_string: private int currentSortIndexOffset;
focal_class.type: int
focal_class.var_name: currentSortIndexOffset
focal_class.declarator: numRecords
focal_class.modifier: private
focal_class.original_string: private int numRecords;
focal_class.type: int
focal_class.var_name: numRecords
focal_class.declarator: numKeyBytes
focal_class.modifier: private final
focal_class.original_string: private final int numKeyBytes;
focal_class.type: int
focal_class.var_name: numKeyBytes
focal_class.declarator: indexEntrySize
focal_class.modifier: private final
focal_class.original_string: private final int indexEntrySize;
focal_class.type: int
focal_class.var_name: indexEntrySize
focal_class.declarator: indexEntriesPerSegment
focal_class.modifier: private final
focal_class.original_string: private final int indexEntriesPerSegment;
focal_class.type: int
focal_class.var_name: indexEntriesPerSegment
focal_class.declarator: lastIndexEntryOffset
focal_class.modifier: private final
focal_class.original_string: private final int lastIndexEntryOffset;
focal_class.type: int
focal_class.var_name: lastIndexEntryOffset
focal_class.declarator: segmentSize
focal_class.modifier: private final
focal_class.original_string: private final int segmentSize;
focal_class.type: int
focal_class.var_name: segmentSize
focal_class.declarator: totalNumBuffers
focal_class.modifier: private final
focal_class.original_string: private final int totalNumBuffers;
focal_class.type: int
focal_class.var_name: totalNumBuffers
focal_class.declarator: normalizedKeyFullyDetermines
focal_class.modifier: private final
focal_class.original_string: private final boolean normalizedKeyFullyDetermines;
focal_class.type: boolean
focal_class.var_name: normalizedKeyFullyDetermines
focal_class.declarator: useNormKeyUninverted
focal_class.modifier: private final
focal_class.original_string: private final boolean useNormKeyUninverted;
focal_class.type: boolean
focal_class.var_name: useNormKeyUninverted
focal_class.file: flink-runtime/src/main/java/org/apache/flink/runtime/operators/sort/NormalizedKeySorter.java
focal_class.identifier: NormalizedKeySorter
focal_class.interfaces: implements InMemorySorter<T>
focal_class.class_method_signature: NormalizedKeySorter.NormalizedKeySorter(TypeSerializer<T> serializer, TypeComparator<T> comparator, List<MemorySegment> memory)
focal_class.full_signature: public  NormalizedKeySorter(TypeSerializer<T> serializer, TypeComparator<T> comparator, List<MemorySegment> memory)
focal_class.identifier: NormalizedKeySorter
focal_class.modifiers: public
focal_class.parameters: (TypeSerializer<T> serializer, TypeComparator<T> comparator, List<MemorySegment> memory)
focal_class.signature:  NormalizedKeySorter(TypeSerializer<T> serializer, TypeComparator<T> comparator, List<MemorySegment> memory)
focal_class.class_method_signature: NormalizedKeySorter.NormalizedKeySorter(TypeSerializer<T> serializer, TypeComparator<T> comparator, 
  			List<MemorySegment> memory, int maxNormalizedKeyBytes)
focal_class.full_signature: public  NormalizedKeySorter(TypeSerializer<T> serializer, TypeComparator<T> comparator, 
  			List<MemorySegment> memory, int maxNormalizedKeyBytes)
focal_class.identifier: NormalizedKeySorter
focal_class.modifiers: public
focal_class.parameters: (TypeSerializer<T> serializer, TypeComparator<T> comparator, 
  			List<MemorySegment> memory, int maxNormalizedKeyBytes)
focal_class.signature:  NormalizedKeySorter(TypeSerializer<T> serializer, TypeComparator<T> comparator, 
  			List<MemorySegment> memory, int maxNormalizedKeyBytes)
focal_class.class_method_signature: NormalizedKeySorter.reset()
focal_class.full_signature: @Override public void reset()
focal_class.identifier: reset
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void reset()
focal_class.class_method_signature: NormalizedKeySorter.isEmpty()
focal_class.full_signature: @Override public boolean isEmpty()
focal_class.identifier: isEmpty
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isEmpty()
focal_class.class_method_signature: NormalizedKeySorter.dispose()
focal_class.full_signature: @Override public void dispose()
focal_class.identifier: dispose
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void dispose()
focal_class.class_method_signature: NormalizedKeySorter.getCapacity()
focal_class.full_signature: @Override public long getCapacity()
focal_class.identifier: getCapacity
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getCapacity()
focal_class.class_method_signature: NormalizedKeySorter.getOccupancy()
focal_class.full_signature: @Override public long getOccupancy()
focal_class.identifier: getOccupancy
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getOccupancy()
focal_class.class_method_signature: NormalizedKeySorter.getRecord(int logicalPosition)
focal_class.full_signature: @Override public T getRecord(int logicalPosition)
focal_class.identifier: getRecord
focal_class.modifiers: @Override public
focal_class.parameters: (int logicalPosition)
focal_class.return: T
focal_class.signature: T getRecord(int logicalPosition)
focal_class.class_method_signature: NormalizedKeySorter.getRecord(T reuse, int logicalPosition)
focal_class.full_signature: @Override public T getRecord(T reuse, int logicalPosition)
focal_class.identifier: getRecord
focal_class.modifiers: @Override public
focal_class.parameters: (T reuse, int logicalPosition)
focal_class.return: T
focal_class.signature: T getRecord(T reuse, int logicalPosition)
focal_class.class_method_signature: NormalizedKeySorter.write(T record)
focal_class.full_signature: @Override public boolean write(T record)
focal_class.identifier: write
focal_class.modifiers: @Override public
focal_class.parameters: (T record)
focal_class.return: boolean
focal_class.signature: boolean write(T record)
focal_class.class_method_signature: NormalizedKeySorter.readPointer(int logicalPosition)
focal_class.full_signature: private long readPointer(int logicalPosition)
focal_class.identifier: readPointer
focal_class.modifiers: private
focal_class.parameters: (int logicalPosition)
focal_class.return: long
focal_class.signature: long readPointer(int logicalPosition)
focal_class.class_method_signature: NormalizedKeySorter.getRecordFromBuffer(T reuse, long pointer)
focal_class.full_signature: private T getRecordFromBuffer(T reuse, long pointer)
focal_class.identifier: getRecordFromBuffer
focal_class.modifiers: private
focal_class.parameters: (T reuse, long pointer)
focal_class.return: T
focal_class.signature: T getRecordFromBuffer(T reuse, long pointer)
focal_class.class_method_signature: NormalizedKeySorter.getRecordFromBuffer(long pointer)
focal_class.full_signature: private T getRecordFromBuffer(long pointer)
focal_class.identifier: getRecordFromBuffer
focal_class.modifiers: private
focal_class.parameters: (long pointer)
focal_class.return: T
focal_class.signature: T getRecordFromBuffer(long pointer)
focal_class.class_method_signature: NormalizedKeySorter.compareRecords(long pointer1, long pointer2)
focal_class.full_signature: private int compareRecords(long pointer1, long pointer2)
focal_class.identifier: compareRecords
focal_class.modifiers: private
focal_class.parameters: (long pointer1, long pointer2)
focal_class.return: int
focal_class.signature: int compareRecords(long pointer1, long pointer2)
focal_class.class_method_signature: NormalizedKeySorter.memoryAvailable()
focal_class.full_signature: private boolean memoryAvailable()
focal_class.identifier: memoryAvailable
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean memoryAvailable()
focal_class.class_method_signature: NormalizedKeySorter.nextMemorySegment()
focal_class.full_signature: private MemorySegment nextMemorySegment()
focal_class.identifier: nextMemorySegment
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: MemorySegment
focal_class.signature: MemorySegment nextMemorySegment()
focal_class.class_method_signature: NormalizedKeySorter.compare(int i, int j)
focal_class.full_signature: @Override public int compare(int i, int j)
focal_class.identifier: compare
focal_class.modifiers: @Override public
focal_class.parameters: (int i, int j)
focal_class.return: int
focal_class.signature: int compare(int i, int j)
focal_class.class_method_signature: NormalizedKeySorter.swap(int i, int j)
focal_class.full_signature: @Override public void swap(int i, int j)
focal_class.identifier: swap
focal_class.modifiers: @Override public
focal_class.parameters: (int i, int j)
focal_class.return: void
focal_class.signature: void swap(int i, int j)
focal_class.class_method_signature: NormalizedKeySorter.size()
focal_class.full_signature: @Override public int size()
focal_class.identifier: size
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int size()
focal_class.class_method_signature: NormalizedKeySorter.getIterator()
focal_class.full_signature: @Override public final MutableObjectIterator<T> getIterator()
focal_class.identifier: getIterator
focal_class.modifiers: @Override public final
focal_class.parameters: ()
focal_class.return: MutableObjectIterator<T>
focal_class.signature: MutableObjectIterator<T> getIterator()
focal_class.class_method_signature: NormalizedKeySorter.writeToOutput(ChannelWriterOutputView output)
focal_class.full_signature: @Override public void writeToOutput(ChannelWriterOutputView output)
focal_class.identifier: writeToOutput
focal_class.modifiers: @Override public
focal_class.parameters: (ChannelWriterOutputView output)
focal_class.return: void
focal_class.signature: void writeToOutput(ChannelWriterOutputView output)
focal_class.class_method_signature: NormalizedKeySorter.writeToOutput(ChannelWriterOutputView output, LargeRecordHandler<T> largeRecordsOutput)
focal_class.full_signature: @Override public void writeToOutput(ChannelWriterOutputView output, LargeRecordHandler<T> largeRecordsOutput)
focal_class.identifier: writeToOutput
focal_class.modifiers: @Override public
focal_class.parameters: (ChannelWriterOutputView output, LargeRecordHandler<T> largeRecordsOutput)
focal_class.return: void
focal_class.signature: void writeToOutput(ChannelWriterOutputView output, LargeRecordHandler<T> largeRecordsOutput)
focal_class.class_method_signature: NormalizedKeySorter.writeToOutput(final ChannelWriterOutputView output, final int start, int num)
focal_class.full_signature: @Override public void writeToOutput(final ChannelWriterOutputView output, final int start, int num)
focal_class.identifier: writeToOutput
focal_class.modifiers: @Override public
focal_class.parameters: (final ChannelWriterOutputView output, final int start, int num)
focal_class.return: void
focal_class.signature: void writeToOutput(final ChannelWriterOutputView output, final int start, int num)
focal_method.body: @Override
  	public int compare(int i, int j) {
  		final int bufferNumI = i / this.indexEntriesPerSegment;
  		final int segmentOffsetI = (i % this.indexEntriesPerSegment) * this.indexEntrySize;
  		
  		final int bufferNumJ = j / this.indexEntriesPerSegment;
  		final int segmentOffsetJ = (j % this.indexEntriesPerSegment) * this.indexEntrySize;
  		
  		final MemorySegment segI = this.sortIndex.get(bufferNumI);
  		final MemorySegment segJ = this.sortIndex.get(bufferNumJ);
  		
  		int val = segI.compare(segJ, segmentOffsetI + OFFSET_LEN, segmentOffsetJ + OFFSET_LEN, this.numKeyBytes);
  		
  		if (val != 0 || this.normalizedKeyFullyDetermines) {
  			return this.useNormKeyUninverted ? val : -val;
  		}
  		
  		final long pointerI = segI.getLong(segmentOffsetI) & POINTER_MASK;
  		final long pointerJ = segJ.getLong(segmentOffsetJ)  & POINTER_MASK;
  		
  		return compareRecords(pointerI, pointerJ);
  	}
focal_method.class_method_signature: NormalizedKeySorter.compare(int i, int j)
focal_method.full_signature: @Override public int compare(int i, int j)
focal_method.identifier: compare
focal_method.invocations: get get compare getLong getLong compareRecords
focal_method.modifiers: @Override public
focal_method.parameters: (int i, int j)
focal_method.return: int
focal_method.signature: int compare(int i, int j)