Java Code Examples for org.apache.kudu.client.KuduPredicate#newInListPredicate()

The following examples show how to use org.apache.kudu.client.KuduPredicate#newInListPredicate() . 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: KuduFilterInfo.java    From flink-learning with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: KuduFilterInfo.java    From flink-learning with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: KuduFilterInfo.java    From bahir-flink with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: KuduOutput.java    From envelope with Apache License 2.0 5 votes vote down vote up
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 = filter.getAs(fieldName);
      columnValues.add(columnValue);
    }

    KuduPredicate predicate = KuduPredicate.newInListPredicate(columnSchema, columnValues);

    builder = builder.addPredicate(predicate);
  }

  KuduScanner scanner = builder.build();

  return scanner;
}
 
Example 5
Source File: KuduClientSession.java    From presto with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example 6
Source File: NativeKuduClientSession.java    From presto-kudu with Apache License 2.0 4 votes vote down vote up
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);
}