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: 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.declarator: ioManager
test_class.modifier: private
test_class.original_string: private IOManager ioManager;
test_class.type: IOManager
test_class.var_name: ioManager
test_class.declarator: serializer
test_class.modifier: private
test_class.original_string: private TypeSerializer<IntPair> serializer;
test_class.type: TypeSerializer<IntPair>
test_class.var_name: serializer
test_class.declarator: comparator
test_class.modifier: private
test_class.original_string: private TypeComparator<IntPair> comparator;
test_class.type: TypeComparator<IntPair>
test_class.var_name: comparator
test_class.file: flink-runtime/src/test/java/org/apache/flink/runtime/operators/sort/FixedLengthRecordSorterTest.java
test_class.identifier: FixedLengthRecordSorterTest
test_case.body: @Test
  	public void testSwap() throws Exception {
  		final int numSegments = MEMORY_SIZE / MEMORY_PAGE_SIZE;
  		final List<MemorySegment> memory = this.memoryManager.allocatePages(new DummyInvokable(), numSegments);
  		
  		FixedLengthRecordSorter<IntPair> sorter = newSortBuffer(memory);
  		RandomIntPairGenerator generator = new RandomIntPairGenerator(SEED);
  		
  		// write the records
  		IntPair record = new IntPair();
  		int num = -1;
  		do {
  			generator.next(record);
  			num++;
  		}
  		while (sorter.write(record) && num < 3354624);
  		
  		// swap the records
  		int start = 0, end = num - 1;
  		while (start < end) {
  			sorter.swap(start++, end--);
  		}
  		
  		// re-read the records
  		generator.reset();
  		IntPair readTarget = new IntPair();
  		
  		int i = num - 1;
  		while (i >= 0) {
  			generator.next(record);
  			readTarget = sorter.getRecord(readTarget, i--);
  			
  			int rk = readTarget.getKey();
  			int gk = record.getKey();
  			
  			int rv = readTarget.getValue();
  			int gv = record.getValue();
  			
  			Assert.assertEquals("The re-read key is wrong", gk, rk);
  			Assert.assertEquals("The re-read value is wrong", gv, rv);
  		}
  		
  		// release the memory occupied by the buffers
  		sorter.dispose();
  		this.memoryManager.release(memory);
  	}
test_case.class_method_signature: FixedLengthRecordSorterTest.testSwap()
test_case.full_signature: @Test public void testSwap()
test_case.identifier: testSwap
test_case.invocations: allocatePages newSortBuffer next write swap reset next getRecord getKey getKey getValue getValue assertEquals assertEquals dispose release
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSwap()
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: 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: outView
focal_class.modifier: private final
focal_class.original_string: private final SingleSegmentOutputView outView;
focal_class.type: SingleSegmentOutputView
focal_class.var_name: outView
focal_class.declarator: inView
focal_class.modifier: private final
focal_class.original_string: private final SingleSegmentInputView inView;
focal_class.type: SingleSegmentInputView
focal_class.var_name: inView
focal_class.declarator: currentSortBufferSegment
focal_class.modifier: private
focal_class.original_string: private MemorySegment currentSortBufferSegment;
focal_class.type: MemorySegment
focal_class.var_name: currentSortBufferSegment
focal_class.declarator: currentSortBufferOffset
focal_class.modifier: private
focal_class.original_string: private int currentSortBufferOffset;
focal_class.type: int
focal_class.var_name: currentSortBufferOffset
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: sortBuffer
focal_class.modifier: private final
focal_class.original_string: private final ArrayList<MemorySegment> sortBuffer;
focal_class.type: ArrayList<MemorySegment>
focal_class.var_name: sortBuffer
focal_class.declarator: sortBufferBytes
focal_class.modifier: private
focal_class.original_string: private long sortBufferBytes;
focal_class.type: long
focal_class.var_name: sortBufferBytes
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: recordSize
focal_class.modifier: private final
focal_class.original_string: private final int recordSize;
focal_class.type: int
focal_class.var_name: recordSize
focal_class.declarator: recordsPerSegment
focal_class.modifier: private final
focal_class.original_string: private final int recordsPerSegment;
focal_class.type: int
focal_class.var_name: recordsPerSegment
focal_class.declarator: lastEntryOffset
focal_class.modifier: private final
focal_class.original_string: private final int lastEntryOffset;
focal_class.type: int
focal_class.var_name: lastEntryOffset
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: 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.declarator: recordInstance
focal_class.modifier: private final
focal_class.original_string: private final T recordInstance;
focal_class.type: T
focal_class.var_name: recordInstance
focal_class.file: flink-runtime/src/main/java/org/apache/flink/runtime/operators/sort/FixedLengthRecordSorter.java
focal_class.identifier: FixedLengthRecordSorter
focal_class.interfaces: implements InMemorySorter<T>
focal_class.class_method_signature: FixedLengthRecordSorter.FixedLengthRecordSorter(TypeSerializer<T> serializer, TypeComparator<T> comparator, 
  			List<MemorySegment> memory)
focal_class.full_signature: public  FixedLengthRecordSorter(TypeSerializer<T> serializer, TypeComparator<T> comparator, 
  			List<MemorySegment> memory)
focal_class.identifier: FixedLengthRecordSorter
focal_class.modifiers: public
focal_class.parameters: (TypeSerializer<T> serializer, TypeComparator<T> comparator, 
  			List<MemorySegment> memory)
focal_class.signature:  FixedLengthRecordSorter(TypeSerializer<T> serializer, TypeComparator<T> comparator, 
  			List<MemorySegment> memory)
focal_class.class_method_signature: FixedLengthRecordSorter.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: FixedLengthRecordSorter.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: FixedLengthRecordSorter.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: FixedLengthRecordSorter.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: FixedLengthRecordSorter.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: FixedLengthRecordSorter.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: FixedLengthRecordSorter.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: FixedLengthRecordSorter.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: FixedLengthRecordSorter.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: FixedLengthRecordSorter.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: FixedLengthRecordSorter.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: FixedLengthRecordSorter.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: FixedLengthRecordSorter.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: FixedLengthRecordSorter.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: FixedLengthRecordSorter.writeToOutput(final ChannelWriterOutputView output)
focal_class.full_signature: @Override public void writeToOutput(final ChannelWriterOutputView output)
focal_class.identifier: writeToOutput
focal_class.modifiers: @Override public
focal_class.parameters: (final ChannelWriterOutputView output)
focal_class.return: void
focal_class.signature: void writeToOutput(final ChannelWriterOutputView output)
focal_class.class_method_signature: FixedLengthRecordSorter.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: FixedLengthRecordSorter.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 void swap(int i, int j) {
  		final int bufferNumI = i / this.recordsPerSegment;
  		final int segmentOffsetI = (i % this.recordsPerSegment) * this.recordSize;
  		
  		final int bufferNumJ = j / this.recordsPerSegment;
  		final int segmentOffsetJ = (j % this.recordsPerSegment) * this.recordSize;
  		
  		final MemorySegment segI = this.sortBuffer.get(bufferNumI);
  		final MemorySegment segJ = this.sortBuffer.get(bufferNumJ);
  		
  		segI.swapBytes(this.swapBuffer, segJ, segmentOffsetI, segmentOffsetJ, this.recordSize);
  	}
focal_method.class_method_signature: FixedLengthRecordSorter.swap(int i, int j)
focal_method.full_signature: @Override public void swap(int i, int j)
focal_method.identifier: swap
focal_method.invocations: get get swapBytes
focal_method.modifiers: @Override public
focal_method.parameters: (int i, int j)
focal_method.return: void
focal_method.signature: void swap(int i, int j)