本文整理了Java中com.facebook.presto.spi.block.Block.compareTo()
方法的一些代码示例,展示了Block.compareTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.compareTo()
方法的具体详情如下:
包路径:com.facebook.presto.spi.block.Block
类名称:Block
方法名:compareTo
[英]Compares the byte sequences at offset in the value at positionto the byte sequence at otherOffset in the value at otherPositionin otherBlock. This method must be implemented if @{code getSlice} is implemented.
[中]将位置处的值中偏移量处的字节序列与其他块中其他位置处的值中其他偏移量处的字节序列进行比较。如果实现了@{code getSlice},则必须实现此方法。
代码示例来源:origin: prestodb/presto
@Override
public int compareTo(int leftPosition, int leftOffset, int leftLength, Block rightBlock, int rightPosition, int rightOffset, int rightLength)
{
return block.compareTo(leftPosition, leftOffset, leftLength, rightBlock, rightPosition, rightOffset, rightLength);
}
代码示例来源:origin: prestodb/presto
@Override
public int compareTo(int leftPosition, int leftOffset, int leftLength, Block rightBlock, int rightPosition, int rightOffset, int rightLength)
{
checkReadablePosition(leftPosition);
return value.compareTo(0, leftOffset, leftLength, rightBlock, rightPosition, rightOffset, rightLength);
}
代码示例来源:origin: prestodb/presto
@Override
public int compareTo(int leftPosition, int leftOffset, int leftLength, Block rightBlock, int rightPosition, int rightOffset, int rightLength)
{
return dictionary.compareTo(getId(leftPosition), leftOffset, leftLength, rightBlock, rightPosition, rightOffset, rightLength);
}
代码示例来源:origin: prestodb/presto
@Override
public int compareTo(int leftPosition, int leftOffset, int leftLength, Block rightBlock, int rightPosition, int rightOffset, int rightLength)
{
assureLoaded();
return block.compareTo(leftPosition,
leftOffset,
leftLength,
rightBlock,
rightPosition,
rightOffset,
rightLength);
}
代码示例来源:origin: prestodb/presto
@Override
public int compareTo(int position, int offset, int length, Block otherBlock, int otherPosition, int otherOffset, int otherLength)
{
position = getAbsolutePosition(position);
if (position % 2 == 0) {
return getRawKeyBlock().compareTo(position / 2, offset, length, otherBlock, otherPosition, otherOffset, otherLength);
}
else {
return getRawValueBlock().compareTo(position / 2, offset, length, otherBlock, otherPosition, otherOffset, otherLength);
}
}
代码示例来源:origin: prestodb/presto
@Override
public int compareTo(int position, int offset, int length, Block otherBlock, int otherPosition, int otherOffset, int otherLength)
{
checkFieldIndex(position);
return getRawFieldBlock(position).compareTo(rowIndex, offset, length, otherBlock, otherPosition, otherOffset, otherLength);
}
代码示例来源:origin: prestodb/presto
@Override
public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
int leftLength = leftBlock.getSliceLength(leftPosition);
int rightLength = rightBlock.getSliceLength(rightPosition);
return leftBlock.compareTo(leftPosition, 0, leftLength, rightBlock, rightPosition, 0, rightLength);
}
代码示例来源:origin: prestodb/presto
@Override
public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
return leftBlock.compareTo(leftPosition, 0, getFixedSize(), rightBlock, rightPosition, 0, getFixedSize());
}
代码示例来源:origin: prestodb/presto
@Override
public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
int leftLength = leftBlock.getSliceLength(leftPosition);
int rightLength = rightBlock.getSliceLength(rightPosition);
return leftBlock.compareTo(leftPosition, 0, leftLength, rightBlock, rightPosition, 0, rightLength);
}
代码示例来源:origin: prestodb/presto
@Override
public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
int leftLength = leftBlock.getSliceLength(leftPosition);
int rightLength = rightBlock.getSliceLength(rightPosition);
return leftBlock.compareTo(leftPosition, 0, leftLength, rightBlock, rightPosition, 0, rightLength);
}
代码示例来源:origin: prestodb/presto
@Override
public int compareTo(int leftPosition, int leftOffset, int leftLength, Block rightBlock, int rightPosition, int rightOffset, int rightLength)
{
checkReadablePosition(leftPosition);
return getBlock().compareTo(leftPosition + start, leftOffset, leftLength, rightBlock, rightPosition, rightOffset, rightLength);
}
代码示例来源:origin: prestodb/presto
@Override
public int compare(int left, int right)
{
boolean nullLeft = elementBlock.isNull(left);
boolean nullRight = elementBlock.isNull(right);
if (nullLeft && nullRight) {
return 0;
}
if (nullLeft) {
return 1;
}
if (nullRight) {
return -1;
}
return elementBlock.compareTo(
left,
0,
elementBlock.getSliceLength(left),
elementBlock,
right,
0,
elementBlock.getSliceLength(right));
}
});
代码示例来源:origin: prestodb/presto
private static boolean equals(Block block1, Block block2)
{
boolean retval = block1.getPositionCount() == block2.getPositionCount();
for (int i = 0; i < block1.getPositionCount() && retval; ++i) {
if (block1 instanceof ArrayBlock && block2 instanceof ArrayBlock) {
retval = equals(block1.getObject(i, Block.class), block2.getObject(i, Block.class));
}
else {
retval = block1.compareTo(i, 0, block1.getSliceLength(i), block2, i, 0, block2.getSliceLength(i)) == 0;
}
}
return retval;
}
代码示例来源:origin: prestodb/presto
protected void assertSlicePosition(Block block, int position, Slice expectedSliceValue)
{
int length = block.getSliceLength(position);
assertEquals(length, expectedSliceValue.length());
Block expectedBlock = toSingeValuedBlock(expectedSliceValue);
for (int offset = 0; offset < length - 3; offset++) {
assertEquals(block.getSlice(position, offset, 3), expectedSliceValue.slice(offset, 3));
assertTrue(block.bytesEqual(position, offset, expectedSliceValue, offset, 3));
// if your tests fail here, please change your test to not use this value
assertFalse(block.bytesEqual(position, offset, Slices.utf8Slice("XXX"), 0, 3));
assertEquals(block.bytesCompare(position, offset, 3, expectedSliceValue, offset, 3), 0);
assertTrue(block.bytesCompare(position, offset, 3, expectedSliceValue, offset, 2) > 0);
Slice greaterSlice = createGreaterValue(expectedSliceValue, offset, 3);
assertTrue(block.bytesCompare(position, offset, 3, greaterSlice, 0, greaterSlice.length()) < 0);
assertTrue(block.equals(position, offset, expectedBlock, 0, offset, 3));
assertEquals(block.compareTo(position, offset, 3, expectedBlock, 0, offset, 3), 0);
BlockBuilder blockBuilder = VARBINARY.createBlockBuilder(null, 1);
block.writeBytesTo(position, offset, 3, blockBuilder);
blockBuilder.closeEntry();
Block segment = blockBuilder.build();
assertTrue(block.equals(position, offset, segment, 0, 0, 3));
}
}
代码示例来源:origin: prestodb/presto
@SqlType(StandardTypes.BOOLEAN)
public static boolean isDistinctFrom(
@BlockPosition @SqlType(value = StandardTypes.IPADDRESS, nativeContainerType = Slice.class) Block left,
@BlockIndex int leftPosition,
@BlockPosition @SqlType(value = StandardTypes.IPADDRESS, nativeContainerType = Slice.class) Block right,
@BlockIndex int rightPosition)
{
if (left.isNull(leftPosition) != right.isNull(rightPosition)) {
return true;
}
if (left.isNull(leftPosition)) {
return false;
}
return left.compareTo(leftPosition, 0, IPADDRESS.getFixedSize(), right, rightPosition, 0, IPADDRESS.getFixedSize()) != 0;
}
}
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
@Override
public int compareTo(int leftPosition, int leftOffset, int leftLength, Block rightBlock, int rightPosition, int rightOffset, int rightLength)
{
return block.compareTo(leftPosition, leftOffset, leftLength, rightBlock, rightPosition, rightOffset, rightLength);
}
代码示例来源:origin: com.facebook.presto/presto-spi
@Override
public int compareTo(int leftPosition, int leftOffset, int leftLength, Block rightBlock, int rightPosition, int rightOffset, int rightLength)
{
return dictionary.compareTo(getId(leftPosition), leftOffset, leftLength, rightBlock, rightPosition, rightOffset, rightLength);
}
代码示例来源:origin: com.facebook.presto/presto-spi
@Override
public int compareTo(int position, int offset, int length, Block otherBlock, int otherPosition, int otherOffset, int otherLength)
{
position = getAbsolutePosition(position);
if (position % 2 == 0) {
return getRawKeyBlock().compareTo(position / 2, offset, length, otherBlock, otherPosition, otherOffset, otherLength);
}
else {
return getRawValueBlock().compareTo(position / 2, offset, length, otherBlock, otherPosition, otherOffset, otherLength);
}
}
代码示例来源:origin: com.facebook.presto/presto-spi
@Override
public int compareTo(int position, int offset, int length, Block otherBlock, int otherPosition, int otherOffset, int otherLength)
{
checkFieldIndex(position);
return getRawFieldBlock(position).compareTo(rowIndex, offset, length, otherBlock, otherPosition, otherOffset, otherLength);
}
代码示例来源:origin: com.facebook.presto/presto-spi
@Override
public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
int leftLength = leftBlock.getSliceLength(leftPosition);
int rightLength = rightBlock.getSliceLength(rightPosition);
return leftBlock.compareTo(leftPosition, 0, leftLength, rightBlock, rightPosition, 0, rightLength);
}
内容来源于网络,如有侵权,请联系作者删除!