Skip to content

Commit 774e89b

Browse files
committed
fix
1 parent 8586728 commit 774e89b

File tree

2 files changed

+19
-46
lines changed

2 files changed

+19
-46
lines changed

paimon-core/src/main/java/org/apache/paimon/deletionvectors/append/BaseAppendDeleteFileMaintainer.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,22 @@
2222
import org.apache.paimon.data.BinaryRow;
2323
import org.apache.paimon.deletionvectors.BucketedDvMaintainer;
2424
import org.apache.paimon.deletionvectors.DeletionVector;
25+
import org.apache.paimon.index.DeletionVectorMeta;
2526
import org.apache.paimon.index.IndexFileHandler;
2627
import org.apache.paimon.index.IndexFileMeta;
2728
import org.apache.paimon.manifest.IndexManifestEntry;
2829
import org.apache.paimon.table.source.DeletionFile;
2930

3031
import javax.annotation.Nullable;
3132

33+
import java.util.HashMap;
34+
import java.util.LinkedHashMap;
3235
import java.util.List;
3336
import java.util.Map;
3437
import java.util.stream.Collectors;
3538

3639
import static org.apache.paimon.deletionvectors.DeletionVectorsIndexFile.DELETION_VECTORS_INDEX;
40+
import static org.apache.paimon.utils.Preconditions.checkNotNull;
3741

3842
/**
3943
* A maintainer to maintain deletion files for append table, the core methods:
@@ -74,7 +78,21 @@ static AppendDeleteFileMaintainer forUnawareAppend(
7478
indexFileHandler.scan(snapshot, DELETION_VECTORS_INDEX).stream()
7579
.filter(e -> e.partition().equals(partition))
7680
.collect(Collectors.toList());
77-
Map<String, DeletionFile> deletionFiles = indexFileHandler.scanDVIndex(manifestEntries);
81+
Map<String, DeletionFile> deletionFiles = new HashMap<>();
82+
for (IndexManifestEntry file : manifestEntries) {
83+
IndexFileMeta meta = file.indexFile();
84+
LinkedHashMap<String, DeletionVectorMeta> dvMetas = meta.deletionVectorMetas();
85+
checkNotNull(dvMetas);
86+
for (DeletionVectorMeta dvMeta : dvMetas.values()) {
87+
deletionFiles.put(
88+
dvMeta.dataFileName(),
89+
new DeletionFile(
90+
indexFileHandler.filePath(meta).toString(),
91+
dvMeta.offset(),
92+
dvMeta.length(),
93+
dvMeta.cardinality()));
94+
}
95+
}
7896
return new AppendDeleteFileMaintainer(
7997
indexFileHandler.deletionVectorsIndex(), partition, manifestEntries, deletionFiles);
8098
}

paimon-core/src/main/java/org/apache/paimon/index/IndexFileHandler.java

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,16 @@
2525
import org.apache.paimon.fs.Path;
2626
import org.apache.paimon.manifest.IndexManifestEntry;
2727
import org.apache.paimon.manifest.IndexManifestFile;
28-
import org.apache.paimon.table.source.DeletionFile;
2928
import org.apache.paimon.utils.IntIterator;
3029
import org.apache.paimon.utils.Pair;
3130
import org.apache.paimon.utils.PathFactory;
3231
import org.apache.paimon.utils.SnapshotManager;
3332

34-
import javax.annotation.Nullable;
35-
3633
import java.io.IOException;
3734
import java.io.UncheckedIOException;
3835
import java.util.ArrayList;
3936
import java.util.Collections;
4037
import java.util.HashMap;
41-
import java.util.LinkedHashMap;
4238
import java.util.List;
4339
import java.util.Map;
4440
import java.util.Optional;
@@ -47,7 +43,6 @@
4743
import static org.apache.paimon.deletionvectors.DeletionVectorsIndexFile.DELETION_VECTORS_INDEX;
4844
import static org.apache.paimon.index.HashIndexFile.HASH_INDEX;
4945
import static org.apache.paimon.utils.Preconditions.checkArgument;
50-
import static org.apache.paimon.utils.Preconditions.checkNotNull;
5146

5247
/** Handle index files. */
5348
public class IndexFileHandler {
@@ -85,46 +80,6 @@ public Optional<IndexFileMeta> scanHashIndex(
8580
return result.isEmpty() ? Optional.empty() : Optional.of(result.get(0));
8681
}
8782

88-
public Map<String, DeletionFile> scanDVIndex(
89-
@Nullable Snapshot snapshot, BinaryRow partition, int bucket) {
90-
if (snapshot == null) {
91-
return Collections.emptyMap();
92-
}
93-
String indexManifest = snapshot.indexManifest();
94-
if (indexManifest == null) {
95-
return Collections.emptyMap();
96-
}
97-
List<IndexManifestEntry> manifests = new ArrayList<>();
98-
for (IndexManifestEntry file : indexManifestFile.read(indexManifest)) {
99-
IndexFileMeta meta = file.indexFile();
100-
if (meta.indexType().equals(DELETION_VECTORS_INDEX)
101-
&& file.partition().equals(partition)
102-
&& file.bucket() == bucket) {
103-
manifests.add(file);
104-
}
105-
}
106-
return scanDVIndex(manifests);
107-
}
108-
109-
public Map<String, DeletionFile> scanDVIndex(List<IndexManifestEntry> manifests) {
110-
Map<String, DeletionFile> result = new HashMap<>();
111-
for (IndexManifestEntry file : manifests) {
112-
IndexFileMeta meta = file.indexFile();
113-
LinkedHashMap<String, DeletionVectorMeta> dvMetas = meta.deletionVectorMetas();
114-
checkNotNull(dvMetas);
115-
for (DeletionVectorMeta dvMeta : dvMetas.values()) {
116-
result.put(
117-
dvMeta.dataFileName(),
118-
new DeletionFile(
119-
filePath(meta).toString(),
120-
dvMeta.offset(),
121-
dvMeta.length(),
122-
dvMeta.cardinality()));
123-
}
124-
}
125-
return result;
126-
}
127-
12883
public List<IndexManifestEntry> scan(String indexType) {
12984
return scan(snapshotManager.latestSnapshot(), indexType);
13085
}

0 commit comments

Comments
 (0)