当前位置: 首页>>代码示例>>Java>>正文


Java MemorySegment.compare方法代码示例

本文整理汇总了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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:NormalizedKeySorter.java

示例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());
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:40,代码来源:ComparatorTestBase.java

示例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;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:FixedLengthRecordSorter.java


注:本文中的org.apache.flink.core.memory.MemorySegment.compare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。