Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,16 @@ public final class OzoneConsts {
public static final String OM_SLD_VERSION = "version";
public static final String OM_SLD_CHECKSUM = "checksum";
public static final String OM_SLD_IS_SST_FILTERED = "isSSTFiltered";
public static final String OM_SLD_UNCOMPACTED_SST_FILE_LIST = "uncompactedSSTFileList";
public static final String OM_SLD_LAST_COMPACTION_TIME = "lastCompactionTime";
public static final String OM_SLD_NEEDS_COMPACTION = "needsCompaction";
public static final String OM_SLD_COMPACTED_SST_FILE_LIST = "compactedSSTFileList";
public static final String OM_SLD_VERSION_SST_FILE_INFO = "versionSstFileInfos";
public static final String OM_SLD_PREV_SNAP_ID = "previousSnapshotId";
public static final String OM_SLD_VERSION_META_SST_FILES = "sstFiles";
public static final String OM_SLD_VERSION_META_PREV_SNAP_VERSION = "previousSnapshotVersion";
public static final String OM_SST_FILE_INFO_FILE_NAME = "fileName";
public static final String OM_SST_FILE_INFO_START_KEY = "startKey";
public static final String OM_SST_FILE_INFO_END_KEY = "endKey";
public static final String OM_SST_FILE_INFO_COL_FAMILY = "columnFamily";

// YAML fields for .container files
public static final String CONTAINER_ID = "containerID";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
/**
* 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;
public final class CompactionFileInfo extends SstFileInfo {
private boolean pruned;

@VisibleForTesting
Expand All @@ -47,29 +43,10 @@ public CompactionFileInfo(String fileName,
String endRange,
String columnFamily,
boolean pruned) {
this.fileName = fileName;
this.startKey = startRange;
this.endKey = endRange;
this.columnFamily = columnFamily;
super(fileName, startRange, endRange, columnFamily);
this.pruned = pruned;
}

public String getFileName() {
return fileName;
}

public String getStartKey() {
return startKey;
}

public String getEndKey() {
return endKey;
}

public String getColumnFamily() {
return columnFamily;
}

public boolean isPruned() {
return pruned;
}
Expand All @@ -81,16 +58,16 @@ public void setPruned() {
public HddsProtos.CompactionFileInfoProto getProtobuf() {
HddsProtos.CompactionFileInfoProto.Builder builder =
HddsProtos.CompactionFileInfoProto.newBuilder()
.setFileName(fileName)
.setFileName(getFileName())
.setPruned(pruned);
if (startKey != null) {
builder = builder.setStartKey(startKey);
if (getStartKey() != null) {
builder = builder.setStartKey(getStartKey());
}
if (endKey != null) {
builder = builder.setEndKey(endKey);
if (getEndKey() != null) {
builder = builder.setEndKey(getEndKey());
}
if (columnFamily != null) {
builder = builder.setColumnFamily(columnFamily);
if (getColumnFamily() != null) {
builder = builder.setColumnFamily(getColumnFamily());
}
return builder.build();
}
Expand All @@ -117,8 +94,25 @@ public static CompactionFileInfo getFromProtobuf(

@Override
public String toString() {
return String.format("fileName: '%s', startKey: '%s', endKey: '%s'," +
" columnFamily: '%s', isPruned: '%b'", fileName, startKey, endKey, columnFamily, pruned);
return String.format("%s, isPruned: '%b'", super.toString(), pruned);
}

@Override
public SstFileInfo copyObject() {
return new CompactionFileInfo(getFileName(), getStartKey(), getEndKey(), getColumnFamily(), pruned);
}

@Override
public boolean equals(Object o) {
if (!(o instanceof CompactionFileInfo)) {
return false;
}
return super.equals(o) && pruned == ((CompactionFileInfo)o).pruned;
Copy link

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The cast to CompactionFileInfo is unsafe since the type check was performed for CompactionFileInfo. However, consider storing the cast result in a variable for better readability: CompactionFileInfo other = (CompactionFileInfo) o; return super.equals(o) && pruned == other.pruned;

Suggested change
return super.equals(o) && pruned == ((CompactionFileInfo)o).pruned;
CompactionFileInfo other = (CompactionFileInfo) o;
return super.equals(o) && pruned == other.pruned;

Copilot uses AI. Check for mistakes.
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), pruned);
}

/**
Expand Down Expand Up @@ -180,25 +174,4 @@ public CompactionFileInfo build() {
columnFamily, pruned);
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof CompactionFileInfo)) {
return false;
}

CompactionFileInfo that = (CompactionFileInfo) o;
return Objects.equals(fileName, that.fileName) &&
Objects.equals(startKey, that.startKey) &&
Objects.equals(endKey, that.endKey) &&
Objects.equals(columnFamily, that.columnFamily);
}

@Override
public int hashCode() {
return Objects.hash(fileName, startKey, endKey, columnFamily);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* 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 java.util.Objects;
import org.apache.hadoop.hdds.StringUtils;
import org.apache.hadoop.hdds.utils.db.CopyObject;
import org.rocksdb.LiveFileMetaData;

/**
* Dao to keep SST file information in the compaction log.
*/
public class SstFileInfo implements CopyObject<SstFileInfo> {
private final String fileName;
private final String startKey;
private final String endKey;
private final String columnFamily;

public SstFileInfo(String fileName, String startRange, String endRange, String columnFamily) {
this.fileName = fileName;
this.startKey = startRange;
this.endKey = endRange;
this.columnFamily = columnFamily;
}

public SstFileInfo(LiveFileMetaData fileMetaData) {
this(fileMetaData.fileName(), StringUtils.bytes2String(fileMetaData.smallestKey()),
StringUtils.bytes2String(fileMetaData.largestKey()),
StringUtils.bytes2String(fileMetaData.columnFamilyName()));
}

public String getFileName() {
return fileName;
}

public String getStartKey() {
return startKey;
}

public String getEndKey() {
return endKey;
}

public String getColumnFamily() {
return columnFamily;
}

@Override
public String toString() {
return String.format("fileName: '%s', startKey: '%s', endKey: '%s'," +
" columnFamily: '%s'", fileName, startKey, endKey, columnFamily);
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof SstFileInfo)) {
return false;
}

SstFileInfo that = (SstFileInfo) o;
return Objects.equals(fileName, that.fileName) &&
Objects.equals(startKey, that.startKey) &&
Objects.equals(endKey, that.endKey) &&
Objects.equals(columnFamily, that.columnFamily);
}

@Override
public int hashCode() {
return Objects.hash(fileName, startKey, endKey, columnFamily);
}

@Override
public SstFileInfo copyObject() {
return new SstFileInfo(fileName, startKey, endKey, columnFamily);
}
}
1 change: 1 addition & 0 deletions hadoop-ozone/dist/src/main/license/bin/LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ Apache License 2.0
org.apache.commons:commons-compress
org.apache.commons:commons-configuration2
org.apache.commons:commons-lang3
org.apache.commons:commons-pool2
org.apache.commons:commons-text
org.apache.curator:curator-client
org.apache.curator:curator-framework
Expand Down
1 change: 1 addition & 0 deletions hadoop-ozone/dist/src/main/license/jar-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ share/ozone/lib/commons-io.jar
share/ozone/lib/commons-lang3.jar
share/ozone/lib/commons-lang.jar
share/ozone/lib/commons-net.jar
share/ozone/lib/commons-pool2.jar
share/ozone/lib/commons-text.jar
share/ozone/lib/commons-validator.jar
share/ozone/lib/commons-fileupload.jar
Expand Down
4 changes: 4 additions & 0 deletions hadoop-ozone/ozone-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-auth</artifactId>
Expand Down
Loading