You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/08/20 07:27:10 UTC

[GitHub] [ozone] umamaheswararao commented on a change in pull request #2455: HDDS-5470 : EC: Add padding and generate parity if the last stripe is not full

umamaheswararao commented on a change in pull request #2455:
URL: https://github.com/apache/ozone/pull/2455#discussion_r692728386



##########
File path: hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/ECKeyOutputStream.java
##########
@@ -473,6 +505,53 @@ public void close() throws IOException {
     ecChunkBufferCache.release();
   }
 
+  private void addPadding() {
+    final long lastStripeSize =
+        currentBlockGroupLen % (numDataBlks * ecChunkSize);
+
+    final long parityCellSize =
+        lastStripeSize < ecChunkSize ? lastStripeSize : ecChunkSize;
+    ByteBuffer[] buffers = ecChunkBufferCache.getDataBuffers();
+
+    for (int i = 0; i < numDataBlks; i++) {
+      // Pad zero bytes to make all cells exactly the size of parityCellSize
+      // If internal block is smaller than parity block, pad zero bytes.
+      // Also pad zero bytes to all parity cells
+      final int position = buffers[i].position();
+      assert position <= parityCellSize : "If an internal block is smaller"
+          + " than parity block, then its last cell should be small than last"
+          + " parity cell";
+      for (int j = 0; j < parityCellSize - position; j++) {
+        buffers[i].put((byte) 0);
+      }
+      buffers[i].flip();
+    }
+
+    buffers = ecChunkBufferCache.getParityBuffers();
+    for (int i = 0; i < (numParityBlks); i++) {
+      // Pad zero bytes to make all cells exactly the size of parityCellSize
+      // If internal block is smaller than parity block, pad zero bytes.
+      // Also pad zero bytes to all parity cells
+      final int position = buffers[i].position();
+      assert position <= parityCellSize : "If an internal block is smaller"
+          + " than parity block, then its last cell should be small than last"
+          + " parity cell";
+      for (int j = 0; j < parityCellSize - position; j++) {

Review comment:
       I agree. Fixed it.




-- 
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: issues-unsubscribe@ozone.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org