Skip to content

Commit

Permalink
[minor] Name BucketIdentifier in IndexManifestFileHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
JingsongLi committed May 22, 2024
1 parent e8acd22 commit 9cb2909
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import java.util.Map;
import java.util.zip.CRC32;

import static org.apache.paimon.utils.Preconditions.checkNotNull;

/** DeletionVectors index file. */
public class DeletionVectorsIndexFile extends IndexFile {

Expand All @@ -56,6 +58,8 @@ public DeletionVectorsIndexFile(FileIO fileIO, PathFactory pathFactory) {
public Map<String, DeletionVector> readAllDeletionVectors(IndexFileMeta fileMeta) {
LinkedHashMap<String, Pair<Integer, Integer>> deletionVectorRanges =
fileMeta.deletionVectorsRanges();
checkNotNull(deletionVectorRanges);

String indexFileName = fileMeta.fileName();
Map<String, DeletionVector> deletionVectors = new HashMap<>();
Path filePath = pathFactory.toPath(indexFileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.paimon.index.IndexFileMeta;
import org.apache.paimon.table.BucketMode;
import org.apache.paimon.utils.Pair;
import org.apache.paimon.utils.Preconditions;

import javax.annotation.Nullable;

Expand All @@ -34,6 +33,7 @@

import static org.apache.paimon.deletionvectors.DeletionVectorsIndexFile.DELETION_VECTORS_INDEX;
import static org.apache.paimon.index.HashIndexFile.HASH_INDEX;
import static org.apache.paimon.utils.Preconditions.checkArgument;

/** IndexManifestFile Handler. */
public class IndexManifestFileHandler {
Expand All @@ -53,7 +53,7 @@ String write(@Nullable String previousIndexManifest, List<IndexManifestEntry> ne
? new ArrayList<>()
: indexManifestFile.read(previousIndexManifest);
for (IndexManifestEntry entry : entries) {
Preconditions.checkArgument(entry.kind() == FileKind.ADD);
checkArgument(entry.kind() == FileKind.ADD);
}

Pair<List<IndexManifestEntry>, List<IndexManifestEntry>> previous =
Expand Down Expand Up @@ -129,13 +129,13 @@ public List<IndexManifestEntry> combine(
}
}

/** We combine the previous and new index files by {@link Identifier}. */
/** We combine the previous and new index files by {@link BucketIdentifier}. */
static class CommonBucketCombiner implements IndexManifestFileCombiner {

@Override
public List<IndexManifestEntry> combine(
List<IndexManifestEntry> prevIndexFiles, List<IndexManifestEntry> newIndexFiles) {
Map<Identifier, IndexManifestEntry> indexEntries = new HashMap<>();
Map<BucketIdentifier, IndexManifestEntry> indexEntries = new HashMap<>();
for (IndexManifestEntry entry : prevIndexFiles) {
indexEntries.put(identifier(entry), entry);
}
Expand All @@ -151,23 +151,23 @@ public List<IndexManifestEntry> combine(
}
}

private static Identifier identifier(IndexManifestEntry indexManifestEntry) {
return new Identifier(
private static BucketIdentifier identifier(IndexManifestEntry indexManifestEntry) {
return new BucketIdentifier(
indexManifestEntry.partition(),
indexManifestEntry.bucket(),
indexManifestEntry.indexFile().indexType());
}

/** The {@link Identifier} of a {@link IndexFileMeta}. */
public static class Identifier {
/** The {@link BucketIdentifier} of a {@link IndexFileMeta}. */
private static class BucketIdentifier {

public final BinaryRow partition;
public final int bucket;
public final String indexType;

private Integer hash;

private Identifier(BinaryRow partition, int bucket, String indexType) {
private BucketIdentifier(BinaryRow partition, int bucket, String indexType) {
this.partition = partition;
this.bucket = bucket;
this.indexType = indexType;
Expand All @@ -181,7 +181,7 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
Identifier that = (Identifier) o;
BucketIdentifier that = (BucketIdentifier) o;
return bucket == that.bucket
&& Objects.equals(partition, that.partition)
&& Objects.equals(indexType, that.indexType);
Expand All @@ -197,7 +197,7 @@ public int hashCode() {

@Override
public String toString() {
return "Identifier{"
return "BucketIdentifier{"
+ "partition="
+ partition
+ ", bucket="
Expand Down

0 comments on commit 9cb2909

Please sign in to comment.