@Override public boolean equals(int position, int offset, Block otherBlock, int otherPosition, int otherOffset, int length) { return block.equals(position, offset, otherBlock, otherPosition, otherOffset, length); }
@Override public boolean equals(int position, int offset, Block otherBlock, int otherPosition, int otherOffset, int length) { assureLoaded(); return block.equals(position, offset, otherBlock, otherPosition, otherOffset, length); }
@Override public boolean equals(int position, int offset, Block otherBlock, int otherPosition, int otherOffset, int length) { return dictionary.equals(getId(position), offset, otherBlock, otherPosition, otherOffset, length); }
@Override public boolean equals(int position, int offset, Block otherBlock, int otherPosition, int otherOffset, int length) { checkReadablePosition(position); return value.equals(0, offset, otherBlock, otherPosition, otherOffset, length); }
@Override public boolean equals(int position, int offset, Block otherBlock, int otherPosition, int otherOffset, int length) { position = getAbsolutePosition(position); if (position % 2 == 0) { return getRawKeyBlock().equals(position / 2, offset, otherBlock, otherPosition, otherOffset, length); } else { return getRawValueBlock().equals(position / 2, offset, otherBlock, otherPosition, otherOffset, length); } }
@Override public boolean equals(int position, int offset, Block otherBlock, int otherPosition, int otherOffset, int length) { checkFieldIndex(position); return getRawFieldBlock(position).equals(rowIndex, offset, otherBlock, otherPosition, otherOffset, length); }
@Override public boolean equalTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition) { int leftLength = leftBlock.getSliceLength(leftPosition); int rightLength = rightBlock.getSliceLength(rightPosition); if (leftLength != rightLength) { return false; } return leftBlock.equals(leftPosition, 0, rightBlock, rightPosition, 0, leftLength); }
@Override public boolean equalTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition) { int leftLength = leftBlock.getSliceLength(leftPosition); int rightLength = rightBlock.getSliceLength(rightPosition); if (leftLength != rightLength) { return false; } return leftBlock.equals(leftPosition, 0, rightBlock, rightPosition, 0, leftLength); }
@Override public boolean equalTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition) { int leftLength = leftBlock.getSliceLength(leftPosition); int rightLength = rightBlock.getSliceLength(rightPosition); if (leftLength != rightLength) { return false; } return leftBlock.equals(leftPosition, 0, rightBlock, rightPosition, 0, leftLength); }
@Override public boolean equals(int position, int offset, Block otherBlock, int otherPosition, int otherOffset, int length) { checkReadablePosition(position); return getBlock().equals(position + start, offset, otherBlock, otherPosition, otherOffset, length); }
@Override public boolean equalTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition) { int leftLength = leftBlock.getSliceLength(leftPosition); int rightLength = rightBlock.getSliceLength(rightPosition); if (leftLength != rightLength) { return false; } return leftBlock.equals(leftPosition, 0, rightBlock, rightPosition, 0, leftLength); }
/** * Get slot position of element at {@code position} of {@code block} */ private long getHashPositionOfElement(Block block, int position) { checkArgument(!block.isNull(position), "position is null"); int length = block.getSliceLength(position); long hashPosition = getMaskedHash(block.hash(position, 0, length)); while (true) { int blockPosition = blockPositionByHash.get(hashPosition); if (blockPosition == EMPTY_SLOT) { // Doesn't have this element return hashPosition; } else if (elementBlock.getSliceLength(blockPosition) == length && block.equals(position, 0, elementBlock, blockPosition, 0, length)) { // Already has this element return hashPosition; } hashPosition = getMaskedHash(hashPosition + 1); } }
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)); } }
@SqlType(BOOLEAN) public static boolean isDistinctFrom( @BlockPosition @SqlType(value = JSON, nativeContainerType = Slice.class) Block left, @BlockIndex int leftPosition, @BlockPosition @SqlType(value = JSON, nativeContainerType = Slice.class) Block right, @BlockIndex int rightPosition) { if (left.isNull(leftPosition) != right.isNull(rightPosition)) { return true; } if (left.isNull(leftPosition)) { return false; } int leftLength = left.getSliceLength(leftPosition); int rightLength = right.getSliceLength(rightPosition); if (leftLength != rightLength) { return true; } return !left.equals(leftPosition, 0, right, rightPosition, 0, leftLength); } }
@SqlType(StandardTypes.BOOLEAN) public static boolean isDistinctFrom( @BlockPosition @SqlType(value = StandardTypes.VARBINARY, nativeContainerType = Slice.class) Block left, @BlockIndex int leftPosition, @BlockPosition @SqlType(value = StandardTypes.VARBINARY, nativeContainerType = Slice.class) Block right, @BlockIndex int rightPosition) { if (left.isNull(leftPosition) != right.isNull(rightPosition)) { return true; } if (left.isNull(leftPosition)) { return false; } int leftLength = left.getSliceLength(leftPosition); int rightLength = right.getSliceLength(rightPosition); if (leftLength != rightLength) { return true; } return !left.equals(leftPosition, 0, right, rightPosition, 0, leftLength); } }
@LiteralParameters({"x", "y"}) @SqlType(StandardTypes.BOOLEAN) public static boolean isDistinctFrom( @BlockPosition @SqlType(value = "varchar(x)", nativeContainerType = Slice.class) Block left, @BlockIndex int leftPosition, @BlockPosition @SqlType(value = "varchar(y)", nativeContainerType = Slice.class) Block right, @BlockIndex int rightPosition) { if (left.isNull(leftPosition) != right.isNull(rightPosition)) { return true; } if (left.isNull(leftPosition)) { return false; } int leftLength = left.getSliceLength(leftPosition); int rightLength = right.getSliceLength(rightPosition); if (leftLength != rightLength) { return true; } return !left.equals(leftPosition, 0, right, rightPosition, 0, leftLength); } }
@LiteralParameters("x") @SqlType(StandardTypes.BOOLEAN) public static boolean isDistinctFrom( @BlockPosition @SqlType(value = "char(x)", nativeContainerType = Slice.class) Block left, @BlockIndex int leftPosition, @BlockPosition @SqlType(value = "char(x)", nativeContainerType = Slice.class) Block right, @BlockIndex int rightPosition) { if (left.isNull(leftPosition) != right.isNull(rightPosition)) { return true; } if (left.isNull(leftPosition)) { return false; } int leftLength = left.getSliceLength(leftPosition); int rightLength = right.getSliceLength(rightPosition); if (leftLength != rightLength) { return true; } return !left.equals(leftPosition, 0, right, rightPosition, 0, leftLength); } }
@Override public boolean equals(int position, int offset, Block otherBlock, int otherPosition, int otherOffset, int length) { return dictionary.equals(getId(position), offset, otherBlock, otherPosition, otherOffset, length); }
@Override public boolean equalTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition) { int leftLength = leftBlock.getSliceLength(leftPosition); int rightLength = rightBlock.getSliceLength(rightPosition); if (leftLength != rightLength) { return false; } return leftBlock.equals(leftPosition, 0, rightBlock, rightPosition, 0, leftLength); }
@Override public boolean equals(int position, int offset, Block otherBlock, int otherPosition, int otherOffset, int length) { checkFieldIndex(position); return getRawFieldBlock(position).equals(rowIndex, offset, otherBlock, otherPosition, otherOffset, length); }