You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/05/16 10:29:05 UTC

[GitHub] [iotdb] cigarl opened a new pull request, #5921: [IOTDB-3200] [PartitionInfo] replace bytebuffer with stream

cigarl opened a new pull request, #5921:
URL: https://github.com/apache/iotdb/pull/5921

   This PR has:
   - [x] Replace bytebuffer with stream in `PartitionInfo`.
   - [x] Fixed incorrect serialization of multiple sub-maps in `dataPartitionMap`
   - [x] Resolve snapshot temporary file deletion failure.
   


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] qiaojialin merged pull request #5921: [IOTDB-3200] [PartitionInfo] replace bytebuffer with stream

Posted by GitBox <gi...@apache.org>.
qiaojialin merged PR #5921:
URL: https://github.com/apache/iotdb/pull/5921


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] cigarl commented on a diff in pull request #5921: [IOTDB-3200] [PartitionInfo] replace bytebuffer with stream

Posted by GitBox <gi...@apache.org>.
cigarl commented on code in PR #5921:
URL: https://github.com/apache/iotdb/pull/5921#discussion_r874316734


##########
node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartition.java:
##########
@@ -248,75 +245,76 @@ public void createDataPartition(
         .put(timePartitionSlot, Collections.singletonList(regionReplicaSet));
   }
 
-  public void serialize(ByteBuffer buffer) throws IOException, TException {
-    try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
-      for (Entry<
-              String, Map<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TRegionReplicaSet>>>>
-          entry : dataPartitionMap.entrySet()) {
-        ReadWriteIOUtils.write(entry.getKey(), byteArrayOutputStream);
-        try (TIOStreamTransport tioStreamTransport =
-            new TIOStreamTransport(byteArrayOutputStream)) {
-          TProtocol protocol = new TBinaryProtocol(tioStreamTransport);
-          for (Entry<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TRegionReplicaSet>>>
-              seriesPartitionSlotMapEntry : entry.getValue().entrySet()) {
-            seriesPartitionSlotMapEntry.getKey().write(protocol);
-            for (Entry<TTimePartitionSlot, List<TRegionReplicaSet>> timePartitionSlotListEntry :
-                seriesPartitionSlotMapEntry.getValue().entrySet()) {
-              timePartitionSlotListEntry.getKey().write(protocol);
-              ReadWriteIOUtils.write(
-                  timePartitionSlotListEntry.getValue().size(), byteArrayOutputStream);
-              timePartitionSlotListEntry
-                  .getValue()
-                  .forEach(
-                      x -> {
-                        try {
-                          x.write(protocol);
-                        } catch (TException e) {
-                          throw new RuntimeException(e);
-                        }
-                      });
-            }
-          }
+  public void serialize(DataOutputStream dataOutputStream, TProtocol protocol)
+      throws IOException, TException {
+    // Map<StorageGroup, Map<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TRegionMessage>>>>
+    dataOutputStream.writeInt(dataPartitionMap.size());
+    for (Entry<String, Map<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TRegionReplicaSet>>>>
+        entry : dataPartitionMap.entrySet()) {
+      ReadWriteIOUtils.write(entry.getKey(), dataOutputStream);
+      ReadWriteIOUtils.write(entry.getValue().size(), dataOutputStream);
+      for (Entry<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TRegionReplicaSet>>>
+          seriesPartitionSlotMapEntry : entry.getValue().entrySet()) {
+        seriesPartitionSlotMapEntry.getKey().write(protocol);
+        ReadWriteIOUtils.write(seriesPartitionSlotMapEntry.getValue().size(), dataOutputStream);
+        for (Entry<TTimePartitionSlot, List<TRegionReplicaSet>> timePartitionSlotListEntry :
+            seriesPartitionSlotMapEntry.getValue().entrySet()) {
+          timePartitionSlotListEntry.getKey().write(protocol);
+          ReadWriteIOUtils.write(timePartitionSlotListEntry.getValue().size(), dataOutputStream);
+          timePartitionSlotListEntry
+              .getValue()
+              .forEach(
+                  x -> {
+                    try {
+                      x.write(protocol);
+                    } catch (TException e) {
+                      throw new RuntimeException(e);

Review Comment:
   fixed



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] cigarl commented on pull request #5921: [IOTDB-3200] [PartitionInfo] replace bytebuffer with stream

Posted by GitBox <gi...@apache.org>.
cigarl commented on PR #5921:
URL: https://github.com/apache/iotdb/pull/5921#issuecomment-1128384797

   > Don't forget to clean up redundant snapshot files when takeSnapshot returns false.
   
   Each module that operates on snapshots, such as `partitionInfo` and `clusterSchema`, already deleted temporary files with the finally clause.  There is no need to clean up again in `ConfigRequestExecutor`.


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] CRZbulabula commented on a diff in pull request #5921: [IOTDB-3200] [PartitionInfo] replace bytebuffer with stream

Posted by GitBox <gi...@apache.org>.
CRZbulabula commented on code in PR #5921:
URL: https://github.com/apache/iotdb/pull/5921#discussion_r874291733


##########
node-commons/src/main/java/org/apache/iotdb/commons/partition/DataPartition.java:
##########
@@ -248,75 +245,76 @@ public void createDataPartition(
         .put(timePartitionSlot, Collections.singletonList(regionReplicaSet));
   }
 
-  public void serialize(ByteBuffer buffer) throws IOException, TException {
-    try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
-      for (Entry<
-              String, Map<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TRegionReplicaSet>>>>
-          entry : dataPartitionMap.entrySet()) {
-        ReadWriteIOUtils.write(entry.getKey(), byteArrayOutputStream);
-        try (TIOStreamTransport tioStreamTransport =
-            new TIOStreamTransport(byteArrayOutputStream)) {
-          TProtocol protocol = new TBinaryProtocol(tioStreamTransport);
-          for (Entry<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TRegionReplicaSet>>>
-              seriesPartitionSlotMapEntry : entry.getValue().entrySet()) {
-            seriesPartitionSlotMapEntry.getKey().write(protocol);
-            for (Entry<TTimePartitionSlot, List<TRegionReplicaSet>> timePartitionSlotListEntry :
-                seriesPartitionSlotMapEntry.getValue().entrySet()) {
-              timePartitionSlotListEntry.getKey().write(protocol);
-              ReadWriteIOUtils.write(
-                  timePartitionSlotListEntry.getValue().size(), byteArrayOutputStream);
-              timePartitionSlotListEntry
-                  .getValue()
-                  .forEach(
-                      x -> {
-                        try {
-                          x.write(protocol);
-                        } catch (TException e) {
-                          throw new RuntimeException(e);
-                        }
-                      });
-            }
-          }
+  public void serialize(DataOutputStream dataOutputStream, TProtocol protocol)
+      throws IOException, TException {
+    // Map<StorageGroup, Map<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TRegionMessage>>>>
+    dataOutputStream.writeInt(dataPartitionMap.size());
+    for (Entry<String, Map<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TRegionReplicaSet>>>>
+        entry : dataPartitionMap.entrySet()) {
+      ReadWriteIOUtils.write(entry.getKey(), dataOutputStream);
+      ReadWriteIOUtils.write(entry.getValue().size(), dataOutputStream);
+      for (Entry<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TRegionReplicaSet>>>
+          seriesPartitionSlotMapEntry : entry.getValue().entrySet()) {
+        seriesPartitionSlotMapEntry.getKey().write(protocol);
+        ReadWriteIOUtils.write(seriesPartitionSlotMapEntry.getValue().size(), dataOutputStream);
+        for (Entry<TTimePartitionSlot, List<TRegionReplicaSet>> timePartitionSlotListEntry :
+            seriesPartitionSlotMapEntry.getValue().entrySet()) {
+          timePartitionSlotListEntry.getKey().write(protocol);
+          ReadWriteIOUtils.write(timePartitionSlotListEntry.getValue().size(), dataOutputStream);
+          timePartitionSlotListEntry
+              .getValue()
+              .forEach(
+                  x -> {
+                    try {
+                      x.write(protocol);
+                    } catch (TException e) {
+                      throw new RuntimeException(e);

Review Comment:
   You can delete this.



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org