OneSizeFitsQuorum commented on code in PR #11481:
URL: https://github.com/apache/iotdb/pull/11481#discussion_r1383019246
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/region/CreateRegionGroupsPlan.java:
##########
@@ -39,40 +40,48 @@
import java.util.Objects;
import java.util.stream.Collectors;
-/** Create regions for specific StorageGroups. */
+/** Create regions for specified Databases. */
public class CreateRegionGroupsPlan extends ConfigPhysicalPlan {
- // Map<StorageGroupName, List<TRegionReplicaSet>>
+ // Map<Database, List<TRegionReplicaSet>>
protected final Map<String, List<TRegionReplicaSet>> regionGroupMap;
+ protected final Map<TConsensusGroupId, Long> regionGroupCreateTimeMap;
Review Comment:
Maybe you don't need to maintain a map, just a value? A batch of
RegionGroups can use the same time?
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/region/CreateRegionGroupsPlan.java:
##########
@@ -96,28 +105,46 @@ protected void serializeImpl(DataOutputStream stream)
throws IOException {
stream.writeInt(regionGroupMap.size());
for (Entry<String, List<TRegionReplicaSet>> entry :
regionGroupMap.entrySet()) {
- String storageGroup = entry.getKey();
+ String database = entry.getKey();
List<TRegionReplicaSet> regionReplicaSets = entry.getValue();
- BasicStructureSerDeUtil.write(storageGroup, stream);
+ BasicStructureSerDeUtil.write(database, stream);
stream.writeInt(regionReplicaSets.size());
regionReplicaSets.forEach(
regionReplicaSet ->
ThriftCommonsSerDeUtils.serializeTRegionReplicaSet(regionReplicaSet, stream));
}
+
+ stream.writeInt(regionGroupCreateTimeMap.size());
+ for (Entry<TConsensusGroupId, Long> entry :
regionGroupCreateTimeMap.entrySet()) {
+ TConsensusGroupId regionId = entry.getKey();
+ long createTime = entry.getValue();
+ ThriftCommonsSerDeUtils.serializeTConsensusGroupId(regionId, stream);
+ stream.writeLong(createTime);
+ }
}
@Override
protected void deserializeImpl(ByteBuffer buffer) throws IOException {
- int storageGroupNum = buffer.getInt();
- for (int i = 0; i < storageGroupNum; i++) {
- String storageGroup = BasicStructureSerDeUtil.readString(buffer);
- regionGroupMap.put(storageGroup, new ArrayList<>());
+ int databaseNum = buffer.getInt();
+ for (int i = 0; i < databaseNum; i++) {
+ String database = BasicStructureSerDeUtil.readString(buffer);
+ regionGroupMap.put(database, new ArrayList<>());
int regionReplicaSetNum = buffer.getInt();
for (int j = 0; j < regionReplicaSetNum; j++) {
TRegionReplicaSet regionReplicaSet =
ThriftCommonsSerDeUtils.deserializeTRegionReplicaSet(buffer);
- regionGroupMap.get(storageGroup).add(regionReplicaSet);
+ regionGroupMap.get(database).add(regionReplicaSet);
+ }
+ }
+
+ if (buffer.hasRemaining()) {
Review Comment:
We need to consider setting a default value (maybe the current time) when
restarts with no data.
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/region/CreateRegionGroupsPlan.java:
##########
@@ -39,40 +40,48 @@
import java.util.Objects;
import java.util.stream.Collectors;
-/** Create regions for specific StorageGroups. */
+/** Create regions for specified Databases. */
public class CreateRegionGroupsPlan extends ConfigPhysicalPlan {
- // Map<StorageGroupName, List<TRegionReplicaSet>>
+ // Map<Database, List<TRegionReplicaSet>>
protected final Map<String, List<TRegionReplicaSet>> regionGroupMap;
+ protected final Map<TConsensusGroupId, Long> regionGroupCreateTimeMap;
Review Comment:
Maybe you don't need to maintain a map, just a value? A batch of
RegionGroups can use the same time?
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/region/CreateRegionGroupsPlan.java:
##########
@@ -39,40 +40,48 @@
import java.util.Objects;
import java.util.stream.Collectors;
-/** Create regions for specific StorageGroups. */
+/** Create regions for specified Databases. */
public class CreateRegionGroupsPlan extends ConfigPhysicalPlan {
- // Map<StorageGroupName, List<TRegionReplicaSet>>
+ // Map<Database, List<TRegionReplicaSet>>
protected final Map<String, List<TRegionReplicaSet>> regionGroupMap;
+ protected final Map<TConsensusGroupId, Long> regionGroupCreateTimeMap;
Review Comment:
Maybe you don't need to maintain a map, just a value? A batch of
RegionGroups can use the same time?
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/region/CreateRegionGroupsPlan.java:
##########
@@ -39,40 +40,48 @@
import java.util.Objects;
import java.util.stream.Collectors;
-/** Create regions for specific StorageGroups. */
+/** Create regions for specified Databases. */
public class CreateRegionGroupsPlan extends ConfigPhysicalPlan {
- // Map<StorageGroupName, List<TRegionReplicaSet>>
+ // Map<Database, List<TRegionReplicaSet>>
protected final Map<String, List<TRegionReplicaSet>> regionGroupMap;
+ protected final Map<TConsensusGroupId, Long> regionGroupCreateTimeMap;
Review Comment:
Maybe you don't need to maintain a map, just a value? A batch of
RegionGroups can use the same time?
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/region/CreateRegionGroupsPlan.java:
##########
@@ -39,40 +40,48 @@
import java.util.Objects;
import java.util.stream.Collectors;
-/** Create regions for specific StorageGroups. */
+/** Create regions for specified Databases. */
public class CreateRegionGroupsPlan extends ConfigPhysicalPlan {
- // Map<StorageGroupName, List<TRegionReplicaSet>>
+ // Map<Database, List<TRegionReplicaSet>>
protected final Map<String, List<TRegionReplicaSet>> regionGroupMap;
+ protected final Map<TConsensusGroupId, Long> regionGroupCreateTimeMap;
Review Comment:
Maybe you don't need to maintain a map, just a value? A batch of
RegionGroups can use the same time?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]