You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "aswinshakil (via GitHub)" <gi...@apache.org> on 2023/09/18 22:29:17 UTC

[GitHub] [ozone] aswinshakil commented on a diff in pull request #5303: HDDS-7601. Added new columnFamily: compactionLogTable to store compaction entries

aswinshakil commented on code in PR #5303:
URL: https://github.com/apache/ozone/pull/5303#discussion_r1329343286


##########
hadoop-hdds/rocksdb-checkpoint-differ/src/main/java/org/apache/ozone/compaction/log/CompactionFileInfo.java:
##########
@@ -0,0 +1,164 @@
+/*
+ * 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.ozone.compaction.log;
+
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.util.Preconditions;
+
+import java.util.Objects;
+
+/**
+ * Dao to keep SST file information in the compaction log.
+ */
+public final class CompactionFileInfo {
+  private final String fileName;
+  private final String startKey;
+  private final String endKey;
+  private final String columnFamily;
+
+  private CompactionFileInfo(String fileName,
+                             String startRange,
+                             String endRange,
+                             String columnFamily) {
+    this.fileName = fileName;
+    this.startKey = startRange;
+    this.endKey = endRange;
+    this.columnFamily = columnFamily;
+  }
+
+  public String getFileName() {
+    return fileName;
+  }
+
+  public String getStartKey() {
+    return startKey;
+  }
+
+  public String getEndKey() {
+    return endKey;
+  }
+
+  public String getColumnFamily() {
+    return columnFamily;
+  }
+
+  public HddsProtos.CompactionFileInfoProto getProtobuf() {
+    HddsProtos.CompactionFileInfoProto.Builder builder =
+        HddsProtos.CompactionFileInfoProto.newBuilder()
+            .setFileName(fileName);
+    if (startKey != null) {
+      builder = builder.setStartKey(startKey);
+    }
+    if (endKey != null) {
+      builder = builder.setEndKey(endKey);
+    }
+    if (columnFamily != null) {
+      builder = builder.setColumnFamily(columnFamily);
+    }
+    return builder.build();
+  }
+
+  public static CompactionFileInfo getFromProtobuf(
+      HddsProtos.CompactionFileInfoProto proto) {
+    Builder builder = new Builder(proto.getFileName());
+
+    if (proto.hasStartKey()) {
+      builder.setStartRange(proto.getStartKey());
+    }
+    if (proto.hasEndKey()) {
+      builder.setEndRange(proto.getEndKey());
+    }
+    if (proto.hasColumnFamily()) {
+      builder.setColumnFamily(proto.getColumnFamily());
+    }
+
+    return builder.build();
+  }
+
+  @Override
+  public String toString() {
+    return String.format("fileName: '%s', startKey: '%s', endKey: '%s'," +
+        " columnFamily: '%s'", fileName, startKey, endKey, columnFamily);
+  }
+
+  /**
+   * Builder of CompactionFileInfo.
+   */
+  public static class Builder {
+    private final String fileName;
+    private String startRange;
+    private String endRange;
+    private String columnFamily;
+
+    public Builder(String fileName) {
+      Preconditions.checkNotNull(fileName, "FileName is required parameter.");
+      this.fileName = fileName;
+    }
+
+    public Builder setStartRange(String startRange) {
+      this.startRange = startRange;
+      return this;
+    }
+
+    public Builder setEndRange(String endRange) {
+      this.endRange = endRange;
+      return this;
+    }
+
+    public Builder setColumnFamily(String columnFamily) {
+      this.columnFamily = columnFamily;
+      return this;
+    }
+
+    public CompactionFileInfo build() {
+      if ((startRange != null || endRange != null || columnFamily != null) &&

Review Comment:
   Sorry, I'm confused about this condition. Either all three should be set or none of them should be set? Is that right? 



##########
hadoop-hdds/interface-client/src/main/proto/hdds.proto:
##########
@@ -479,4 +479,19 @@ message DeletedBlocksTransactionInfo {
     optional int64 containerID = 2;
     repeated int64 localID = 3;
     optional int32 count = 4;
-}
\ No newline at end of file
+}
+
+message CompactionFileInfoProto {
+    required string fileName = 1;
+    optional string startKey = 2;
+    optional string endKey = 3;
+    optional string columnFamily = 4;
+}
+
+message CompactionLogEntryProto {
+    required uint64 dbSequenceNumber = 1;

Review Comment:
   We should avoid using `required`, Please see here: https://protobuf.dev/programming-guides/proto2/
   proto3 has already removed it. It is required for the application to handle this. Let me know what you think about it.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java:
##########
@@ -742,6 +751,11 @@ protected void initializeOmTables(boolean addCacheMetrics)
     checkTableStatus(snapshotRenamedTable, SNAPSHOT_RENAMED_TABLE,
         addCacheMetrics);
     // TODO: [SNAPSHOT] Initialize table lock for snapshotRenamedTable.
+
+    compactionLogTable = this.store.getTable(COMPACTION_LOG_TABLE,
+        String.class, String.class);

Review Comment:
   Shouldn't this be?
   ```suggestion
           String.class, CompactionLogEntry.class);
   ```



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