From b9ccc2a1cb26704f248b7578159e648b01720503 Mon Sep 17 00:00:00 2001 From: Harbor Liu <460660596@qq.com> Date: Wed, 13 Nov 2024 19:11:34 +0800 Subject: [PATCH] Added compatible code for PhysicalPartition and LogicalPartition splitting Signed-off-by: Harbor Liu <460660596@qq.com> --- .../java/com/starrocks/catalog/Partition.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/com/starrocks/catalog/Partition.java b/fe/fe-core/src/main/java/com/starrocks/catalog/Partition.java index f7224e4067e6d..76f4825252a9b 100644 --- a/fe/fe-core/src/main/java/com/starrocks/catalog/Partition.java +++ b/fe/fe-core/src/main/java/com/starrocks/catalog/Partition.java @@ -631,7 +631,10 @@ public void setMinRetainVersion(long minRetainVersion) { public String generatePhysicalPartitionName(long physicalPartitionId) { return this.name + '_' + physicalPartitionId; } - + + @SerializedName(value = "dpid") + private long defaultPhysicalPartitionId = 0; + @Override public void gsonPostProcess() throws IOException { if (dataVersion == 0) { @@ -653,5 +656,37 @@ public void gsonPostProcess() throws IOException { } nameToSubPartition.put(subPartition.getName(), subPartition); } + + if (defaultPhysicalPartitionId != 0) { + PhysicalPartitionImpl physicalPartition = idToSubPartition.get(defaultPhysicalPartitionId); + + idToSubPartition.remove(defaultPhysicalPartitionId); + nameToSubPartition.remove(physicalPartition.getName()); + + this.shardGroupId = physicalPartition.getShardGroupId(); + this.isImmutable.set(physicalPartition.isImmutable()); + this.baseIndex = physicalPartition.getBaseIndex(); + + for (MaterializedIndex materializedIndex : physicalPartition.getMaterializedIndices(IndexExtState.VISIBLE)) { + if (materializedIndex.getId() == baseIndex.getId()) { + continue; + } + this.idToShadowIndex.put(materializedIndex.getId(), materializedIndex); + } + + for (MaterializedIndex materializedIndex : physicalPartition.getMaterializedIndices(IndexExtState.SHADOW)) { + this.idToShadowIndex.put(materializedIndex.getId(), materializedIndex); + } + + this.visibleVersion = physicalPartition.getVisibleVersion(); + this.visibleVersionTime = physicalPartition.getVisibleVersionTime(); + this.nextVersion = physicalPartition.getNextVersion(); + this.dataVersion = physicalPartition.getDataVersion(); + this.nextDataVersion = physicalPartition.getNextDataVersion(); + this.versionEpoch = physicalPartition.getVersionEpoch(); + this.versionTxnType = physicalPartition.getVersionTxnType(); + + this.defaultPhysicalPartitionId = 0; + } } }