use of com.netflix.metacat.common.dto.GetPartitionsRequestDto in project metacat by Netflix.
the class PartitionServiceImpl method list.
@Override
public List<PartitionDto> list(final QualifiedName name, final String filter, final List<String> partitionNames, final Sort sort, final Pageable pageable, final boolean includeUserDefinitionMetadata, final boolean includeUserDataMetadata, final boolean includePartitionDetails) {
if (Strings.isNullOrEmpty(filter) && (pageable == null || !pageable.isPageable()) && (partitionNames == null || partitionNames.isEmpty()) && config.getQualifiedNamesToThrowErrorWhenNoFilterOnListPartitions().contains(name)) {
throw new IllegalArgumentException(String.format("No filter or limit specified for table %s", name));
}
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final ConnectorPartitionService service = connectorManager.getPartitionService(name.getCatalogName());
final GetPartitionsRequestDto requestDto = new GetPartitionsRequestDto();
requestDto.setFilter(filter);
requestDto.setIncludePartitionDetails(includePartitionDetails);
requestDto.setPartitionNames(partitionNames);
final ConnectorContext connectorContext = converterUtil.toConnectorContext(metacatRequestContext);
final List<PartitionInfo> resultInfo = service.getPartitions(connectorContext, name, converterUtil.toPartitionListRequest(requestDto, pageable, sort));
List<PartitionDto> result = Lists.newArrayList();
if (resultInfo != null && !resultInfo.isEmpty()) {
result = resultInfo.stream().map(converterUtil::toPartitionDto).collect(Collectors.toList());
final List<QualifiedName> names = Lists.newArrayList();
final List<String> uris = Lists.newArrayList();
result.forEach(partitionDto -> {
names.add(partitionDto.getName());
uris.add(partitionDto.getDataUri());
});
registry.gauge(this.partitionGetCountId.withTags(new HashMap<>(name.parts())), result.size());
log.info("Got {} partitions for {} using filter: {} and partition names: {}", result.size(), name, filter, partitionNames);
if (includeUserDefinitionMetadata || includeUserDataMetadata) {
final List<ListenableFuture<Map<String, ObjectNode>>> futures = Lists.newArrayList();
futures.add(threadServiceManager.getExecutor().submit(() -> includeUserDefinitionMetadata ? userMetadataService.getDefinitionMetadataMap(names) : Maps.newHashMap()));
futures.add(threadServiceManager.getExecutor().submit(() -> includeUserDataMetadata ? userMetadataService.getDataMetadataMap(uris) : Maps.newHashMap()));
try {
final List<Map<String, ObjectNode>> metadataResults = Futures.successfulAsList(futures).get(1, TimeUnit.HOURS);
final Map<String, ObjectNode> definitionMetadataMap = metadataResults.get(0);
final Map<String, ObjectNode> dataMetadataMap = metadataResults.get(1);
result.forEach(partitionDto -> userMetadataService.populateMetadata(partitionDto, definitionMetadataMap.get(partitionDto.getName().toString()), dataMetadataMap.get(partitionDto.getDataUri())));
} catch (Exception e) {
Throwables.propagate(e);
}
}
}
return result;
}
use of com.netflix.metacat.common.dto.GetPartitionsRequestDto in project metacat by Netflix.
the class CatalogThriftHiveMetastore method getPartitionDtoByName.
private PartitionDto getPartitionDtoByName(final TableDto tableDto, final String partName) throws TException {
final GetPartitionsRequestDto dto = new GetPartitionsRequestDto();
dto.setIncludePartitionDetails(true);
dto.setPartitionNames(ImmutableList.of(partName));
final List<PartitionDto> partitionDtos = partV1.getPartitionsForRequest(catalogName, tableDto.getName().getDatabaseName(), tableDto.getName().getTableName(), null, null, null, null, false, dto);
if (partitionDtos == null || partitionDtos.isEmpty()) {
throw new NoSuchObjectException("Partition (" + partName + ") not found on " + tableDto.getName());
} else if (partitionDtos.size() != 1) {
// I don't think this is even possible
throw new NoSuchObjectException("Partition (" + partName + ") matched extra on " + tableDto.getName());
}
return partitionDtos.get(0);
}
Aggregations