本文整理汇总了Java中org.apache.flink.core.memory.MemorySegment.compare方法的典型用法代码示例。如果您正苦于以下问题:Java MemorySegment.compare方法的具体用法?Java MemorySegment.compare怎么用?Java MemorySegment.compare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.core.memory.MemorySegment
的用法示例。
在下文中一共展示了MemorySegment.compare方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compare
import org.apache.flink.core.memory.MemorySegment; //导入方法依赖的package包/类
@Override
public int compare(int segmentNumberI, int segmentOffsetI, int segmentNumberJ, int segmentOffsetJ) {
final MemorySegment segI = this.sortIndex.get(segmentNumberI);
final MemorySegment segJ = this.sortIndex.get(segmentNumberJ);
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);
}
示例2: testNormalizedKeysGreatSmall
import org.apache.flink.core.memory.MemorySegment; //导入方法依赖的package包/类
protected void testNormalizedKeysGreatSmall(boolean greater, TypeComparator<T> comparator, boolean halfLength) {
try {
T[] data = getSortedData();
// Get the normKeyLen on which we are testing
int normKeyLen = getNormKeyLen(halfLength, data, comparator);
// Write the data into different 2 memory segments
MemorySegment memSegLow = setupNormalizedKeysMemSegment(data, normKeyLen, comparator);
MemorySegment memSegHigh = setupNormalizedKeysMemSegment(data, normKeyLen, comparator);
boolean fullyDetermines = !comparator.isNormalizedKeyPrefixOnly(normKeyLen);
// Compare every element with every bigger element
for (int l = 0; l < data.length - 1; l++) {
for (int h = l + 1; h < data.length; h++) {
int cmp;
if (greater) {
cmp = memSegLow.compare(memSegHigh, l * normKeyLen, h * normKeyLen, normKeyLen);
if (fullyDetermines) {
assertTrue(cmp < 0);
} else {
assertTrue(cmp <= 0);
}
} else {
cmp = memSegHigh.compare(memSegLow, h * normKeyLen, l * normKeyLen, normKeyLen);
if (fullyDetermines) {
assertTrue(cmp > 0);
} else {
assertTrue(cmp >= 0);
}
}
}
}
} catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
fail("Exception in test: " + e.getMessage());
}
}
示例3: compare
import org.apache.flink.core.memory.MemorySegment; //导入方法依赖的package包/类
@Override
public int compare(int segmentNumberI, int segmentOffsetI, int segmentNumberJ, int segmentOffsetJ) {
final MemorySegment segI = this.sortBuffer.get(segmentNumberI);
final MemorySegment segJ = this.sortBuffer.get(segmentNumberJ);
int val = segI.compare(segJ, segmentOffsetI, segmentOffsetJ, this.numKeyBytes);
return this.useNormKeyUninverted ? val : -val;
}