use of com.amazonaws.services.glue.model.Segment in project presto by prestodb.
the class GlueHiveMetastore method getPartitions.
private List<Partition> getPartitions(String databaseName, String tableName, String expression) {
if (partitionSegments == 1) {
return getPartitions(databaseName, tableName, expression, null);
}
// Do parallel partition fetch.
CompletionService<List<Partition>> completionService = new ExecutorCompletionService<>(executor);
for (int i = 0; i < partitionSegments; i++) {
Segment segment = new Segment().withSegmentNumber(i).withTotalSegments(partitionSegments);
completionService.submit(() -> getPartitions(databaseName, tableName, expression, segment));
}
List<Partition> partitions = new ArrayList<>();
try {
for (int i = 0; i < partitionSegments; i++) {
Future<List<Partition>> futurePartitions = completionService.take();
partitions.addAll(futurePartitions.get());
}
} catch (ExecutionException | InterruptedException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
throw new PrestoException(HIVE_METASTORE_ERROR, "Failed to fetch partitions from Glue Data Catalog", e);
}
partitions.sort(PARTITION_COMPARATOR);
return partitions;
}
Aggregations