use of org.apache.kudu.client.AsyncKuduScanner.AsyncKuduScannerBuilder in project geowave by locationtech.
the class KuduRangeRead method results.
public CloseableIterator<T> results() {
final List<AsyncKuduScanner> scanners = new ArrayList<>();
final KuduPredicate adapterIdPred = KuduPredicate.newInListPredicate(schema.getColumn(KuduField.GW_ADAPTER_ID_KEY.getFieldName()), Arrays.asList(ArrayUtils.toObject(adapterIds)));
if ((ranges != null) && !ranges.isEmpty()) {
for (final SinglePartitionQueryRanges r : ranges) {
byte[] partitionKey = r.getPartitionKey();
if (partitionKey == null) {
partitionKey = new byte[0];
}
final KuduPredicate partitionPred = KuduPredicate.newComparisonPredicate(schema.getColumn(KuduField.GW_PARTITION_ID_KEY.getFieldName()), ComparisonOp.EQUAL, partitionKey);
for (final ByteArrayRange range : r.getSortKeyRanges()) {
final byte[] start = range.getStart() != null ? range.getStart() : new byte[0];
final byte[] end = range.getEnd() != null ? range.getEndAsNextPrefix() : new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
final KuduPredicate lowerPred = KuduPredicate.newComparisonPredicate(schema.getColumn(KuduField.GW_SORT_KEY.getFieldName()), ComparisonOp.GREATER_EQUAL, start);
final KuduPredicate upperPred = KuduPredicate.newComparisonPredicate(schema.getColumn(KuduField.GW_SORT_KEY.getFieldName()), ComparisonOp.LESS, end);
final AsyncKuduScannerBuilder scannerBuilder = operations.getAsyncScannerBuilder(table);
final AsyncKuduScanner scanner = scannerBuilder.addPredicate(adapterIdPred).addPredicate(partitionPred).addPredicate(lowerPred).addPredicate(upperPred).build();
scanners.add(scanner);
}
}
} else {
final AsyncKuduScannerBuilder scannerBuilder = operations.getAsyncScannerBuilder(table);
final AsyncKuduScanner scanner = scannerBuilder.addPredicate(adapterIdPred).build();
scanners.add(scanner);
}
return executeQueryAsync(scanners);
}
Aggregations