Skip to content

Commit

Permalink
delete idToStoragePolicy from PartitionInfo.java
Browse files Browse the repository at this point in the history
  • Loading branch information
DarvenDuan committed Sep 11, 2024
1 parent 91afeec commit fa41c5b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

public class ListPartitionInfo extends PartitionInfo {
Expand Down Expand Up @@ -264,11 +263,10 @@ public PartitionDesc toPartitionDesc(OlapTable table) throws AnalysisException {
PartitionKeyDesc partitionKeyDesc = PartitionKeyDesc.createIn(inValues);

Map<String, String> properties = Maps.newHashMap();
Optional.ofNullable(this.idToStoragePolicy.get(entry.getKey())).ifPresent(p -> {
if (!p.equals("")) {
properties.put("STORAGE POLICY", p);
}
});
String storagePolicy = getStoragePolicy(entry.getKey());
if (!storagePolicy.isEmpty()) {
properties.put("STORAGE POLICY", storagePolicy);
}

allPartitionDescs.add(new SinglePartitionDesc(false, partitionName, partitionKeyDesc, properties));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ public class PartitionInfo {
// partition id -> data property
@SerializedName("IdToDataProperty")
protected Map<Long, DataProperty> idToDataProperty;
// partition id -> storage policy
protected Map<Long, String> idToStoragePolicy;
// partition id -> replication allocation
@SerializedName("IdToReplicaAllocation")
protected Map<Long, ReplicaAllocation> idToReplicaAllocation;
Expand Down Expand Up @@ -100,7 +98,6 @@ public PartitionInfo() {
this.idToReplicaAllocation = new HashMap<>();
this.idToInMemory = new HashMap<>();
this.idToTabletType = new HashMap<>();
this.idToStoragePolicy = new HashMap<>();
this.partitionExprs = new ArrayList<>();
}

Expand All @@ -110,7 +107,6 @@ public PartitionInfo(PartitionType type) {
this.idToReplicaAllocation = new HashMap<>();
this.idToInMemory = new HashMap<>();
this.idToTabletType = new HashMap<>();
this.idToStoragePolicy = new HashMap<>();
this.partitionExprs = new ArrayList<>();
}

Expand Down Expand Up @@ -209,7 +205,6 @@ public PartitionItem handleNewSinglePartitionDesc(SinglePartitionDesc desc,
idToDataProperty.put(partitionId, desc.getPartitionDataProperty());
idToReplicaAllocation.put(partitionId, desc.getReplicaAlloc());
idToInMemory.put(partitionId, desc.isInMemory());
idToStoragePolicy.put(partitionId, desc.getStoragePolicy());

return partitionItem;
}
Expand All @@ -225,7 +220,6 @@ public void unprotectHandleNewSinglePartitionDesc(long partitionId, boolean isTe
idToDataProperty.put(partitionId, dataProperty);
idToReplicaAllocation.put(partitionId, replicaAlloc);
idToInMemory.put(partitionId, isInMemory);
idToStoragePolicy.put(partitionId, "");
//TODO
//idToMutable.put(partitionId, isMutable);
}
Expand Down Expand Up @@ -299,18 +293,17 @@ public void setDataProperty(long partitionId, DataProperty newDataProperty) {
}

public void refreshTableStoragePolicy(String storagePolicy) {
idToStoragePolicy.replaceAll((k, v) -> storagePolicy);
idToDataProperty.entrySet().forEach(entry -> {
entry.getValue().setStoragePolicy(storagePolicy);
});
}

public String getStoragePolicy(long partitionId) {
return idToStoragePolicy.getOrDefault(partitionId, "");
return idToDataProperty.get(partitionId).getStoragePolicy();
}

public void setStoragePolicy(long partitionId, String storagePolicy) {
idToStoragePolicy.put(partitionId, storagePolicy);
idToDataProperty.get(partitionId).setStoragePolicy(storagePolicy);
}

public Map<Long, ReplicaAllocation> getPartitionReplicaAllocations() {
Expand Down Expand Up @@ -421,12 +414,10 @@ public void resetPartitionIdForRestore(
Map<Long, ReplicaAllocation> origIdToReplicaAllocation = idToReplicaAllocation;
Map<Long, PartitionItem> origIdToItem = idToItem;
Map<Long, Boolean> origIdToInMemory = idToInMemory;
Map<Long, String> origIdToStoragePolicy = idToStoragePolicy;
idToDataProperty = Maps.newHashMap();
idToReplicaAllocation = Maps.newHashMap();
idToItem = Maps.newHashMap();
idToInMemory = Maps.newHashMap();
idToStoragePolicy = Maps.newHashMap();

for (Map.Entry<Long, Long> entry : partitionIdMap.entrySet()) {
idToDataProperty.put(entry.getKey(), origIdToDataProperty.get(entry.getValue()));
Expand All @@ -437,7 +428,6 @@ public void resetPartitionIdForRestore(
idToItem.put(entry.getKey(), origIdToItem.get(entry.getValue()));
}
idToInMemory.put(entry.getKey(), origIdToInMemory.get(entry.getValue()));
idToStoragePolicy.put(entry.getKey(), origIdToStoragePolicy.get(entry.getValue()));
}
}

Expand Down Expand Up @@ -518,15 +508,15 @@ public boolean equals(Object o) {
return isMultiColumnPartition == that.isMultiColumnPartition && type == that.type && Objects.equals(
partitionColumns, that.partitionColumns) && Objects.equals(idToItem, that.idToItem)
&& Objects.equals(idToTempItem, that.idToTempItem) && Objects.equals(idToDataProperty,
that.idToDataProperty) && Objects.equals(idToStoragePolicy, that.idToStoragePolicy)
&& Objects.equals(idToReplicaAllocation, that.idToReplicaAllocation) && Objects.equals(
idToInMemory, that.idToInMemory) && Objects.equals(idToTabletType, that.idToTabletType)
that.idToDataProperty) && Objects.equals(idToReplicaAllocation, that.idToReplicaAllocation)
&& Objects.equals(idToInMemory, that.idToInMemory)
&& Objects.equals(idToTabletType, that.idToTabletType)
&& Objects.equals(partitionExprs, that.partitionExprs);
}

@Override
public int hashCode() {
return Objects.hash(type, partitionColumns, idToItem, idToTempItem, idToDataProperty, idToStoragePolicy,
return Objects.hash(type, partitionColumns, idToItem, idToTempItem, idToDataProperty,
idToReplicaAllocation, isMultiColumnPartition, idToInMemory, idToTabletType, partitionExprs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

public class RangePartitionInfo extends PartitionInfo {
Expand Down Expand Up @@ -330,11 +329,10 @@ public PartitionDesc toPartitionDesc(OlapTable table) throws AnalysisException {
PartitionInfo.toPartitionValue(range.upperEndpoint()));

Map<String, String> properties = Maps.newHashMap();
Optional.ofNullable(this.idToStoragePolicy.get(entry.getKey())).ifPresent(p -> {
if (!p.equals("")) {
properties.put("STORAGE POLICY", p);
}
});
String storagePolicy = getStoragePolicy(entry.getKey());
if (!storagePolicy.isEmpty()) {
properties.put("STORAGE POLICY", storagePolicy);
}

allPartitionDescs.add(new SinglePartitionDesc(false, partitionName, partitionKeyDesc, properties));
}
Expand Down

0 comments on commit fa41c5b

Please sign in to comment.