Java Code Examples for io.airlift.slice.Slice#compareTo()
The following examples show how to use
io.airlift.slice.Slice#compareTo() .
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: StringStatisticsBuilder.java From presto with Apache License 2.0 | 6 votes |
@Override public void addValue(Slice value) { requireNonNull(value, "value is null"); if (nonNullValueCount == 0) { checkState(minimum == null && maximum == null); minimum = value; maximum = value; } else if (minimum != null && value.compareTo(minimum) <= 0) { minimum = value; } else if (maximum != null && value.compareTo(maximum) >= 0) { maximum = value; } nonNullValueCount++; sum = addExact(sum, value.length()); }
Example 2
Source File: ShardStats.java From presto with Apache License 2.0 | 5 votes |
private static ColumnStats indexString(Type type, OrcRecordReader reader, long columnId) throws IOException { boolean minSet = false; boolean maxSet = false; Slice min = null; Slice max = null; while (true) { Page page = reader.nextPage(); if (page == null) { break; } Block block = page.getBlock(0).getLoadedBlock(); for (int i = 0; i < page.getPositionCount(); i++) { if (block.isNull(i)) { continue; } Slice slice = type.getSlice(block, i); slice = truncateIndexValue(slice); if (!minSet || (slice.compareTo(min) < 0)) { minSet = true; min = slice; } if (!maxSet || (slice.compareTo(max) > 0)) { maxSet = true; max = slice; } } } return new ColumnStats(columnId, minSet ? min.toStringUtf8() : null, maxSet ? max.toStringUtf8() : null); }
Example 3
Source File: StringStatistics.java From presto with Apache License 2.0 | 5 votes |
public StringStatistics(@Nullable Slice minimum, @Nullable Slice maximum, long sum) { if (minimum != null && maximum != null && minimum.compareTo(maximum) > 0) { throw new IllegalArgumentException(format( "minimum is not less than or equal to maximum: '%s' [%s], '%s' [%s]", minimum.toStringUtf8(), base16().encode(minimum.getBytes()), maximum.toStringUtf8(), base16().encode(maximum.getBytes()))); } this.minimum = minimum; this.maximum = maximum; this.sum = sum; }
Example 4
Source File: VarcharOperators.java From presto with Apache License 2.0 | 5 votes |
@LiteralParameters("x") @ScalarOperator(GREATER_THAN_OR_EQUAL) @SqlType(StandardTypes.BOOLEAN) public static boolean greaterThanOrEqual(@SqlType("varchar(x)") Slice left, @SqlType("varchar(x)") Slice right) { return left.compareTo(right) >= 0; }
Example 5
Source File: VarcharOperators.java From presto with Apache License 2.0 | 5 votes |
@LiteralParameters("x") @ScalarOperator(GREATER_THAN) @SqlType(StandardTypes.BOOLEAN) public static boolean greaterThan(@SqlType("varchar(x)") Slice left, @SqlType("varchar(x)") Slice right) { return left.compareTo(right) > 0; }
Example 6
Source File: VarcharOperators.java From presto with Apache License 2.0 | 5 votes |
@LiteralParameters("x") @ScalarOperator(LESS_THAN_OR_EQUAL) @SqlType(StandardTypes.BOOLEAN) public static boolean lessThanOrEqual(@SqlType("varchar(x)") Slice left, @SqlType("varchar(x)") Slice right) { return left.compareTo(right) <= 0; }
Example 7
Source File: VarcharOperators.java From presto with Apache License 2.0 | 5 votes |
@LiteralParameters("x") @ScalarOperator(LESS_THAN) @SqlType(StandardTypes.BOOLEAN) public static boolean lessThan(@SqlType("varchar(x)") Slice left, @SqlType("varchar(x)") Slice right) { return left.compareTo(right) < 0; }
Example 8
Source File: StringFunctions.java From presto with Apache License 2.0 | 5 votes |
@Description("Determine whether source starts with prefix or not") @ScalarFunction @LiteralParameters({"x", "y"}) @SqlType(StandardTypes.BOOLEAN) public static boolean startsWith(@SqlType("varchar(x)") Slice source, @SqlType("varchar(y)") Slice prefix) { if (source.length() < prefix.length()) { return false; } return source.compareTo(0, prefix.length(), prefix, 0, prefix.length()) == 0; }
Example 9
Source File: IpAddressOperators.java From presto with Apache License 2.0 | 4 votes |
@ScalarOperator(GREATER_THAN_OR_EQUAL) @SqlType(StandardTypes.BOOLEAN) public static boolean greaterThanOrEqual(@SqlType(StandardTypes.IPADDRESS) Slice left, @SqlType(StandardTypes.IPADDRESS) Slice right) { return left.compareTo(right) >= 0; }
Example 10
Source File: IpAddressOperators.java From presto with Apache License 2.0 | 4 votes |
@ScalarOperator(GREATER_THAN) @SqlType(StandardTypes.BOOLEAN) public static boolean greaterThan(@SqlType(StandardTypes.IPADDRESS) Slice left, @SqlType(StandardTypes.IPADDRESS) Slice right) { return left.compareTo(right) > 0; }
Example 11
Source File: IpAddressOperators.java From presto with Apache License 2.0 | 4 votes |
@ScalarOperator(LESS_THAN_OR_EQUAL) @SqlType(StandardTypes.BOOLEAN) public static boolean lessThanOrEqual(@SqlType(StandardTypes.IPADDRESS) Slice left, @SqlType(StandardTypes.IPADDRESS) Slice right) { return left.compareTo(right) <= 0; }
Example 12
Source File: IpAddressOperators.java From presto with Apache License 2.0 | 4 votes |
@ScalarOperator(LESS_THAN) @SqlType(StandardTypes.BOOLEAN) public static boolean lessThan(@SqlType(StandardTypes.IPADDRESS) Slice left, @SqlType(StandardTypes.IPADDRESS) Slice right) { return left.compareTo(right) < 0; }
Example 13
Source File: VarbinaryOperators.java From presto with Apache License 2.0 | 4 votes |
@ScalarOperator(LESS_THAN) @SqlType(StandardTypes.BOOLEAN) public static boolean lessThan(@SqlType(StandardTypes.VARBINARY) Slice left, @SqlType(StandardTypes.VARBINARY) Slice right) { return left.compareTo(right) < 0; }
Example 14
Source File: VarbinaryOperators.java From presto with Apache License 2.0 | 4 votes |
@ScalarOperator(LESS_THAN_OR_EQUAL) @SqlType(StandardTypes.BOOLEAN) public static boolean lessThanOrEqual(@SqlType(StandardTypes.VARBINARY) Slice left, @SqlType(StandardTypes.VARBINARY) Slice right) { return left.compareTo(right) <= 0; }
Example 15
Source File: VarbinaryOperators.java From presto with Apache License 2.0 | 4 votes |
@ScalarOperator(GREATER_THAN) @SqlType(StandardTypes.BOOLEAN) public static boolean greaterThan(@SqlType(StandardTypes.VARBINARY) Slice left, @SqlType(StandardTypes.VARBINARY) Slice right) { return left.compareTo(right) > 0; }
Example 16
Source File: VarbinaryOperators.java From presto with Apache License 2.0 | 4 votes |
@ScalarOperator(GREATER_THAN_OR_EQUAL) @SqlType(StandardTypes.BOOLEAN) public static boolean greaterThanOrEqual(@SqlType(StandardTypes.VARBINARY) Slice left, @SqlType(StandardTypes.VARBINARY) Slice right) { return left.compareTo(right) >= 0; }
Example 17
Source File: UuidOperators.java From presto with Apache License 2.0 | 4 votes |
@ScalarOperator(LESS_THAN) @SqlType(StandardTypes.BOOLEAN) public static boolean lessThan(@SqlType(StandardTypes.UUID) Slice left, @SqlType(StandardTypes.UUID) Slice right) { return left.compareTo(right) < 0; }
Example 18
Source File: UuidOperators.java From presto with Apache License 2.0 | 4 votes |
@ScalarOperator(LESS_THAN_OR_EQUAL) @SqlType(StandardTypes.BOOLEAN) public static boolean lessThanOrEqual(@SqlType(StandardTypes.UUID) Slice left, @SqlType(StandardTypes.UUID) Slice right) { return left.compareTo(right) <= 0; }
Example 19
Source File: UuidOperators.java From presto with Apache License 2.0 | 4 votes |
@ScalarOperator(GREATER_THAN) @SqlType(StandardTypes.BOOLEAN) public static boolean greaterThan(@SqlType(StandardTypes.UUID) Slice left, @SqlType(StandardTypes.UUID) Slice right) { return left.compareTo(right) > 0; }
Example 20
Source File: UuidOperators.java From presto with Apache License 2.0 | 4 votes |
@ScalarOperator(GREATER_THAN_OR_EQUAL) @SqlType(StandardTypes.BOOLEAN) public static boolean greaterThanOrEqual(@SqlType(StandardTypes.UUID) Slice left, @SqlType(StandardTypes.UUID) Slice right) { return left.compareTo(right) >= 0; }