ivandika3 commented on code in PR #9886:
URL: https://github.com/apache/ozone/pull/9886#discussion_r2936636312


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java:
##########
@@ -1520,7 +1529,24 @@ public List<ExpiredMultipartUploadsBucket> 
getExpiredMultipartUploads(
           expiredMPUs.get(mapKey)
               .addMultipartUploads(builder.setName(dbMultipartInfoKey)
                   .build());
-          numParts += omMultipartKeyInfo.getPartKeyInfoMap().size();
+          if (omMultipartKeyInfo.getSchemaVersion() == 0) {
+            numParts += omMultipartKeyInfo.getPartKeyInfoMap().size();
+          } else {
+            OmMultipartPartKey prefix =
+                
OmMultipartPartKey.prefix(expiredMultipartUpload.getUploadId());
+            try (TableIterator<OmMultipartPartKey, ? extends 
KeyValue<OmMultipartPartKey, OmMultipartPartInfo>>
+                     partIterator = getMultipartPartTable().iterator(prefix)) {
+              while (partIterator.hasNext()) {
+                KeyValue<OmMultipartPartKey, OmMultipartPartInfo> partEntry =
+                    partIterator.next();
+                if (!expiredMultipartUpload.getUploadId().equals(
+                    partEntry.getKey().getUploadId())) {
+                  break;
+                }
+                numParts++;
+              }
+            }
+          }

Review Comment:
   Since this is not tested yet, let's exclude this first and use this once the 
MPU flow patches are done.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java:
##########
@@ -160,6 +162,7 @@ public class OmMetadataManagerImpl implements 
OMMetadataManager,
 
   private Table<String, OmKeyInfo> openKeyTable;
   private Table<String, OmMultipartKeyInfo> multipartInfoTable;
+  private Table<OmMultipartPartKey, OmMultipartPartInfo> multipartPartTable;

Review Comment:
   Nit: Standardize to multipartPart**s**Table



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/codec/OMDBDefinition.java:
##########
@@ -228,6 +231,13 @@ public final class OMDBDefinition extends 
DBDefinition.WithMap {
           StringCodec.get(),
           OmMultipartKeyInfo.getCodec());
 
+  public static final String MULTIPART_PARTS_TABLE = "multipartPartsTable";
+  /** multipartPartsTable: /uploadId/partNumber :- PartKeyInfo. */

Review Comment:
   Can remove the `/`, `/uploadId/partNumber` -> `uploadId/partNumber`



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmMultipartPartKey.java:
##########
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.helpers;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.Objects;
+import org.apache.hadoop.hdds.utils.db.Codec;
+
+/**
+ * Typed key for multipart parts table.
+ * Key encoding:
+ * <pre>
+ *   uploadId(utf8) + '/' + partNumber(int32, big-endian)
+ * </pre>
+ * Prefix encoding for iteration:
+ * <pre>
+ *   uploadId(utf8) + '/'
+ * </pre>
+ */
+public final class OmMultipartPartKey {
+  private static final byte SEPARATOR = (byte) '/';
+  private static final Codec<OmMultipartPartKey> CODEC =
+      new OmMultipartPartKeyCodec();
+
+  private final String uploadId;
+  private final Integer partNumber;
+
+  private OmMultipartPartKey(String uploadId, Integer partNumber) {
+    this.uploadId = Objects.requireNonNull(uploadId, "uploadId is null");
+    this.partNumber = partNumber;
+  }
+
+  public static OmMultipartPartKey of(String uploadId, int partNumber) {
+    return new OmMultipartPartKey(uploadId, partNumber);
+  }

Review Comment:
   Should we also use the boxed `Integer` instead? If we pass `null` `Integer` 
here, it might throw NPE. We should also always use this static constructor and 
not normal constructor (in `fromPersistedFormat`)



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmMultipartPartKey.java:
##########
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.helpers;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.Objects;
+import org.apache.hadoop.hdds.utils.db.Codec;
+
+/**
+ * Typed key for multipart parts table.
+ * Key encoding:
+ * <pre>
+ *   uploadId(utf8) + '/' + partNumber(int32, big-endian)
+ * </pre>
+ * Prefix encoding for iteration:
+ * <pre>
+ *   uploadId(utf8) + '/'
+ * </pre>
+ */
+public final class OmMultipartPartKey {
+  private static final byte SEPARATOR = (byte) '/';
+  private static final Codec<OmMultipartPartKey> CODEC =
+      new OmMultipartPartKeyCodec();
+
+  private final String uploadId;
+  private final Integer partNumber;
+
+  private OmMultipartPartKey(String uploadId, Integer partNumber) {
+    this.uploadId = Objects.requireNonNull(uploadId, "uploadId is null");
+    this.partNumber = partNumber;
+  }
+
+  public static OmMultipartPartKey of(String uploadId, int partNumber) {
+    return new OmMultipartPartKey(uploadId, partNumber);
+  }
+
+  public static OmMultipartPartKey prefix(String uploadId) {
+    return new OmMultipartPartKey(uploadId, null);
+  }
+
+  public static Codec<OmMultipartPartKey> getCodec() {
+    return CODEC;
+  }
+
+  public String getUploadId() {
+    return uploadId;
+  }
+
+  public Integer getPartNumber() {
+    return partNumber;
+  }
+
+  public boolean hasPartNumber() {
+    return partNumber != null;
+  }
+
+  @Override
+  public String toString() {
+    return hasPartNumber() ? uploadId + "/" + partNumber : uploadId;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (!(o instanceof OmMultipartPartKey)) {
+      return false;
+    }
+    OmMultipartPartKey that = (OmMultipartPartKey) o;
+    return Objects.equals(uploadId, that.uploadId)
+        && Objects.equals(partNumber, that.partNumber);
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(uploadId, partNumber);
+  }
+
+  private static final class OmMultipartPartKeyCodec
+      implements Codec<OmMultipartPartKey> {

Review Comment:
   We can support `CodecBuffer` to prevent buffer copying, should be able to be 
addressed here, but can raise in another ticket (under HDDS-2274) if you prefer.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to