Java Code Examples for io.airlift.slice.Slice#equals()
The following examples show how to use
io.airlift.slice.Slice#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestOrcMetadataReader.java From presto with Apache License 2.0 | 6 votes |
private static void testMaxStringTruncateAtFirstReplacementCharacter(Slice prefix, Slice suffix) { for (int testCodePoint : TEST_CODE_POINTS) { Slice codePoint = codePointToUtf8(testCodePoint); Slice value = concatSlice(prefix, codePoint, suffix); assertEquals(maxStringTruncateToValidRange(value, ORC_HIVE_8732), value); // For ORIGINAL, skip prefixes that truncate if (prefix.equals(maxStringTruncateToValidRange(prefix, ORIGINAL))) { if (testCodePoint == REPLACEMENT_CHARACTER_CODE_POINT || testCodePoint >= MIN_SUPPLEMENTARY_CODE_POINT) { // truncate at test code point assertEquals(maxStringTruncateToValidRange(value, ORIGINAL), concatSlice(prefix, wrappedBuffer((byte) 0xFF))); } else { // truncate in suffix (if at all) assertEquals(maxStringTruncateToValidRange(value, ORIGINAL), concatSlice(prefix, codePoint, maxStringTruncateToValidRange(suffix, ORIGINAL))); } } } }
Example 2
Source File: LongEncoding.java From presto with Apache License 2.0 | 6 votes |
private static long parseLong(Slice slice, int start, int length) { if (slice.equals(start, length, MIN_LONG, 0, MIN_LONG.length())) { return Long.MIN_VALUE; } int limit = start + length; int sign; if (slice.getByte(start) == '-') { sign = -1; start++; } else { sign = 1; } long value = slice.getByte(start) - ((int) '0'); start++; while (start < limit) { value = value * 10 + (slice.getByte(start) - ((int) '0')); start++; } return value * sign; }
Example 3
Source File: EvaluateClassifierPredictionsAggregation.java From presto with Apache License 2.0 | 6 votes |
@InputFunction @LiteralParameters({"x", "y"}) public static void input(@AggregationState EvaluateClassifierPredictionsState state, @SqlType("varchar(x)") Slice truth, @SqlType("varchar(y)") Slice prediction) { if (truth.equals(prediction)) { String key = truth.toStringUtf8(); if (!state.getTruePositives().containsKey(key)) { state.addMemoryUsage(truth.length() + SIZE_OF_INT); } state.getTruePositives().put(key, state.getTruePositives().getOrDefault(key, 0) + 1); } else { String truthKey = truth.toStringUtf8(); String predictionKey = prediction.toStringUtf8(); if (!state.getFalsePositives().containsKey(predictionKey)) { state.addMemoryUsage(prediction.length() + SIZE_OF_INT); } state.getFalsePositives().put(predictionKey, state.getFalsePositives().getOrDefault(predictionKey, 0) + 1); if (!state.getFalseNegatives().containsKey(truthKey)) { state.addMemoryUsage(truth.length() + SIZE_OF_INT); } state.getFalseNegatives().put(truthKey, state.getFalseNegatives().getOrDefault(truthKey, 0) + 1); } }
Example 4
Source File: TestOrcMetadataReader.java From presto with Apache License 2.0 | 6 votes |
private static void testMinStringTruncateAtFirstReplacementCharacter(Slice prefix, Slice suffix) { for (int testCodePoint : TEST_CODE_POINTS) { Slice codePoint = codePointToUtf8(testCodePoint); Slice value = concatSlice(prefix, codePoint, suffix); assertEquals(minStringTruncateToValidRange(value, ORC_HIVE_8732), value); // For ORIGINAL, skip prefixes that truncate if (prefix.equals(minStringTruncateToValidRange(prefix, ORIGINAL))) { if (testCodePoint == REPLACEMENT_CHARACTER_CODE_POINT || testCodePoint >= MIN_SUPPLEMENTARY_CODE_POINT) { // truncate at test code point assertEquals(minStringTruncateToValidRange(value, ORIGINAL), prefix); } else { // truncate in suffix (if at all) assertEquals(minStringTruncateToValidRange(value, ORIGINAL), concatSlice(prefix, codePoint, minStringTruncateToValidRange(suffix, ORIGINAL))); } } } }
Example 5
Source File: JsonOperators.java From presto with Apache License 2.0 | 5 votes |
@ScalarOperator(NOT_EQUAL) @SqlType(BOOLEAN) @SqlNullable public static Boolean notEqual(@SqlType(JSON) Slice leftJson, @SqlType(JSON) Slice rightJson) { return !leftJson.equals(rightJson); }
Example 6
Source File: IpAddressOperators.java From presto with Apache License 2.0 | 5 votes |
@ScalarOperator(EQUAL) @SqlType(StandardTypes.BOOLEAN) @SqlNullable public static Boolean equal(@SqlType(StandardTypes.IPADDRESS) Slice left, @SqlType(StandardTypes.IPADDRESS) Slice right) { return left.equals(right); }
Example 7
Source File: IpAddressOperators.java From presto with Apache License 2.0 | 5 votes |
@ScalarOperator(NOT_EQUAL) @SqlType(StandardTypes.BOOLEAN) @SqlNullable public static Boolean notEqual(@SqlType(StandardTypes.IPADDRESS) Slice left, @SqlType(StandardTypes.IPADDRESS) Slice right) { return !left.equals(right); }
Example 8
Source File: VarcharOperators.java From presto with Apache License 2.0 | 5 votes |
@LiteralParameters("x") @ScalarOperator(EQUAL) @SqlType(StandardTypes.BOOLEAN) @SqlNullable public static Boolean equal(@SqlType("varchar(x)") Slice left, @SqlType("varchar(x)") Slice right) { return left.equals(right); }
Example 9
Source File: VarcharOperators.java From presto with Apache License 2.0 | 5 votes |
@LiteralParameters("x") @ScalarOperator(NOT_EQUAL) @SqlType(StandardTypes.BOOLEAN) @SqlNullable public static Boolean notEqual(@SqlType("varchar(x)") Slice left, @SqlType("varchar(x)") Slice right) { return !left.equals(right); }
Example 10
Source File: JsonType.java From presto with Apache License 2.0 | 5 votes |
@Override public boolean equalTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition) { Slice leftValue = leftBlock.getSlice(leftPosition, 0, leftBlock.getSliceLength(leftPosition)); Slice rightValue = rightBlock.getSlice(rightPosition, 0, rightBlock.getSliceLength(rightPosition)); return leftValue.equals(rightValue); }
Example 11
Source File: VarbinaryOperators.java From presto with Apache License 2.0 | 5 votes |
@ScalarOperator(EQUAL) @SqlType(StandardTypes.BOOLEAN) @SqlNullable public static Boolean equal(@SqlType(StandardTypes.VARBINARY) Slice left, @SqlType(StandardTypes.VARBINARY) Slice right) { return left.equals(right); }
Example 12
Source File: VarbinaryOperators.java From presto with Apache License 2.0 | 5 votes |
@ScalarOperator(NOT_EQUAL) @SqlType(StandardTypes.BOOLEAN) @SqlNullable public static Boolean notEqual(@SqlType(StandardTypes.VARBINARY) Slice left, @SqlType(StandardTypes.VARBINARY) Slice right) { return !left.equals(right); }
Example 13
Source File: CharOperators.java From presto with Apache License 2.0 | 5 votes |
@LiteralParameters("x") @ScalarOperator(EQUAL) @SqlType(StandardTypes.BOOLEAN) @SqlNullable public static Boolean equal(@SqlType("char(x)") Slice left, @SqlType("char(x)") Slice right) { return left.equals(right); }
Example 14
Source File: CharOperators.java From presto with Apache License 2.0 | 5 votes |
@LiteralParameters("x") @ScalarOperator(NOT_EQUAL) @SqlType(StandardTypes.BOOLEAN) @SqlNullable public static Boolean notEqual(@SqlType("char(x)") Slice left, @SqlType("char(x)") Slice right) { return !left.equals(right); }
Example 15
Source File: UuidOperators.java From presto with Apache License 2.0 | 5 votes |
@ScalarOperator(EQUAL) @SqlType(StandardTypes.BOOLEAN) @SqlNullable public static Boolean equal(@SqlType(StandardTypes.UUID) Slice left, @SqlType(StandardTypes.UUID) Slice right) { return left.equals(right); }
Example 16
Source File: UuidOperators.java From presto with Apache License 2.0 | 5 votes |
@ScalarOperator(NOT_EQUAL) @SqlType(StandardTypes.BOOLEAN) @SqlNullable public static Boolean notEqual(@SqlType(StandardTypes.UUID) Slice left, @SqlType(StandardTypes.UUID) Slice right) { return !left.equals(right); }
Example 17
Source File: ObjectIdFunctions.java From presto with Apache License 2.0 | 5 votes |
@ScalarOperator(EQUAL) @SqlType(StandardTypes.BOOLEAN) @SqlNullable public static Boolean equal(@SqlType("ObjectId") Slice left, @SqlType("ObjectId") Slice right) { return left.equals(right); }
Example 18
Source File: ObjectIdFunctions.java From presto with Apache License 2.0 | 5 votes |
@ScalarOperator(NOT_EQUAL) @SqlType(StandardTypes.BOOLEAN) @SqlNullable public static Boolean notEqual(@SqlType("ObjectId") Slice left, @SqlType("ObjectId") Slice right) { return !left.equals(right); }
Example 19
Source File: JsonOperators.java From presto with Apache License 2.0 | 5 votes |
@ScalarOperator(EQUAL) @SqlType(BOOLEAN) @SqlNullable public static Boolean equals(@SqlType(JSON) Slice leftJson, @SqlType(JSON) Slice rightJson) { return leftJson.equals(rightJson); }