private KuduPredicate createInListPredicate(ColumnSchema columnSchema, DiscreteValues discreteValues) { com.facebook.presto.spi.type.Type type = TypeHelper.fromKuduColumn(columnSchema); List<Object> javaValues = discreteValues.getValues().stream().map(value -> TypeHelper.getJavaValue(type, value)).collect(toImmutableList()); return KuduPredicate.newInListPredicate(columnSchema, javaValues); }
public static KuduPredicate getInPredicate(ColumnSchema column, List<Object> values) { return KuduPredicate.newInListPredicate(column, values); }
private static KuduPredicate boolInList(Boolean... values) { return KuduPredicate.newInListPredicate(boolCol, Arrays.asList(values)); }
private static KuduPredicate intInList(Integer... values) { return KuduPredicate.newInListPredicate(intCol, Arrays.asList(values)); }
private static KuduPredicate stringInList(String... values) { return KuduPredicate.newInListPredicate(stringCol, Arrays.asList(values)); }
private KuduPredicate createInListPredicate(ColumnSchema columnSchema, DiscreteValues discreteValues) { io.prestosql.spi.type.Type type = TypeHelper.fromKuduColumn(columnSchema); List<Object> javaValues = discreteValues.getValues().stream().map(value -> TypeHelper.getJavaValue(type, value)).collect(toImmutableList()); return KuduPredicate.newInListPredicate(columnSchema, javaValues); }
private KuduPredicate createInListPredicate(ColumnSchema columnSchema, DiscreteValues discreteValues) { com.facebook.presto.spi.type.Type type = TypeHelper.fromKuduColumn(columnSchema); List<Object> javaValues = discreteValues.getValues().stream().map(value -> TypeHelper.getJavaValue(type, value)).collect(toImmutableList()); return KuduPredicate.newInListPredicate(columnSchema, javaValues); }
public KuduPredicate toPredicate(ColumnSchema column) { KuduPredicate predicate; switch (this.type) { case IS_IN: predicate = KuduPredicate.newInListPredicate(column, (List) this.value); break; case IS_NULL: predicate = KuduPredicate.newIsNullPredicate(column); break; case IS_NOT_NULL: predicate = KuduPredicate.newIsNotNullPredicate(column); break; default: predicate = predicateComparator(column); break; } return predicate; }
kuduPredicateList.add(KuduPredicate.newInListPredicate(columnSchemaLookups.get(columnName), extractListOfBools(listofboolsContext,columnName))); kuduPredicateList.add(KuduPredicate.newInListPredicate(columnSchemaLookups.get(columnName), extractListOfDoubles(listofdoubles,columnName))); kuduPredicateList.add(KuduPredicate.newInListPredicate(columnSchemaLookups.get(columnName), extractListOfFloats(listoffloatsContext,columnName))); kuduPredicateList.add(KuduPredicate.newInListPredicate(columnSchemaLookups.get(columnName), extractListOfLongs(listofnumsContext,columnName))); if (listofstringsContext != null) { if (columnSchemaLookups.get(columnName).getType().getDataType().getNumber() == Common.DataType.STRING_VALUE) { kuduPredicateList.add(KuduPredicate.newInListPredicate(columnSchemaLookups.get(columnName), extractListOfStrings(listofstringsContext,columnName))); kuduPredicateList.add(KuduPredicate.newInListPredicate(columnSchemaLookups.get(columnName), extractListOfBinary(listofstringsContext,columnName)));
private KuduScanner scannerForFilters(Iterable<Row> filters, KuduTable table) throws KuduException { List<Row> filtersList = Lists.newArrayList(filters); if (filtersList.size() == 0) { throw new RuntimeException("Kudu existing filter was not provided."); } if (filtersList.get(0).schema() == null) { throw new RuntimeException("Kudu existing filter did not contain a schema."); } if (hasAccumulators()) { accumulators.getLongAccumulators().get(ACCUMULATOR_NUMBER_OF_SCANNERS).add(1); accumulators.getLongAccumulators().get(ACCUMULATOR_NUMBER_OF_FILTERS_SCANNED).add(filtersList.size()); } KuduScannerBuilder builder = getConnection().getClient().newScannerBuilder(table); for (String fieldName : filtersList.get(0).schema().fieldNames()) { ColumnSchema columnSchema = table.getSchema().getColumn(fieldName); List<Object> columnValues = Lists.newArrayList(); for (Row filter : filtersList) { Object columnValue = RowUtils.get(filter, fieldName); columnValues.add(columnValue); } KuduPredicate predicate = KuduPredicate.newInListPredicate(columnSchema, columnValues); builder = builder.addPredicate(predicate); } KuduScanner scanner = builder.build(); return scanner; }
KuduPredicate.newInListPredicate(a, ImmutableList.of((byte) 0, (byte) 1))); KuduPredicate.newInListPredicate(a, ImmutableList.of((byte) 0, (byte) 1, (byte) 8))); KuduPredicate.newInListPredicate(b, ImmutableList.of((byte) 0, (byte) 1))); KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) 0, (byte) 1))); KuduPredicate.newInListPredicate(b, ImmutableList.of((byte) 0, (byte) 1)), KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) 0, (byte) 1))); KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) 0, (byte) 1))); KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) 0, (byte) 1))); KuduPredicate.newInListPredicate(a, ImmutableList.of((byte) 0, (byte) 1)), KuduPredicate.newInListPredicate(b, ImmutableList.of((byte) 0, (byte) 1)), KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) 0, (byte) 1)));
KuduPredicate.newInListPredicate(a, ImmutableList.of((byte) 0, (byte) 1))); KuduPredicate.newInListPredicate(a, ImmutableList.of((byte) 0, (byte) 1, (byte) 8))); KuduPredicate.newInListPredicate(b, ImmutableList.of((byte) 0, (byte) 1))); KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) 0, (byte) 1))); KuduPredicate.newInListPredicate(b, ImmutableList.of((byte) 0, (byte) 1)), KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) 0, (byte) 1))); KuduPredicate.newInListPredicate(a, ImmutableList.of((byte) 0, (byte) 1)), KuduPredicate.newInListPredicate(b, ImmutableList.of((byte) 0, (byte) 1)), KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) 0, (byte) 1)));
testMerge(KuduPredicate.newInListPredicate(byteCol, ImmutableList.of((byte) 12, (byte) 14, (byte) 16, (byte) 18)), KuduPredicate.newInListPredicate(byteCol, ImmutableList.of((byte) 14, (byte) 18, (byte) 20)), KuduPredicate.newInListPredicate(byteCol, ImmutableList.of((byte) 14, (byte) 18))); testMerge(KuduPredicate.newInListPredicate(shortCol, ImmutableList.of((short) 12, (short) 14, (short) 16, (short) 18)), KuduPredicate.newInListPredicate(shortCol, ImmutableList.of((short) 14, (short) 18, (short) 20)), KuduPredicate.newInListPredicate(shortCol, ImmutableList.of((short) 14, (short) 18))); testMerge(KuduPredicate.newInListPredicate(longCol, ImmutableList.of(12L, 14L, 16L, 18L)), KuduPredicate.newInListPredicate(longCol, ImmutableList.of(14L, 18L, 20L)), KuduPredicate.newInListPredicate(longCol, ImmutableList.of(14L, 18L))); testMerge(KuduPredicate.newInListPredicate(floatCol, ImmutableList.of(12f, 14f, 16f, 18f)), KuduPredicate.newInListPredicate(floatCol, ImmutableList.of(14f, 18f, 20f)), KuduPredicate.newInListPredicate(floatCol, ImmutableList.of(14f, 18f))); testMerge(KuduPredicate.newInListPredicate(doubleCol, ImmutableList.of(12d, 14d, 16d, 18d)), KuduPredicate.newInListPredicate(doubleCol, ImmutableList.of(14d, 18d, 20d)), KuduPredicate.newInListPredicate(doubleCol, ImmutableList.of(14d, 18d))); testMerge(KuduPredicate.newInListPredicate(decimal32Col, ImmutableList.of( BigDecimal.valueOf(12345, 2), BigDecimal.valueOf(45678, 2))), KuduPredicate.newInListPredicate(decimal32Col, ImmutableList.of( BigDecimal.valueOf(45678, 2), BigDecimal.valueOf(98765, 2))), KuduPredicate.newInListPredicate(decimal32Col, ImmutableList.of( BigDecimal.valueOf(45678, 2))));
KuduPredicate.newIsNullPredicate(intCol).toString()); Assert.assertEquals("`bool` = true", KuduPredicate.newInListPredicate( boolCol, ImmutableList.of(true)).toString()); Assert.assertEquals("`bool` = false", KuduPredicate.newInListPredicate( boolCol, ImmutableList.of(false)).toString()); Assert.assertEquals("`bool` IS NOT NULL", KuduPredicate.newInListPredicate( boolCol, ImmutableList.of(false, true, true)).toString()); Assert.assertEquals("`byte` IN (1, 10, 100)", KuduPredicate.newInListPredicate( byteCol, ImmutableList.of((byte) 1, (byte) 10, (byte) 100)).toString()); Assert.assertEquals("`short` IN (1, 10, 100)", KuduPredicate.newInListPredicate( shortCol, ImmutableList.of((short) 1, (short) 100, (short) 10)).toString()); Assert.assertEquals("`int` IN (1, 10, 100)", KuduPredicate.newInListPredicate( intCol, ImmutableList.of(1, 100, 10)).toString()); Assert.assertEquals("`long` IN (1, 10, 100)", KuduPredicate.newInListPredicate( longCol, ImmutableList.of(1L, 100L, 10L)).toString()); Assert.assertEquals("`float` IN (78.9, 123.456)", KuduPredicate.newInListPredicate( floatCol, ImmutableList.of(123.456f, 78.9f)).toString()); Assert.assertEquals("`double` IN (78.9, 123.456)", KuduPredicate.newInListPredicate( doubleCol, ImmutableList.of(123.456d, 78.9d)).toString()); Assert.assertEquals("`string` IN (\"a\", \"my string\")", KuduPredicate.newInListPredicate(stringCol, ImmutableList.of("my string", "a")).toString()); Assert.assertEquals("`binary` IN (0x00, 0xAB01CD)", KuduPredicate.newInListPredicate( binaryCol, ImmutableList.of(new byte[] { (byte) 0xAB, (byte) 0x01, (byte) 0xCD }, new byte[] { (byte) 0x00 })).toString());
KuduPredicate.newInListPredicate(schema.getColumn("key"), ImmutableList.of("key_30", "key_01", "invalid", "key_99")) ).size()); assertEquals(3, scanTableToStrings(table, KuduPredicate.newInListPredicate(schema.getColumn("c2"), ImmutableList.of("c2_30", "c2_1", "invalid", "c2_99")) ).size()); assertEquals(2, scanTableToStrings(table, KuduPredicate.newInListPredicate(schema.getColumn("c2"), ImmutableList.of("c2_30", "c2_1", "invalid", "c2_99")), KuduPredicate.newIsNotNullPredicate(schema.getColumn("c2")), KuduPredicate.newInListPredicate(schema.getColumn("key"), ImmutableList.of("key_30", "key_45", "invalid", "key_99")) ).size());
KuduPredicate.newInListPredicate(timestamp, ImmutableList.of(0L, 9L)), KuduPredicate.newComparisonPredicate(host, ComparisonOp.EQUAL, "a"), KuduPredicate.newInListPredicate(metric, ImmutableList.of("foo", "baz"))); KuduPredicate.newInListPredicate(timestamp, ImmutableList.of(10L, 100L))); KuduPredicate.newInListPredicate(timestamp, ImmutableList.of(9L, 10L)));
KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) 0, (byte) 10)));
KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) 1, (byte) 2))); KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) 0, (byte) 1, (byte) 2))); KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) -10, (byte) 0)), KuduPredicate.newComparisonPredicate(b, ComparisonOp.LESS, "m")); KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) -10, (byte) 0)), KuduPredicate.newComparisonPredicate(b, ComparisonOp.LESS, "m\0"));