Java Code Examples for org.apache.kudu.client.KuduPredicate#newComparisonPredicate()
The following examples show how to use
org.apache.kudu.client.KuduPredicate#newComparisonPredicate() .
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: KuduClientSession.java From presto with Apache License 2.0 | 5 votes |
private KuduPredicate createComparisonPredicate(ColumnSchema columnSchema, KuduPredicate.ComparisonOp op, Object value) { io.prestosql.spi.type.Type type = TypeHelper.fromKuduColumn(columnSchema); Object javaValue = TypeHelper.getJavaValue(type, value); if (javaValue instanceof Long) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (Long) javaValue); } if (javaValue instanceof BigDecimal) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (BigDecimal) javaValue); } if (javaValue instanceof Integer) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (Integer) javaValue); } if (javaValue instanceof Short) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (Short) javaValue); } if (javaValue instanceof Byte) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (Byte) javaValue); } if (javaValue instanceof String) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (String) javaValue); } if (javaValue instanceof Double) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (Double) javaValue); } if (javaValue instanceof Float) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (Float) javaValue); } if (javaValue instanceof Boolean) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (Boolean) javaValue); } if (javaValue instanceof byte[]) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (byte[]) javaValue); } if (javaValue == null) { throw new IllegalStateException("Unexpected null java value for column " + columnSchema.getName()); } throw new IllegalStateException("Unexpected java value for column " + columnSchema.getName() + ": " + javaValue + "(" + javaValue.getClass() + ")"); }
Example 2
Source File: NativeKuduClientSession.java From presto-kudu with Apache License 2.0 | 5 votes |
private KuduPredicate createComparisonPredicate(ColumnSchema columnSchema, KuduPredicate.ComparisonOp op, Object value) { com.facebook.presto.spi.type.Type type = TypeHelper.fromKuduColumn(columnSchema); Object javaValue = TypeHelper.getJavaValue(type, value); if (javaValue instanceof Long) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (Long) javaValue); } else if (javaValue instanceof Integer) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (Integer) javaValue); } else if (javaValue instanceof Short) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (Short) javaValue); } else if (javaValue instanceof Byte) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (Byte) javaValue); } else if (javaValue instanceof String) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (String) javaValue); } else if (javaValue instanceof Double) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (Double) javaValue); } else if (javaValue instanceof Float) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (Float) javaValue); } else if (javaValue instanceof Boolean) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (Boolean) javaValue); } else if (javaValue instanceof byte[]) { return KuduPredicate.newComparisonPredicate(columnSchema, op, (byte[]) javaValue); } else if (javaValue == null) { throw new IllegalStateException("Unexpected null java value for column " + columnSchema.getName()); } else { throw new IllegalStateException("Unexpected java value for column " + columnSchema.getName() + ": " + javaValue + "(" + javaValue.getClass() + ")"); } }
Example 3
Source File: KuduFilterInfo.java From flink-learning with Apache License 2.0 | 4 votes |
private KuduPredicate predicateComparator(ColumnSchema column) { KuduPredicate.ComparisonOp comparison = this.type.comparator; KuduPredicate predicate; switch (column.getType()) { case STRING: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (String)this.value); break; case FLOAT: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (Float)this.value); break; case INT8: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (Byte)this.value); break; case INT16: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (Short)this.value); break; case INT32: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (Integer)this.value); break; case INT64: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (Long)this.value); break; case DOUBLE: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (Double)this.value); break; case BOOL: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (Boolean)this.value); break; case UNIXTIME_MICROS: Long time = (Long)this.value; predicate = KuduPredicate.newComparisonPredicate(column, comparison, time*1000); break; case BINARY: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (byte[])this.value); break; default: throw new IllegalArgumentException("Illegal var type: " + column.getType()); } return predicate; }
Example 4
Source File: KuduFilterInfo.java From flink-learning with Apache License 2.0 | 4 votes |
private KuduPredicate predicateComparator(ColumnSchema column) { KuduPredicate.ComparisonOp comparison = this.type.comparator; KuduPredicate predicate; switch (column.getType()) { case STRING: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (String)this.value); break; case FLOAT: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (Float)this.value); break; case INT8: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (Byte)this.value); break; case INT16: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (Short)this.value); break; case INT32: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (Integer)this.value); break; case INT64: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (Long)this.value); break; case DOUBLE: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (Double)this.value); break; case BOOL: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (Boolean)this.value); break; case UNIXTIME_MICROS: Long time = (Long)this.value; predicate = KuduPredicate.newComparisonPredicate(column, comparison, time*1000); break; case BINARY: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (byte[])this.value); break; default: throw new IllegalArgumentException("Illegal var type: " + column.getType()); } return predicate; }
Example 5
Source File: KuduFilterInfo.java From bahir-flink with Apache License 2.0 | 4 votes |
private KuduPredicate predicateComparator(ColumnSchema column) { KuduPredicate.ComparisonOp comparison = this.type.comparator; KuduPredicate predicate; switch (column.getType()) { case STRING: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (String) this.value); break; case FLOAT: predicate = KuduPredicate.newComparisonPredicate(column, comparison, this.value); break; case INT8: predicate = KuduPredicate.newComparisonPredicate(column, comparison, this.value); break; case INT16: predicate = KuduPredicate.newComparisonPredicate(column, comparison, this.value); break; case INT32: predicate = KuduPredicate.newComparisonPredicate(column, comparison, this.value); break; case INT64: predicate = KuduPredicate.newComparisonPredicate(column, comparison, this.value); break; case DOUBLE: predicate = KuduPredicate.newComparisonPredicate(column, comparison, this.value); break; case BOOL: predicate = KuduPredicate.newComparisonPredicate(column, comparison, this.value); break; case UNIXTIME_MICROS: Long time = (Long) this.value; predicate = KuduPredicate.newComparisonPredicate(column, comparison, time * 1000); break; case BINARY: predicate = KuduPredicate.newComparisonPredicate(column, comparison, (byte[]) this.value); break; default: throw new IllegalArgumentException("Illegal var type: " + column.getType()); } return predicate; }
Example 6
Source File: KuduSQLParseTreeListener.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
private KuduPredicate buildKuduPredicate(String columnName,KuduPredicate.ComparisonOp comparisonOp, KuduSQLExpressionParser.AnyvalueContext anyvalueContext) { ColumnSchema thisColumnSchema = columnSchemaLookups.get(columnName); if (anyvalueContext.bool() != null) { if (thisColumnSchema.getType().getDataType().getNumber() != (Common.DataType.BOOL_VALUE)) { LOG.error(" Mismatched data type for column " + columnName); isSuccessfullyParsed = false; return null; } return KuduPredicate.newComparisonPredicate(thisColumnSchema,comparisonOp, Boolean.valueOf(anyvalueContext.bool().getText().toLowerCase())); } if (anyvalueContext.doubleval() != null) { if (thisColumnSchema.getType().getDataType().getNumber() != (Common.DataType.DOUBLE_VALUE)) { LOG.error(" Mismatched data type for column (Ensure doubles are appended with letter d)" + columnName); isSuccessfullyParsed = false; return null; } return KuduPredicate.newComparisonPredicate(thisColumnSchema,comparisonOp, Double.valueOf(anyvalueContext.doubleval().getText())); } if (anyvalueContext.floatval() != null) { if (thisColumnSchema.getType().getDataType().getNumber() != (Common.DataType.FLOAT_VALUE)) { LOG.error(" Mismatched data type for column (Ensure doubles are appended with letter f)" + columnName); isSuccessfullyParsed = false; return null; } return KuduPredicate.newComparisonPredicate(thisColumnSchema,comparisonOp, Float.valueOf(anyvalueContext.floatval().getText())); } if (anyvalueContext.stringval() != null) { if ( (thisColumnSchema.getType().getDataType().getNumber() != (Common.DataType.STRING_VALUE)) && (thisColumnSchema.getType().getDataType().getNumber() != (Common.DataType.BINARY_VALUE))) { LOG.error(" Mismatched data type for column ( Has to be a string or a binary value enclosed in" + " double quotes" + columnName); isSuccessfullyParsed = false; return null; } if (thisColumnSchema.getType().getDataType().getNumber() == (Common.DataType.STRING_VALUE)) { return KuduPredicate.newComparisonPredicate(thisColumnSchema, comparisonOp, anyvalueContext.stringval().getText()); } if (thisColumnSchema.getType().getDataType().getNumber() == (Common.DataType.BINARY_VALUE)) { return KuduPredicate.newComparisonPredicate(thisColumnSchema, comparisonOp, anyvalueContext.stringval().getText().getBytes()); } } if (anyvalueContext.numval() != null) { int dataTypeNumberForKuduCol = thisColumnSchema.getType().getDataType().getNumber(); if ( (dataTypeNumberForKuduCol != (Common.DataType.UNIXTIME_MICROS_VALUE)) && (dataTypeNumberForKuduCol != (Common.DataType.INT8_VALUE)) && (dataTypeNumberForKuduCol != (Common.DataType.INT16_VALUE)) && (dataTypeNumberForKuduCol != (Common.DataType.INT32_VALUE)) && (dataTypeNumberForKuduCol != (Common.DataType.INT64_VALUE)) && (dataTypeNumberForKuduCol != (Common.DataType.UINT8_VALUE)) && (dataTypeNumberForKuduCol != (Common.DataType.UINT16_VALUE)) && (dataTypeNumberForKuduCol != (Common.DataType.UINT32_VALUE)) && (dataTypeNumberForKuduCol != (Common.DataType.UINT64_VALUE)) ) { LOG.error(" Mismatched data type for column " + columnName); isSuccessfullyParsed = false; return null; } return KuduPredicate.newComparisonPredicate(thisColumnSchema,comparisonOp, Long.valueOf(anyvalueContext.numval().getText())); } return null; }