Search in sources :

Example 1 with HoodieSavepointPartitionMetadata

use of org.apache.hudi.avro.model.HoodieSavepointPartitionMetadata in project hudi by apache.

the class HoodieTestTable method getSavepointMetadata.

public HoodieSavepointMetadata getSavepointMetadata(String instant, Map<String, List<String>> partitionToFilesMeta) {
    HoodieSavepointMetadata savepointMetadata = new HoodieSavepointMetadata();
    savepointMetadata.setSavepointedAt(Long.valueOf(instant));
    Map<String, HoodieSavepointPartitionMetadata> partitionMetadataMap = new HashMap<>();
    for (Map.Entry<String, List<String>> entry : partitionToFilesMeta.entrySet()) {
        HoodieSavepointPartitionMetadata savepointPartitionMetadata = new HoodieSavepointPartitionMetadata();
        savepointPartitionMetadata.setPartitionPath(entry.getKey());
        savepointPartitionMetadata.setSavepointDataFile(entry.getValue());
        partitionMetadataMap.put(entry.getKey(), savepointPartitionMetadata);
    }
    savepointMetadata.setPartitionMetadata(partitionMetadataMap);
    savepointMetadata.setSavepointedBy("test");
    return savepointMetadata;
}
Also used : HoodieSavepointPartitionMetadata(org.apache.hudi.avro.model.HoodieSavepointPartitionMetadata) HashMap(java.util.HashMap) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) CollectionUtils.createImmutableMap(org.apache.hudi.common.util.CollectionUtils.createImmutableMap) HashMap(java.util.HashMap) HoodieSavepointMetadata(org.apache.hudi.avro.model.HoodieSavepointMetadata)

Example 2 with HoodieSavepointPartitionMetadata

use of org.apache.hudi.avro.model.HoodieSavepointPartitionMetadata in project hudi by apache.

the class TimelineMetadataUtils method convertSavepointMetadata.

public static HoodieSavepointMetadata convertSavepointMetadata(String user, String comment, Map<String, List<String>> latestFiles) {
    Map<String, HoodieSavepointPartitionMetadata> partitionMetadataBuilder = new HashMap<>();
    for (Map.Entry<String, List<String>> stat : latestFiles.entrySet()) {
        HoodieSavepointPartitionMetadata metadata = new HoodieSavepointPartitionMetadata(stat.getKey(), stat.getValue());
        partitionMetadataBuilder.put(stat.getKey(), metadata);
    }
    return new HoodieSavepointMetadata(user, System.currentTimeMillis(), comment, Collections.unmodifiableMap(partitionMetadataBuilder), DEFAULT_VERSION);
}
Also used : HoodieSavepointPartitionMetadata(org.apache.hudi.avro.model.HoodieSavepointPartitionMetadata) HashMap(java.util.HashMap) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) HoodieSavepointMetadata(org.apache.hudi.avro.model.HoodieSavepointMetadata)

Aggregations

HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 HoodieSavepointMetadata (org.apache.hudi.avro.model.HoodieSavepointMetadata)2 HoodieSavepointPartitionMetadata (org.apache.hudi.avro.model.HoodieSavepointPartitionMetadata)2 ArrayList (java.util.ArrayList)1 CollectionUtils.createImmutableMap (org.apache.hudi.common.util.CollectionUtils.createImmutableMap)1