@Override
 public synchronized Optional<Partition> getPartition(
     String databaseName, String tableName, List<String> partitionValues) {
   PartitionName name = PartitionName.partition(databaseName, tableName, partitionValues);
   Partition partition = partitions.get(name);
   if (partition == null) {
     return Optional.empty();
   }
   return Optional.of(partition.deepCopy());
 }
 @Override
 public synchronized List<Partition> getPartitionsByNames(
     String databaseName, String tableName, List<String> partitionNames) {
   ImmutableList.Builder<Partition> builder = ImmutableList.builder();
   for (String name : partitionNames) {
     PartitionName partitionName = PartitionName.partition(databaseName, tableName, name);
     Partition partition = partitions.get(partitionName);
     if (partition == null) {
       return ImmutableList.of();
     }
     builder.add(partition.deepCopy());
   }
   return builder.build();
 }
Exemplo n.º 3
0
 @Override
 public void addPartitions(String databaseName, String tableName, List<Partition> partitions) {
   Optional<Table> table = getTable(databaseName, tableName);
   if (!table.isPresent()) {
     throw new TableNotFoundException(new SchemaTableName(databaseName, tableName));
   }
   for (Partition partition : partitions) {
     String partitionName = createPartitionName(partition, table.get());
     partition = partition.deepCopy();
     if (partition.getParameters() == null) {
       partition.setParameters(ImmutableMap.of());
     }
     this.partitions.put(
         PartitionName.partition(databaseName, tableName, partitionName), partition);
   }
 }