This is an automated email from the ASF dual-hosted git repository.
smengcl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 667444e4192 HDDS-15393. Sequential reader of delta SST files for DAG
based snapshot diff. (#11428)
667444e4192 is described below
commit 667444e4192e6dddf33e55caee364fc2fa3ce49d
Author: SaketaChalamchala <[email protected]>
AuthorDate: Fri Oct 16 18:07:29 2026 -0700
HDDS-15393. Sequential reader of delta SST files for DAG based snapshot
diff. (#11428)
Co-authored-by: Cursor <[email protected]>
---
.../utils/db/LatestVersionedKWayMergeIterator.java | 85 +++--
...estLatestVersionedKWayMergeIteratorOverSst.java | 53 ++-
.../org/apache/hadoop/ozone/om/OMConfigKeys.java | 4 +-
.../om/snapshot/diff/DagDiffSequentialReader.java | 271 +++++++++++++
.../ozone/om/snapshot/diff/SnapDiffJobStore.java | 153 ++++++--
.../snapshot/diff/TestDagDiffSequentialReader.java | 423 +++++++++++++++++++++
.../diff/TestFullDiffSequentialReader.java | 2 +-
.../snapshot/diff/TestMergeJoinSnapDiffWriter.java | 6 +-
.../om/snapshot/diff/TestSnapDiffPathResolver.java | 4 +-
9 files changed, 923 insertions(+), 78 deletions(-)
diff --git
a/hadoop-hdds/rocks-native/src/main/java/org/apache/hadoop/hdds/utils/db/LatestVersionedKWayMergeIterator.java
b/hadoop-hdds/rocks-native/src/main/java/org/apache/hadoop/hdds/utils/db/LatestVersionedKWayMergeIterator.java
index fc072c7fde6..f142e2222fe 100644
---
a/hadoop-hdds/rocks-native/src/main/java/org/apache/hadoop/hdds/utils/db/LatestVersionedKWayMergeIterator.java
+++
b/hadoop-hdds/rocks-native/src/main/java/org/apache/hadoop/hdds/utils/db/LatestVersionedKWayMergeIterator.java
@@ -30,6 +30,7 @@
import java.util.PriorityQueue;
import org.apache.hadoop.hdds.utils.IOUtils;
import org.apache.hadoop.hdds.utils.db.managed.ManagedOptions;
+import org.apache.hadoop.hdds.utils.db.managed.ManagedSlice;
import org.apache.hadoop.ozone.util.ClosableIterator;
/**
@@ -50,7 +51,6 @@ public final class LatestVersionedKWayMergeIterator implements
public static final int ROCKS_TYPE_VALUE = 1;
private static final int DEFAULT_READ_AHEAD_SIZE = 2 * 1024 * 1024;
- private final ManagedOptions options;
private final List<ClosableIterator<? extends MergeHead>> iterators;
private final Long exclusiveMinSequenceNumber;
@@ -59,41 +59,45 @@ public final class LatestVersionedKWayMergeIterator
implements
private List<MergedKeyValue> emitQueue;
private boolean initialized;
- public static LatestVersionedKWayMergeIterator
overRawSstFiles(Collection<Path> sstFiles) {
- return overRawSstFiles(sstFiles, DEFAULT_READ_AHEAD_SIZE, null);
- }
-
- public static LatestVersionedKWayMergeIterator
overRawSstFiles(Collection<Path> sstFiles,
- int readAheadSizePerFile) {
- return overRawSstFiles(sstFiles, readAheadSizePerFile, null);
- }
-
/**
- * Opens one iterator per SST file and merges them.
+ * Opens one iterator per SST file and merges them within an optional
user-key range.
+ *
+ * <p>Caller contract: {@code fromUserKeyInclusive} and {@code
toUserKeyExclusive} are wrapped by
+ * native {@link org.apache.hadoop.hdds.utils.db.managed.ManagedSlice}
objects without copying.
+ * Callers must not mutate either array until the returned iterator is
closed.
*
* @param exclusiveMinSequenceNumber when non-null, each source skips
entries with
* sequence {@code <=} this value while advancing; when null, no
entries are skipped
+ * @param fromUserKeyInclusive when non-null and non-empty, each source
seeks to this lower bound
+ * @param toUserKeyExclusive when non-null and non-empty, each source stops
before this upper bound
*/
public static LatestVersionedKWayMergeIterator
overRawSstFiles(Collection<Path> sstFiles,
- int readAheadSizePerFile, Long exclusiveMinSequenceNumber) {
+ int readAheadSizePerFile, Long exclusiveMinSequenceNumber,
+ byte[] fromUserKeyInclusive, byte[] toUserKeyExclusive) {
Objects.requireNonNull(sstFiles, "sstFiles cannot be null");
- ManagedOptions options = new ManagedOptions();
List<ClosableIterator<? extends MergeHead>> sources = new
ArrayList<>(sstFiles.size());
- try {
+ try (ManagedOptions options = new ManagedOptions()) {
for (Path file : sstFiles) {
- sources.add(new RawSstIterator(options, file, readAheadSizePerFile));
+ sources.add(new RawSstIterator(options, file, readAheadSizePerFile,
fromUserKeyInclusive,
+ toUserKeyExclusive));
}
- return new LatestVersionedKWayMergeIterator(options, sources,
exclusiveMinSequenceNumber);
} catch (RuntimeException e) {
IOUtils.closeQuietly(sources);
- options.close();
throw e;
}
+ return new LatestVersionedKWayMergeIterator(sources,
exclusiveMinSequenceNumber);
}
+ /**
+ * Opens one iterator per SST file, skipping entries at or below {@code
exclusiveMinSequenceNumber}.
+ *
+ * <p>Bound arrays must stay unchanged until the returned iterator is
closed; see
+ * {@link #overRawSstFiles(Collection, int, Long, byte[], byte[])}.
+ */
public static LatestVersionedKWayMergeIterator
overRawSstFilesFromSequence(Collection<Path> sstFiles,
- long exclusiveMinSequenceNumber) {
- return overRawSstFiles(sstFiles, DEFAULT_READ_AHEAD_SIZE,
exclusiveMinSequenceNumber);
+ long exclusiveMinSequenceNumber, byte[] fromUserKeyInclusive, byte[]
toUserKeyExclusive) {
+ return overRawSstFiles(sstFiles, DEFAULT_READ_AHEAD_SIZE,
exclusiveMinSequenceNumber,
+ fromUserKeyInclusive, toUserKeyExclusive);
}
@VisibleForTesting
@@ -101,14 +105,12 @@ public static LatestVersionedKWayMergeIterator forTest(
List<ClosableIterator<MergedKeyValue>> iterators, Long
exclusiveMinSequenceNumber) {
List<ClosableIterator<? extends MergeHead>> sources = new
ArrayList<>(iterators.size());
sources.addAll(iterators);
- return new LatestVersionedKWayMergeIterator(null, sources,
exclusiveMinSequenceNumber);
+ return new LatestVersionedKWayMergeIterator(sources,
exclusiveMinSequenceNumber);
}
private LatestVersionedKWayMergeIterator(
- ManagedOptions options,
List<ClosableIterator<? extends MergeHead>> iterators,
Long exclusiveMinSequenceNumber) {
- this.options = options;
this.iterators = new ArrayList<>(Objects.requireNonNull(iterators,
"iterators cannot be null"));
this.exclusiveMinSequenceNumber = exclusiveMinSequenceNumber;
this.sourceHeads = new PriorityQueue<>(Math.max(this.iterators.size(), 1));
@@ -218,9 +220,6 @@ private void initHeap() {
@Override
public void close() {
IOUtils.closeQuietly(iterators);
- if (options != null) {
- options.close();
- }
}
private static int compareUserKeys(byte[] left, byte[] right) {
@@ -371,21 +370,30 @@ public int hashCode() {
private static final class RawSstIterator implements
ClosableIterator<RawSstHeapHead> {
private final ManagedRawSSTFileReader reader;
private final
ManagedRawSSTFileIterator<ManagedRawSSTFileIterator.KeyValue> iterator;
+ private final ManagedSlice fromSlice;
+ private final ManagedSlice toSlice;
private boolean closed;
- private RawSstIterator(ManagedOptions options, Path file, int
readAheadSize) {
+ private RawSstIterator(ManagedOptions options, Path file, int
readAheadSize,
+ byte[] fromUserKeyInclusive, byte[] toUserKeyExclusive) {
ManagedRawSSTFileReader openedReader = new ManagedRawSSTFileReader(
options, file.toAbsolutePath().toString(), readAheadSize);
+ ManagedSlice openedFromSlice = toManagedSlice(fromUserKeyInclusive);
+ ManagedSlice openedToSlice = toManagedSlice(toUserKeyExclusive);
ManagedRawSSTFileIterator<ManagedRawSSTFileIterator.KeyValue>
openedIterator;
try {
openedIterator = openedReader.newIterator(
- kv -> kv, null, null, IteratorType.KEY_AND_VALUE);
+ kv -> kv, openedFromSlice, openedToSlice,
IteratorType.KEY_AND_VALUE);
} catch (RuntimeException e) {
+ closeQuietly(openedToSlice);
+ closeQuietly(openedFromSlice);
openedReader.close();
throw e;
}
this.reader = openedReader;
this.iterator = openedIterator;
+ this.fromSlice = openedFromSlice;
+ this.toSlice = openedToSlice;
}
@Override
@@ -411,8 +419,27 @@ public void close() {
return;
}
closed = true;
- iterator.close();
- reader.close();
+ if (iterator != null) {
+ iterator.close();
+ }
+ if (reader != null) {
+ reader.close();
+ }
+ closeQuietly(toSlice);
+ closeQuietly(fromSlice);
+ }
+
+ private static ManagedSlice toManagedSlice(byte[] key) {
+ if (key == null || key.length == 0) {
+ return null;
+ }
+ return new ManagedSlice(key);
+ }
+
+ private static void closeQuietly(ManagedSlice slice) {
+ if (slice != null) {
+ slice.close();
+ }
}
}
diff --git
a/hadoop-hdds/rocks-native/src/test/java/org/apache/hadoop/hdds/utils/db/TestLatestVersionedKWayMergeIteratorOverSst.java
b/hadoop-hdds/rocks-native/src/test/java/org/apache/hadoop/hdds/utils/db/TestLatestVersionedKWayMergeIteratorOverSst.java
index 1d134e408bf..dfc8c2b9809 100644
---
a/hadoop-hdds/rocks-native/src/test/java/org/apache/hadoop/hdds/utils/db/TestLatestVersionedKWayMergeIteratorOverSst.java
+++
b/hadoop-hdds/rocks-native/src/test/java/org/apache/hadoop/hdds/utils/db/TestLatestVersionedKWayMergeIteratorOverSst.java
@@ -17,6 +17,7 @@
package org.apache.hadoop.hdds.utils.db;
+import static
org.apache.hadoop.hdds.StringUtils.getLexicographicallyHigherString;
import static
org.apache.hadoop.hdds.utils.NativeConstants.ROCKS_TOOLS_NATIVE_PROPERTY;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -127,7 +128,7 @@ void testWorkedExampleOverRealSstFiles() throws Exception {
assertEquals(3, distinctK1Sequences,
"k1 versions across SST files should carry distinct RocksDB sequence
numbers");
- List<MergedKeyValue> actual = mergeSstFiles(sstFiles.toArray(new Path[0]));
+ List<MergedKeyValue> actual = mergeSstFiles(sstFiles, null, null);
assertEquals(3, actual.size(), "expected k1 winner plus k2 tombstone and
recreate value");
MergedKeyValue k1Winner = actual.get(0);
@@ -147,6 +148,50 @@ void testWorkedExampleOverRealSstFiles() throws Exception {
"recreate value must be newer than the tombstone");
}
+ @Test
+ void testMergeRespectsUserKeyPrefixBounds() throws Exception {
+ String bucketPrefixA = "/vol/buckA/";
+ String bucketPrefixB = "/vol/buckB/";
+ Path dbDir = tempDir.resolve("prefix-bounds-db");
+ Files.createDirectories(dbDir);
+ Set<String> knownSstFiles = new HashSet<>();
+ List<Path> sstFiles = new ArrayList<>(2);
+
+ try (ManagedDBOptions dbOptions = new ManagedDBOptions();
+ ManagedColumnFamilyOptions cfOptions = new
ManagedColumnFamilyOptions();
+ FlushOptions flushOptions = new FlushOptions()) {
+ dbOptions.setCreateIfMissing(true);
+ List<ColumnFamilyDescriptor> columnFamilyDescriptors =
Collections.singletonList(
+ new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY,
cfOptions));
+ List<ColumnFamilyHandle> columnFamilyHandles = new ArrayList<>();
+ try (ManagedRocksDB db = ManagedRocksDB.open(
+ dbOptions, dbDir.toString(), columnFamilyDescriptors,
columnFamilyHandles);
+ ColumnFamilyHandle cf = columnFamilyHandles.get(0)) {
+
+ rocksPut(db, cf, bucketPrefixA + "file1", "a1");
+ rocksPut(db, cf, bucketPrefixB + "file1", "b1");
+ rocksPut(db, cf, bucketPrefixA + "file2", "a2");
+ sstFiles.add(flushAndCopySst(db, dbDir, cf, flushOptions,
knownSstFiles, "first"));
+
+ rocksPut(db, cf, bucketPrefixB + "file2", "b2");
+ rocksDelete(db, cf, bucketPrefixA + "file1");
+ sstFiles.add(flushAndCopySst(db, dbDir, cf, flushOptions,
knownSstFiles, "second"));
+ }
+ }
+
+ byte[] lowerBound = keyBytes(bucketPrefixA);
+ byte[] upperBoundExclusive =
keyBytes(getLexicographicallyHigherString(bucketPrefixA));
+ List<MergedKeyValue> bucketAOnly = mergeSstFiles(sstFiles, lowerBound,
upperBoundExclusive);
+ List<String> userKeys = bucketAOnly.stream()
+ .map(kv -> new String(kv.getUserKey(), StandardCharsets.UTF_8))
+ .collect(Collectors.toList());
+
+ assertEquals(2, userKeys.size());
+ assertTrue(userKeys.contains(bucketPrefixA + "file1"));
+ assertTrue(userKeys.contains(bucketPrefixA + "file2"));
+ assertTrue(userKeys.stream().noneMatch(key ->
key.startsWith(bucketPrefixB)));
+ }
+
private Path flushAndCopySst(ManagedRocksDB db, Path dbDir,
ColumnFamilyHandle cf,
FlushOptions flushOptions, Set<String> knownSstFiles, String label)
throws RocksDBException, IOException {
@@ -172,10 +217,12 @@ private static Path findNewSstFile(Path dbDir,
Set<String> knownSstFiles) throws
}
}
- private List<MergedKeyValue> mergeSstFiles(Path... sstFiles) throws
Exception {
+ private List<MergedKeyValue> mergeSstFiles(List<Path> sstFiles, byte[]
fromUserKeyInclusive,
+ byte[] toUserKeyExclusive) {
List<MergedKeyValue> results = new ArrayList<>();
try (LatestVersionedKWayMergeIterator iterator =
-
LatestVersionedKWayMergeIterator.overRawSstFiles(Arrays.asList(sstFiles))) {
+ LatestVersionedKWayMergeIterator.overRawSstFilesFromSequence(
+ sstFiles, 0L, fromUserKeyInclusive, toUserKeyExclusive)) {
while (iterator.hasNext()) {
results.add(iterator.next());
}
diff --git
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java
index a90f0d11277..c8becaa14a9 100644
---
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java
+++
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java
@@ -707,9 +707,9 @@ public final class OMConfigKeys {
public static final String
OZONE_OM_SNAPSHOT_DIFF_MAX_IN_MEMORY_ENTRIES_PER_JOB
= "ozone.om.snapshot.diff.max.in.memory.entries.per.job";
- public static final long
+ public static final int
OZONE_OM_SNAPSHOT_DIFF_MAX_IN_MEMORY_ENTRIES_PER_JOB_DEFAULT
- = 1_000_000L;
+ = 1_000_000;
public static final String OZONE_OM_UPGRADE_QUOTA_RECALCULATE_ENABLE
= "ozone.om.upgrade.quota.recalculate.enabled";
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/diff/DagDiffSequentialReader.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/diff/DagDiffSequentialReader.java
new file mode 100644
index 00000000000..8079c873df4
--- /dev/null
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/diff/DagDiffSequentialReader.java
@@ -0,0 +1,271 @@
+/*
+ * 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.snapshot.diff;
+
+import static
org.apache.hadoop.hdds.StringUtils.getLexicographicallyHigherString;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.apache.hadoop.hdds.StringUtils;
+import org.apache.hadoop.hdds.utils.db.CodecException;
+import org.apache.hadoop.hdds.utils.db.IteratorType;
+import org.apache.hadoop.hdds.utils.db.LatestVersionedKWayMergeIterator;
+import
org.apache.hadoop.hdds.utils.db.LatestVersionedKWayMergeIterator.MergedKeyValue;
+import org.apache.hadoop.hdds.utils.db.RocksDatabaseException;
+import org.apache.hadoop.hdds.utils.db.Table;
+import org.apache.hadoop.ozone.util.ClosableIterator;
+
+/**
+ * The DAG-based diff multi-stage sequential read that produces the
intermediate structures
+ * consumed by the later merge-join and path-resolution stages.
+ *
+ * <p>Call {@link #scanFileTables} then {@link #scanDirectoryTables} (FSO
only) in that order.
+ * Each method runs the to-side delta SST scan first, then the from-side load
for the same
+ * table pair. Directory stages full-scan {@code fromSnapshot.directoryTable}
before
+ * {@code toSnapshot.directoryTable}.
+ *
+ * <p>Scans iterate the raw snapshot tables ({@code Table<byte[], byte[]>} from
+ * {@code DBStore#getTable(String)}) or raw delta SST files so {@link
SnapshotDiffValueParser} reads the exact
+ * persisted protobuf bytes and compare signatures match on-disk layout.
+ *
+ * <p>File/key from-side loads are driven by delta table keys batched at
{@code writeBatchSize}.
+ * Directory {@code DiffCandidateSet} membership is populated only from
directory delta SSTs and
+ * consulted during the from-side directory scan; directory delta tombstones
are tracked in a
+ * separate spilled key set with the same in-memory limit.
+ *
+ * <p>Sequence gating ({@code fromSnapshot.dbTxSequenceNumber}) is passed to
the K-way merge
+ * iterator; this reader consumes only entries the iterator emits (tombstones
and rows with
+ * {@code sequence > fromSnapshot.dbTxSequenceNumber}).
+ *
+ * <p>Delta SST scans honor the bucket {@code keyPrefix} via native SST
iterator bounds. The
+ * {@code keyPrefix} array must not be modified for the duration of each delta
SST scan.
+ */
+public class DagDiffSequentialReader {
+
+ private final SnapDiffJobStore store;
+ private final long exclusiveMinSequenceNumber;
+
+ /**
+ * @param store per-job temp column families for this
DAG diff job
+ * @param exclusiveMinSequenceNumber {@code
fromSnapshot.dbTxSequenceNumber}; passed to the
+ * K-way merge iterator
+ */
+ public DagDiffSequentialReader(SnapDiffJobStore store, long
exclusiveMinSequenceNumber) {
+ this.store = store;
+ this.exclusiveMinSequenceNumber = exclusiveMinSequenceNumber;
+ }
+
+ /**
+ * Scans file/key-table delta SSTs with interleaved batched {@code
multiGetSkipCache} against
+ * {@code fromSnapshot.file/keyTable}.
+ *
+ * @param keyPrefix optional bucket prefix as stored in RocksDB; {@code
null} scans the full
+ * delta SST key range
+ * @param deltaSstFiles delta SST paths for the to-side file/key table
+ * @param fromFileTable raw {@code fromSnapshot}'s file or key table
+ */
+ public void scanFileTables(byte[] keyPrefix, Collection<Path> deltaSstFiles,
+ Table<byte[], byte[]> fromFileTable) throws IOException {
+ if (deltaSstFiles.isEmpty()) {
+ return;
+ }
+ try (LatestVersionedKWayMergeIterator iterator =
+
LatestVersionedKWayMergeIterator.overRawSstFilesFromSequence(deltaSstFiles,
+ exclusiveMinSequenceNumber, keyPrefix,
prefixUpperBoundExclusive(keyPrefix))) {
+ scanFileDeltaEntries(iterator, fromFileTable);
+ }
+ }
+
+ /**
+ * Scans directory-table delta SSTs, then full scans of {@code
fromSnapshot.directoryTable}
+ * and {@code toSnapshot.directoryTable} (FSO only).
+ *
+ * @param keyPrefix optional bucket prefix as stored in RocksDB;
{@code null} scans the
+ * full table
+ * @param deltaSstFiles delta SST paths for the to-side directory table
+ * @param fromDirectoryTable raw {@code fromSnapshot.directoryTable}
+ * @param toDirectoryTable raw {@code toSnapshot.directoryTable}
+ */
+ public void scanDirectoryTables(byte[] keyPrefix, Collection<Path>
deltaSstFiles,
+ Table<byte[], byte[]> fromDirectoryTable,
+ Table<byte[], byte[]> toDirectoryTable) throws IOException {
+ if (!deltaSstFiles.isEmpty()) {
+ try (LatestVersionedKWayMergeIterator iterator =
+
LatestVersionedKWayMergeIterator.overRawSstFilesFromSequence(deltaSstFiles,
+ exclusiveMinSequenceNumber, keyPrefix,
prefixUpperBoundExclusive(keyPrefix))) {
+ scanDirectoryDeltaEntries(iterator);
+ }
+ }
+ scanFromDirectoryTable(fromDirectoryTable, keyPrefix);
+ scanToDirectoryTable(toDirectoryTable, keyPrefix);
+ }
+
+ @VisibleForTesting
+ void scanFileTablesFromDelta(ClosableIterator<MergedKeyValue> deltaEntries,
+ Table<byte[], byte[]> fromFileTable) throws IOException {
+ scanFileDeltaEntries(deltaEntries, fromFileTable);
+ }
+
+ @VisibleForTesting
+ void scanDirectoryTablesFromDelta(ClosableIterator<MergedKeyValue>
deltaEntries, byte[] keyPrefix,
+ Table<byte[], byte[]> fromDirectoryTable,
+ Table<byte[], byte[]> toDirectoryTable) throws IOException {
+ scanDirectoryDeltaEntries(deltaEntries);
+ scanFromDirectoryTable(fromDirectoryTable, keyPrefix);
+ scanToDirectoryTable(toDirectoryTable, keyPrefix);
+ }
+
+ private void scanFileDeltaEntries(ClosableIterator<MergedKeyValue> entries,
+ Table<byte[], byte[]> fromFileTable) throws IOException {
+ int batchSize = store.getWriteBatchSize();
+ List<byte[]> lookupBatch = new ArrayList<>(batchSize);
+ try {
+ while (entries.hasNext()) {
+ MergedKeyValue entry = entries.next();
+ lookupBatch.add(entry.getUserKey());
+ if (!entry.isTombstone()) {
+ byte[] value = entry.getValue();
+ SnapshotDiffValueParser.ParsedRequiredInfo info =
parseRequired(value, false);
+ byte[] signature = computeSignature(value, false);
+ store.putNewList(info.getObjectId(),
+ new EntryValue(info.getParentId(), info.getName(), false,
signature).toBytes());
+ }
+ if (lookupBatch.size() >= batchSize) {
+ multiGetAndPutOldList(lookupBatch, fromFileTable);
+ lookupBatch.clear();
+ }
+ }
+ } finally {
+ entries.close();
+ }
+ if (!lookupBatch.isEmpty()) {
+ multiGetAndPutOldList(lookupBatch, fromFileTable);
+ }
+ store.flushWrites();
+ }
+
+ private void scanDirectoryDeltaEntries(ClosableIterator<MergedKeyValue>
entries) throws IOException {
+ try {
+ while (entries.hasNext()) {
+ MergedKeyValue entry = entries.next();
+ if (entry.isTombstone()) {
+ store.addDirTombstoneKey(entry.getUserKey());
+ continue;
+ }
+ byte[] value = entry.getValue();
+ SnapshotDiffValueParser.ParsedRequiredInfo info = parseRequired(value,
true);
+ store.addDiffCandidate(info.getObjectId());
+ byte[] signature = computeSignature(value, true);
+ store.putNewList(info.getObjectId(),
+ new EntryValue(info.getParentId(), info.getName(), true,
signature).toBytes());
+ }
+ } finally {
+ entries.close();
+ store.flushWrites();
+ }
+ }
+
+ private void scanFromDirectoryTable(Table<byte[], byte[]> table, byte[]
keyPrefix) throws IOException {
+ store.flushWrites();
+ try (Table.KeyValueIterator<byte[], byte[]> iterator =
+ table.iterator(keyPrefix, IteratorType.KEY_AND_VALUE)) {
+ while (iterator.hasNext()) {
+ Table.KeyValue<byte[], byte[]> kv = iterator.next();
+ byte[] tableKey = kv.getKey();
+ byte[] value = kv.getValue();
+ SnapshotDiffValueParser.ParsedRequiredInfo info = parseRequired(value,
true);
+ long objectId = info.getObjectId();
+ store.putFromEdge(info.getParentId(), objectId,
nameBytes(info.getName()));
+
+ if (store.isDiffCandidate(objectId) ||
store.isDirTombstoneKey(tableKey)) {
+ byte[] signature = computeSignature(value, true);
+ store.putOldList(objectId,
+ new EntryValue(info.getParentId(), info.getName(), true,
signature).toBytes());
+ }
+ }
+ } catch (RocksDatabaseException | CodecException e) {
+ throw new IOException(e);
+ }
+ store.clearDiffCandidates();
+ store.clearDirTombstoneKeys();
+ store.flushWrites();
+ }
+
+ private void scanToDirectoryTable(Table<byte[], byte[]> table, byte[]
keyPrefix) throws IOException {
+ try (Table.KeyValueIterator<byte[], byte[]> iterator =
+ table.iterator(keyPrefix, IteratorType.VALUE_ONLY)) {
+ while (iterator.hasNext()) {
+ byte[] value = iterator.next().getValue();
+ SnapshotDiffValueParser.ParsedRequiredInfo info = parseRequired(value,
true);
+ store.putToEdge(info.getParentId(), info.getObjectId(),
nameBytes(info.getName()));
+ }
+ } catch (RocksDatabaseException | CodecException e) {
+ throw new IOException(e);
+ }
+ store.flushWrites();
+ }
+
+ private void multiGetAndPutOldList(List<byte[]> keys, Table<byte[], byte[]>
fromFileTable)
+ throws IOException {
+ List<byte[]> values;
+ try {
+ values = fromFileTable.multiGetSkipCache(keys);
+ } catch (RocksDatabaseException | CodecException e) {
+ throw new IOException("Failed to read table keys in batch", e);
+ }
+ for (byte[] value : values) {
+ if (value == null) {
+ continue;
+ }
+ SnapshotDiffValueParser.ParsedRequiredInfo info = parseRequired(value,
false);
+ byte[] signature = computeSignature(value, false);
+ store.putOldList(info.getObjectId(),
+ new EntryValue(info.getParentId(), info.getName(), false,
signature).toBytes());
+ }
+ }
+
+ private static SnapshotDiffValueParser.ParsedRequiredInfo
parseRequired(byte[] value, boolean isDir)
+ throws IOException {
+ return isDir
+ ? SnapshotDiffValueParser.parseDirectoryInfoRequiredFields(value,
false)
+ : SnapshotDiffValueParser.parseKeyInfoRequiredFields(value, false);
+ }
+
+ private static byte[] computeSignature(byte[] value, boolean isDir) throws
IOException {
+ return isDir
+ ? SnapshotDiffValueParser.computeDirectoryInfoCompareSignature(value)
+ : SnapshotDiffValueParser.computeKeyInfoCompareSignature(value);
+ }
+
+ private static byte[] nameBytes(String name) {
+ return (name == null ? "" : name).getBytes(StandardCharsets.UTF_8);
+ }
+
+ private static byte[] prefixUpperBoundExclusive(byte[] keyPrefix) {
+ if (keyPrefix == null || keyPrefix.length == 0) {
+ return null;
+ }
+ return StringUtils.string2Bytes(
+ getLexicographicallyHigherString(new String(keyPrefix,
StandardCharsets.UTF_8)));
+ }
+}
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/diff/SnapDiffJobStore.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/diff/SnapDiffJobStore.java
index 6e00dc628c7..e91a88f53de 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/diff/SnapDiffJobStore.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/diff/SnapDiffJobStore.java
@@ -19,9 +19,12 @@
import static org.apache.commons.lang3.StringUtils.leftPad;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_DIFF_MAX_IN_MEMORY_ENTRIES_PER_JOB_DEFAULT;
+import static org.apache.hadoop.ozone.om.OmSnapshotManager.DELIMITER;
import static
org.apache.hadoop.ozone.om.snapshot.SnapshotDiffManager.getReportKeyForIndex;
import static
org.apache.hadoop.ozone.om.snapshot.SnapshotUtils.dropColumnFamilyHandle;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.primitives.UnsignedBytes;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import java.io.IOException;
@@ -30,12 +33,15 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.NavigableSet;
import java.util.NoSuchElementException;
import java.util.Set;
+import java.util.TreeSet;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.hdds.StringUtils;
import org.apache.hadoop.hdds.utils.db.CodecRegistry;
@@ -55,21 +61,21 @@
* Owns the per-job temporary RocksDB column families and batched writes shared
* between optimized snapshot diff pipeline stages.
*
- * <p>Diff-candidate {@code objectId}s are held in memory while their count is
at
- * most {@code maxInMemoryEntries}; larger sets spill to a temporary column
family.
- * Deleted and renamed directory object ids collected during merge join use
the same
- * in-memory limit and spill policy.
+ * <p>Diff-candidate {@code objectId}s and DAG directory tombstone table keys
are held in
+ * memory while their count is at most {@code maxInMemoryEntries}; larger sets
spill to a
+ * temporary column family. Deleted and renamed directory object ids collected
during merge
+ * join use the same in-memory limit and spill policy.
*
* <p>All RocksDB puts use raw {@code byte[]} keys and values (the JNI
boundary). Callers
* serialize {@link EntryValue} via {@link EntryValue#toBytes()} before
writing to
* {@code newList}/{@code oldList}.
*
- * <p>Temporary column families disable RocksDB auto-compactions and are
dropped once a pipeline
- * stage no longer reads them. Individual key deletes are avoided so
short-lived CFs do not
- * accumulate tombstones before drop.
+ * <p>Temporary column families are created from a copy of the supplied
column-family options with
+ * auto-compactions disabled, then dropped once a pipeline stage no longer
reads them. Individual
+ * key deletes are avoided so short-lived CFs do not accumulate tombstones
before drop.
*
- * <p>This initial version supports the full diff sequential reader ({@link
FullDiffSequentialReader}).
- * DAG diff support extends this store in HDDS-15393.
+ * <p>Shared by the full diff sequential reader ({@link
FullDiffSequentialReader}) and the
+ * DAG diff sequential reader ({@link DagDiffSequentialReader}).
*/
public final class SnapDiffJobStore implements AutoCloseable {
@@ -79,9 +85,13 @@ public final class SnapDiffJobStore implements AutoCloseable
{
/** Reverse edge value header: parentId (8 BE) + nameLen (4 BE). */
static final int EDGE_LINK_HEADER_BYTES = Long.BYTES + Integer.BYTES;
+ private static final Comparator<byte[]> TOMBSTONE_KEY_COMPARATOR =
+ UnsignedBytes.lexicographicalComparator();
+
private static final String NEW_LIST_SUFFIX = "-new-list";
private static final String OLD_LIST_SUFFIX = "-old-list";
private static final String CAND_IDS_SUFFIX = "-cand-ids";
+ private static final String DIR_TOMBSTONE_KEYS_SUFFIX =
"-dir-tombstone-keys";
private static final String TO_EDGES_SUFFIX = "-to-edges";
private static final String FROM_EDGES_SUFFIX = "-from-edges";
private static final String CLASSIFIED_CREATE_SUFFIX = "-cls-create";
@@ -98,8 +108,8 @@ public final class SnapDiffJobStore implements AutoCloseable
{
private final CodecRegistry codecRegistry;
private final ColumnFamilyHandle reportCfh;
private final byte[] presentMarker;
- private final ManagedColumnFamilyOptions familyOptions;
- private final long maxInMemoryEntries;
+ private final ManagedColumnFamilyOptions tmpCfFamilyOptions;
+ private final int maxInMemoryEntries;
private final List<ColumnFamilyHandle> temporaryColumnFamilies = new
ArrayList<>();
private ColumnFamilyHandle newListCf;
@@ -113,12 +123,17 @@ public final class SnapDiffJobStore implements
AutoCloseable {
private ColumnFamilyHandle dependencyNodesCf;
private String diffCandCfName;
- private Set<Long> diffCandidates;
+ private final Set<Long> diffCandidates;
private ColumnFamilyHandle diffCandidatesCf;
private boolean diffCandidatesSpilled;
- private Set<Long> deletedDirectoryIds;
- private Set<Long> renamedDirectoryIds;
+ private String dirTombstoneKeysCfName;
+ private final NavigableSet<byte[]> dirTombstoneKeys;
+ private ColumnFamilyHandle dirTombstoneKeysCf;
+ private boolean dirTombstoneKeysSpilled;
+
+ private final Set<Long> deletedDirectoryIds;
+ private final Set<Long> renamedDirectoryIds;
private String deletedDirectoryIdsCfName;
private String renamedDirectoryIdsCfName;
private ColumnFamilyHandle deletedDirectoryIdsCf;
@@ -139,15 +154,9 @@ public final class SnapDiffJobStore implements
AutoCloseable {
private final byte[] objectIdKeyBuffer = new byte[Long.BYTES];
private final byte[] intKeyBuffer = new byte[Integer.BYTES];
- /** Full diff: shared new/old lists plus FSO edge column families. */
- public enum Mode {
- FULL,
- DAG
- }
-
@SuppressWarnings("checkstyle:ParameterNumber")
private SnapDiffJobStore(ManagedRocksDB db, String jobId, CodecRegistry
codecRegistry, boolean fso,
- int writeBatchSize, ManagedColumnFamilyOptions familyOptions, long
maxInMemoryEntries,
+ int writeBatchSize, ManagedColumnFamilyOptions tmpCfFamilyOptions, int
maxInMemoryEntries,
@Nonnull ColumnFamilyHandle reportCfh) throws IOException {
this.db = db;
this.jobId = jobId;
@@ -155,14 +164,15 @@ private SnapDiffJobStore(ManagedRocksDB db, String jobId,
CodecRegistry codecReg
this.codecRegistry = codecRegistry;
this.reportCfh = reportCfh;
this.writeBatchSize = writeBatchSize;
- this.familyOptions = familyOptions;
- this.familyOptions.setDisableAutoCompactions(true);
+ this.tmpCfFamilyOptions = tmpCfFamilyOptions;
+ this.tmpCfFamilyOptions.setDisableAutoCompactions(true);
this.maxInMemoryEntries = maxInMemoryEntries;
this.presentMarker = codecRegistry.asRawData(Boolean.TRUE);
this.writeBatch = new ManagedWriteBatch();
this.writeOptions = new ManagedWriteOptions();
this.pendingOps = 0;
this.diffCandidates = new HashSet<>();
+ this.dirTombstoneKeys = new TreeSet<>(TOMBSTONE_KEY_COMPARATOR);
this.deletedDirectoryIds = new HashSet<>();
this.renamedDirectoryIds = new HashSet<>();
}
@@ -175,14 +185,15 @@ public static SnapDiffJobStore open(@Nonnull
ManagedRocksDB db,
boolean fso,
@Nonnull ColumnFamilyHandle reportCfh,
@Nullable Integer writeBatchSize,
- @Nullable Long maxInMemoryEntries) throws IOException {
+ @Nullable Integer maxInMemoryEntries) throws IOException {
int resolvedWriteBatchSize = writeBatchSize != null ? writeBatchSize :
DEFAULT_BATCH_SIZE;
- long resolvedMaxInMemoryEntries = maxInMemoryEntries != null ?
maxInMemoryEntries
+ int resolvedMaxInMemoryEntries = maxInMemoryEntries != null ?
maxInMemoryEntries
: OZONE_OM_SNAPSHOT_DIFF_MAX_IN_MEMORY_ENTRIES_PER_JOB_DEFAULT;
+ ManagedColumnFamilyOptions tmpCfFamilyOptions = new
ManagedColumnFamilyOptions(familyOptions);
SnapDiffJobStore store = new SnapDiffJobStore(db, jobId, codecRegistry,
fso, resolvedWriteBatchSize,
- familyOptions, resolvedMaxInMemoryEntries, reportCfh);
+ tmpCfFamilyOptions, resolvedMaxInMemoryEntries, reportCfh);
try {
- store.initColumnFamilies(familyOptions);
+ store.initColumnFamilies();
return store;
} catch (RocksDBException e) {
store.closeQuietly();
@@ -190,7 +201,7 @@ public static SnapDiffJobStore open(@Nonnull ManagedRocksDB
db,
}
}
- long getMaxInMemoryEntries() {
+ int getMaxInMemoryEntries() {
return maxInMemoryEntries;
}
@@ -198,14 +209,20 @@ int getWriteBatchSize() {
return writeBatchSize;
}
+ @VisibleForTesting
+ ManagedColumnFamilyOptions getCopiedCfFamilyOptions() {
+ return tmpCfFamilyOptions;
+ }
+
/** Returns report entries written during a test run. */
List<DiffReportEntry> readReportEntriesForTest() throws IOException {
List<DiffReportEntry> entries = new ArrayList<>();
+ String jobPrefix = jobId + DELIMITER;
try (ManagedRocksIterator iterator = new
ManagedRocksIterator(db.get().newIterator(reportCfh))) {
- iterator.get().seek(codecRegistry.asRawData(jobId));
+ iterator.get().seek(codecRegistry.asRawData(jobPrefix));
while (iterator.get().isValid()) {
String key = codecRegistry.asObject(iterator.get().key(),
String.class);
- if (!key.startsWith(jobId)) {
+ if (!key.startsWith(jobPrefix)) {
break;
}
entries.add(codecRegistry.asObject(iterator.get().value(),
DiffReportEntry.class));
@@ -281,7 +298,7 @@ SnapDiffPathResolver newToPathResolver(long bucketObjectId)
{
}
private int pathResolverLruCapacity() {
- return (int) maxInMemoryEntries / 2;
+ return maxInMemoryEntries / 2;
}
int ancestorMemoCapacity() {
@@ -299,6 +316,17 @@ List<byte[]> multiGetFromEdgeValues(List<Long> objectIds)
throws IOException {
return multiGet(db, fromEdgesCf, keys);
}
+ List<byte[]> multiGetToEdgeValues(List<Long> objectIds) throws IOException {
+ if (objectIds.isEmpty()) {
+ return Collections.emptyList();
+ }
+ List<byte[]> keys = new ArrayList<>(objectIds.size());
+ for (Long objectId : objectIds) {
+ keys.add(objectIdKey(objectId));
+ }
+ return multiGet(db, toEdgesCf, keys);
+ }
+
public List<Long> multiGetFromParentIds(List<Long> objectIds) throws
IOException {
List<byte[]> values = multiGetFromEdgeValues(objectIds);
List<Long> parentIds = new ArrayList<>(values.size());
@@ -362,7 +390,7 @@ public void putDependencyNode(int nodeIndex,
SnapDiffDependencyEntry entry)
}
/** Ascending iterator over the dependency-node column family. */
- public DependencyNodeIterator dependencyNodeIterator() throws
RocksDatabaseException {
+ public DependencyNodeIterator dependencyNodeIterator() {
return new DependencyNodeIterator(dependencyNodesCf);
}
@@ -415,7 +443,7 @@ public boolean isDiffCandidate(long objectId) throws
IOException {
}
/** Clears the diff-candidate set after a from-side scan consumes it. */
- public void clearDiffCandidates() throws IOException {
+ public void clearDiffCandidates() {
diffCandidates.clear();
if (diffCandidatesSpilled) {
dropAndClose(diffCandidatesCf);
@@ -428,6 +456,39 @@ public int getDiffCandidateCount() {
return diffCandidates.size();
}
+ /** Records a directory-table tombstone key from a DAG delta SST scan. */
+ public void addDirTombstoneKey(byte[] tableKey) throws IOException {
+ if (dirTombstoneKeysSpilled) {
+ batchPut(dirTombstoneKeysCf, tableKey, presentMarker);
+ return;
+ }
+ if (dirTombstoneKeys.size() >= maxInMemoryEntries) {
+ spillDirTombstoneKeys();
+ }
+ if (dirTombstoneKeysSpilled) {
+ batchPut(dirTombstoneKeysCf, tableKey, presentMarker);
+ } else {
+ dirTombstoneKeys.add(tableKey);
+ }
+ }
+
+ /** Returns whether {@code tableKey} was recorded as a directory delta
tombstone. */
+ public boolean isDirTombstoneKey(byte[] tableKey) throws IOException {
+ if (dirTombstoneKeysSpilled) {
+ return get(dirTombstoneKeysCf, tableKey) != null;
+ }
+ return dirTombstoneKeys.contains(tableKey);
+ }
+
+ /** Clears directory tombstone keys after the from-side directory scan. */
+ public void clearDirTombstoneKeys() {
+ dirTombstoneKeys.clear();
+ if (dirTombstoneKeysSpilled) {
+ dropAndClose(dirTombstoneKeysCf);
+ dirTombstoneKeysSpilled = false;
+ }
+ }
+
/** Records a deleted directory {@code objectId} for ancestor filtering. */
public void addDeletedDirectoryId(long objectId) throws IOException {
if (deletedDirectoryIdsSpilled) {
@@ -604,11 +665,11 @@ private ColumnFamilyHandle
classifiedColumnFamily(DiffType diffType) {
return cf;
}
- private void initColumnFamilies(ManagedColumnFamilyOptions options)
- throws RocksDBException {
+ private void initColumnFamilies() throws RocksDBException {
newListCf = createColumnFamily(this.jobId + NEW_LIST_SUFFIX);
oldListCf = createColumnFamily(this.jobId + OLD_LIST_SUFFIX);
diffCandCfName = this.jobId + CAND_IDS_SUFFIX;
+ dirTombstoneKeysCfName = this.jobId + DIR_TOMBSTONE_KEYS_SUFFIX;
deletedDirectoryIdsCfName = this.jobId + DELETED_DIR_IDS_SUFFIX;
renamedDirectoryIdsCfName = this.jobId + RENAMED_DIR_IDS_SUFFIX;
classifiedCreateCf = createColumnFamily(this.jobId +
CLASSIFIED_CREATE_SUFFIX);
@@ -636,6 +697,21 @@ void spillDiffCandidates() throws IOException {
diffCandidatesSpilled = true;
}
+ private void spillDirTombstoneKeys() throws IOException {
+ try {
+ dirTombstoneKeysCf = createColumnFamily(dirTombstoneKeysCfName);
+ } catch (RocksDBException e) {
+ throw new IOException("Failed to create directory tombstone key column
family "
+ + dirTombstoneKeysCfName, e);
+ }
+ for (byte[] tableKey : dirTombstoneKeys) {
+ batchPut(dirTombstoneKeysCf, tableKey, presentMarker);
+ }
+ dirTombstoneKeys.clear();
+ flushWrites();
+ dirTombstoneKeysSpilled = true;
+ }
+
private void spillDeletedDirectoryIds() throws IOException {
try {
deletedDirectoryIdsCf = createColumnFamily(deletedDirectoryIdsCfName);
@@ -691,7 +767,7 @@ private byte[] get(ColumnFamilyHandle cf, byte[] key)
throws IOException {
private ColumnFamilyHandle createColumnFamily(String name) throws
RocksDBException {
ColumnFamilyHandle handle = db.get().createColumnFamily(
- new ColumnFamilyDescriptor(StringUtils.string2Bytes(name),
familyOptions));
+ new ColumnFamilyDescriptor(StringUtils.string2Bytes(name),
tmpCfFamilyOptions));
temporaryColumnFamilies.add(handle);
return handle;
}
@@ -710,6 +786,7 @@ public void close() throws IOException {
while (!temporaryColumnFamilies.isEmpty()) {
dropAndClose(temporaryColumnFamilies.get(0));
}
+ tmpCfFamilyOptions.close();
}
private void closeQuietly() {
@@ -917,7 +994,7 @@ public final class ClassifiedIterator implements
AutoCloseable, Iterator<Map.Ent
private final ManagedRocksIterator iterator;
private Map.Entry<Long, byte[]> next;
- private ClassifiedIterator(ColumnFamilyHandle cf) throws
RocksDatabaseException {
+ private ClassifiedIterator(ColumnFamilyHandle cf) {
this.iterator = new ManagedRocksIterator(db.get().newIterator(cf));
iterator.get().seekToFirst();
advance();
@@ -960,7 +1037,7 @@ public final class DependencyNodeIterator implements
AutoCloseable,
private final ManagedRocksIterator iterator;
private SnapDiffDependencyEntry next;
- private DependencyNodeIterator(ColumnFamilyHandle cf) throws
RocksDatabaseException {
+ private DependencyNodeIterator(ColumnFamilyHandle cf) {
this.iterator = new ManagedRocksIterator(db.get().newIterator(cf));
iterator.get().seekToFirst();
advance();
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestDagDiffSequentialReader.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestDagDiffSequentialReader.java
new file mode 100644
index 00000000000..eec0dff069b
--- /dev/null
+++
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestDagDiffSequentialReader.java
@@ -0,0 +1,423 @@
+/*
+ * 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.snapshot.diff;
+
+import static
org.apache.hadoop.hdds.utils.db.DBStoreBuilder.DEFAULT_COLUMN_FAMILY_NAME;
+import static
org.apache.hadoop.hdds.utils.db.managed.ManagedColumnFamilyOptions.closeDeeply;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.DIRECTORY_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.KEY_TABLE;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.hadoop.hdds.StringUtils;
+import org.apache.hadoop.hdds.client.RatisReplicationConfig;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor;
+import org.apache.hadoop.hdds.utils.db.CodecRegistry;
+import org.apache.hadoop.hdds.utils.db.InMemoryTestTable;
+import org.apache.hadoop.hdds.utils.db.LatestVersionedKWayMergeIterator;
+import
org.apache.hadoop.hdds.utils.db.LatestVersionedKWayMergeIterator.MergedKeyValue;
+import org.apache.hadoop.hdds.utils.db.Table;
+import org.apache.hadoop.hdds.utils.db.managed.ManagedBlockBasedTableConfig;
+import org.apache.hadoop.hdds.utils.db.managed.ManagedBloomFilter;
+import org.apache.hadoop.hdds.utils.db.managed.ManagedColumnFamilyOptions;
+import org.apache.hadoop.hdds.utils.db.managed.ManagedDBOptions;
+import org.apache.hadoop.hdds.utils.db.managed.ManagedLRUCache;
+import org.apache.hadoop.hdds.utils.db.managed.ManagedRocksDB;
+import org.apache.hadoop.ozone.om.helpers.OmDirectoryInfo;
+import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
+import org.apache.hadoop.ozone.util.ClosableIterator;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import org.rocksdb.ColumnFamilyDescriptor;
+import org.rocksdb.ColumnFamilyHandle;
+import org.rocksdb.RocksDBException;
+
+/**
+ * Tests the DAG-diff Stage 1 multi-stage sequential read (HDDS-15393).
+ */
+class TestDagDiffSequentialReader {
+
+ private static final String VOLUME = "vol";
+ private static final String BUCKET = "buck";
+ private static final long BUCKET_OBJECT_ID = 1L;
+
+ @TempDir
+ private static File tempDir;
+ private static ManagedRocksDB db;
+ private static ManagedDBOptions dbOptions;
+ private static ManagedColumnFamilyOptions columnFamilyOptions;
+ private static CodecRegistry codecRegistry;
+ private static ColumnFamilyHandle snapDiffReportCfh;
+ private static final AtomicInteger JOB_ID = new AtomicInteger(0);
+
+ @BeforeAll
+ static void init() throws RocksDBException {
+ dbOptions = new ManagedDBOptions();
+ dbOptions.setCreateIfMissing(true);
+ columnFamilyOptions = new ManagedColumnFamilyOptions();
+ codecRegistry = CodecRegistry.newBuilder().build();
+
+ File dbDir = new File(tempDir, "dag-diff-stage1.db");
+ List<ColumnFamilyDescriptor> descriptors = Collections.singletonList(
+ new
ColumnFamilyDescriptor(StringUtils.string2Bytes(DEFAULT_COLUMN_FAMILY_NAME),
columnFamilyOptions));
+ List<ColumnFamilyHandle> handles = new ArrayList<>();
+ db = ManagedRocksDB.open(dbOptions, dbDir.getAbsolutePath(), descriptors,
handles);
+ snapDiffReportCfh = db.get().createColumnFamily(
+ new
ColumnFamilyDescriptor(StringUtils.string2Bytes("snap-diff-report"),
columnFamilyOptions));
+ }
+
+ @AfterAll
+ static void teardown() {
+ if (db != null) {
+ db.close();
+ }
+ if (columnFamilyOptions != null) {
+ columnFamilyOptions.close();
+ }
+ if (dbOptions != null) {
+ dbOptions.close();
+ }
+ }
+
+ /**
+ * {@link SnapDiffJobStore#open} copies caller {@link
ManagedColumnFamilyOptions} for temp CFs.
+ * Closing the store closes only the copy's native handle, not the shared
table-format resources
+ * owned by the caller (as {@link
org.apache.hadoop.ozone.om.snapshot.SnapshotDiffManager} will).
+ */
+ @Test
+ void callerOwnedTableConfigRemainsOpenAfterJobStoreClose() throws
IOException {
+ ManagedLRUCache callerBlockCache = new ManagedLRUCache(16 * 1024 * 1024);
+ ManagedBloomFilter callerBloomFilter = new ManagedBloomFilter();
+ ManagedBlockBasedTableConfig callerTableConfig = new
ManagedBlockBasedTableConfig();
+ callerTableConfig.setBlockCache(callerBlockCache)
+ .setFormatVersion(ManagedBlockBasedTableConfig.FORMAT_VERSION)
+ .setFilterPolicy(callerBloomFilter);
+ ManagedColumnFamilyOptions callerFamilyOptions = new
ManagedColumnFamilyOptions();
+ callerFamilyOptions.setTableFormatConfig(callerTableConfig);
+ try {
+
+ SnapDiffJobStore store = SnapDiffJobStore.open(db, codecRegistry,
callerFamilyOptions,
+ "job" + JOB_ID.incrementAndGet(), false, snapDiffReportCfh, null,
null);
+ ManagedColumnFamilyOptions copiedFamilyOptions =
store.getCopiedCfFamilyOptions();
+
+ assertSame(callerTableConfig, copiedFamilyOptions.tableFormatConfig());
+ assertTrue(callerFamilyOptions.isOwningHandle(),
+ "caller column family options native handle must be open");
+ assertTrue(copiedFamilyOptions.isOwningHandle(),
+ "copied column family options native handle must be open");
+ assertTableFormatResourcesOpen(callerTableConfig, callerBlockCache,
callerBloomFilter);
+
+ store.close();
+
+ assertFalse(copiedFamilyOptions.isOwningHandle(),
+ "copied column family options native handle must be closed");
+ assertTrue(callerFamilyOptions.isOwningHandle(),
+ "caller column family options native handle must be open");
+ assertTableFormatResourcesOpen(callerTableConfig, callerBlockCache,
callerBloomFilter);
+ } finally {
+ closeDeeply(callerFamilyOptions);
+ }
+ }
+
+ @Test
+ void testKeyDiffShapes() throws Exception {
+ long gate = 50L;
+ byte[] modifyKey = userKey("modify");
+ byte[] oldNameKey = userKey("oldname");
+ byte[] newNameKey = userKey("newname");
+ byte[] deletedKey = userKey("deleted");
+
+ byte[] modifyFrom = keyBytes("modify", 2L, 0L, 100L);
+ byte[] modifyTo = keyBytes("modify", 2L, 0L, 200L);
+ byte[] oldRename = keyBytes("oldname", 3L, 0L, 100L);
+ byte[] newRename = keyBytes("newname", 3L, 0L, 100L);
+ byte[] deletedFrom = keyBytes("deleted", 4L, 0L, 100L);
+
+ List<MergedKeyValue> delta = Arrays.asList(
+ toMergedKV(modifyKey, 70L, 1, modifyTo),
+ toMergedKV(oldNameKey, 70L, 0, null),
+ toMergedKV(newNameKey, 80L, 1, newRename),
+ toMergedKV(deletedKey, 70L, 0, null),
+ toMergedKV(userKey("create"), 80L, 1, keyBytes("create", 1L, 0L,
100L)));
+
+ DirectoryTables directoryTables =
directoryTables(InMemoryTestTable.forRawBytes(DIRECTORY_TABLE),
+ InMemoryTestTable.forRawBytes(DIRECTORY_TABLE));
+
+ try (SnapDiffJobStore store = newStore(false)) {
+ runReader(store, false, gate, delta, Collections.emptyList(),
+ rawFileTable(modifyKey, modifyFrom, oldNameKey, oldRename,
deletedKey, deletedFrom),
+ directoryTables);
+
+ assertNotNull(store.getNewList(1L)); // CREATE
+ assertNotNull(store.getNewList(2L)); // MODIFY
+ assertNotNull(store.getNewList(3L)); // RENAME target
+ assertNull(store.getNewList(4L)); // DELETE tombstone only
+
+ assertNull(store.getOldList(1L)); // CREATE has no from entry
+ assertNotNull(store.getOldList(2L));
+ assertNotNull(store.getOldList(3L));
+ assertNotNull(store.getOldList(4L));
+ assertEquals(0, store.getDiffCandidateCount());
+
+ EntryValue newRenameVal = EntryValue.fromBytes(store.getNewList(3L));
+ EntryValue oldRenameVal = EntryValue.fromBytes(store.getOldList(3L));
+ assertEquals("newname", newRenameVal.getName());
+ assertEquals("oldname", oldRenameVal.getName());
+ assertArrayEquals(newRenameVal.getSignature(),
oldRenameVal.getSignature());
+
+ EntryValue newModify = EntryValue.fromBytes(store.getNewList(2L));
+ EntryValue oldModify = EntryValue.fromBytes(store.getOldList(2L));
+ assertFalse(Arrays.equals(newModify.getSignature(),
oldModify.getSignature()));
+ }
+ }
+
+ @Test
+ void testDirectoryDiffShapes() throws Exception {
+ long gate = 50L;
+ byte[] createKey = userKey("create");
+ byte[] modifyKey = userKey("modify");
+ byte[] oldNameKey = userKey("oldname");
+ byte[] newNameKey = userKey("newname");
+ byte[] deletedKey = userKey("deleted");
+
+ byte[] createTo = dirBytes("create", 1L, BUCKET_OBJECT_ID);
+ byte[] modifyFrom = dirBytes("modify", 2L, BUCKET_OBJECT_ID,
metadata("ver", "from"));
+ byte[] modifyTo = dirBytes("modify", 2L, BUCKET_OBJECT_ID, metadata("ver",
"to"));
+ byte[] oldRename = dirBytes("oldname", 3L, BUCKET_OBJECT_ID);
+ byte[] newRename = dirBytes("newname", 3L, BUCKET_OBJECT_ID);
+ byte[] deletedFrom = dirBytes("deleted", 4L, BUCKET_OBJECT_ID);
+
+ List<MergedKeyValue> dirDelta = Arrays.asList(
+ toMergedKV(modifyKey, 70L, 1, modifyTo),
+ toMergedKV(oldNameKey, 70L, 0, null),
+ toMergedKV(newNameKey, 80L, 1, newRename),
+ toMergedKV(deletedKey, 70L, 0, null),
+ toMergedKV(createKey, 80L, 1, createTo));
+
+ DirectoryTables dirTables = directoryTables(
+ rawDirectoryTable(modifyKey, modifyFrom, oldNameKey, oldRename,
deletedKey, deletedFrom),
+ rawDirectoryTable(createKey, createTo, modifyKey, modifyTo,
newNameKey, newRename));
+
+ try (SnapDiffJobStore store = newStore(true)) {
+ runReader(store, true, gate, Collections.emptyList(), dirDelta,
rawFileTable(), dirTables);
+
+ assertNotNull(store.getNewList(1L)); // CREATE
+ assertNotNull(store.getNewList(2L)); // MODIFY
+ assertNotNull(store.getNewList(3L)); // RENAME target
+ assertNull(store.getNewList(4L)); // DELETE tombstone only
+
+ assertNull(store.getOldList(1L)); // CREATE has no from entry
+ assertNotNull(store.getOldList(2L));
+ assertNotNull(store.getOldList(3L));
+ assertNotNull(store.getOldList(4L));
+ assertEquals(0, store.getDiffCandidateCount());
+
+ EntryValue createVal = EntryValue.fromBytes(store.getNewList(1L));
+ assertTrue(createVal.isDir());
+ assertEquals("create", createVal.getName());
+ assertEquals(BUCKET_OBJECT_ID, createVal.getParentId());
+
+ EntryValue newRenameVal = EntryValue.fromBytes(store.getNewList(3L));
+ EntryValue oldRenameVal = EntryValue.fromBytes(store.getOldList(3L));
+ assertTrue(newRenameVal.isDir());
+ assertTrue(oldRenameVal.isDir());
+ assertEquals("newname", newRenameVal.getName());
+ assertEquals("oldname", oldRenameVal.getName());
+ assertArrayEquals(newRenameVal.getSignature(),
oldRenameVal.getSignature());
+
+ EntryValue newModify = EntryValue.fromBytes(store.getNewList(2L));
+ EntryValue oldModify = EntryValue.fromBytes(store.getOldList(2L));
+ assertFalse(Arrays.equals(newModify.getSignature(),
oldModify.getSignature()));
+
+ assertFromEdge(store, 1L, null, null);
+ assertFromEdge(store, 2L, BUCKET_OBJECT_ID, "modify");
+ assertFromEdge(store, 3L, BUCKET_OBJECT_ID, "oldname");
+ assertFromEdge(store, 4L, BUCKET_OBJECT_ID, "deleted");
+
+ assertToEdge(store, 1L, BUCKET_OBJECT_ID, "create");
+ assertToEdge(store, 2L, BUCKET_OBJECT_ID, "modify");
+ assertToEdge(store, 3L, BUCKET_OBJECT_ID, "newname");
+ assertToEdge(store, 4L, null, null);
+ }
+ }
+
+ private static void assertFromEdge(SnapDiffJobStore store, long objectId,
Long parentId, String name)
+ throws IOException {
+
assertEdge(store.multiGetFromEdgeValues(Collections.singletonList(objectId)).get(0),
parentId, name);
+ }
+
+ private static void assertToEdge(SnapDiffJobStore store, long objectId, Long
parentId, String name)
+ throws IOException {
+
assertEdge(store.multiGetToEdgeValues(Collections.singletonList(objectId)).get(0),
parentId, name);
+ }
+
+ private static void assertEdge(byte[] value, Long parentId, String name) {
+ if (parentId == null) {
+ assertNull(value);
+ return;
+ }
+ assertNotNull(value);
+ assertEquals(parentId.longValue(),
SnapDiffJobStore.decodeEdgeLinkParentId(value));
+ if (name != null) {
+ assertEquals(name, SnapDiffJobStore.decodeEdgeLinkName(value));
+ }
+ }
+
+ private static SnapDiffJobStore newStore(boolean fso) throws IOException {
+ return SnapDiffJobStore.open(db, codecRegistry, columnFamilyOptions,
+ "job" + JOB_ID.incrementAndGet(), fso, snapDiffReportCfh, null, null);
+ }
+
+ private static void runReader(SnapDiffJobStore store, boolean fso, long gate,
+ List<MergedKeyValue> fileDelta,
+ List<MergedKeyValue> dirDelta,
+ Table<byte[], byte[]> fromFileTable,
+ DirectoryTables directoryTables) throws Exception {
+ DagDiffSequentialReader reader = new DagDiffSequentialReader(store, gate);
+ if (!fileDelta.isEmpty()) {
+ reader.scanFileTablesFromDelta(mergeIterator(fileDelta, gate),
fromFileTable);
+ }
+ if (fso && !dirDelta.isEmpty()) {
+ reader.scanDirectoryTablesFromDelta(mergeIterator(dirDelta, gate), null,
+ directoryTables.fromTable, directoryTables.toTable);
+ }
+ }
+
+ private static LatestVersionedKWayMergeIterator
mergeIterator(List<MergedKeyValue> entries, long gate) {
+ ClosableIterator<MergedKeyValue> source = new
ClosableIterator<MergedKeyValue>() {
+ private final Iterator<MergedKeyValue> delegate = entries.iterator();
+
+ @Override
+ public boolean hasNext() {
+ return delegate.hasNext();
+ }
+
+ @Override
+ public MergedKeyValue next() {
+ return delegate.next();
+ }
+
+ @Override
+ public void close() {
+ // no-op
+ }
+ };
+ return
LatestVersionedKWayMergeIterator.forTest(Collections.singletonList(source),
gate);
+ }
+
+ private static Table<byte[], byte[]> rawFileTable(byte[]... keyValuePairs) {
+ InMemoryTestTable<byte[], byte[]> table =
InMemoryTestTable.forRawBytes(KEY_TABLE);
+ for (int i = 0; i < keyValuePairs.length; i += 2) {
+ table.put(keyValuePairs[i], keyValuePairs[i + 1]);
+ }
+ return table;
+ }
+
+ private static DirectoryTables directoryTables(Table<byte[], byte[]>
fromTable,
+ Table<byte[], byte[]> toTable) {
+ return new DirectoryTables(fromTable, toTable);
+ }
+
+ private static Table<byte[], byte[]> rawDirectoryTable(byte[]...
keyValuePairs) {
+ InMemoryTestTable<byte[], byte[]> table =
InMemoryTestTable.forRawBytes(DIRECTORY_TABLE);
+ for (int i = 0; i < keyValuePairs.length; i += 2) {
+ table.put(keyValuePairs[i], keyValuePairs[i + 1]);
+ }
+ return table;
+ }
+
+ private static MergedKeyValue toMergedKV(byte[] key, long sequence, int
type, byte[] value) {
+ return MergedKeyValue.of(key, sequence, type, value);
+ }
+
+ private static byte[] userKey(String name) {
+ return name.getBytes(StandardCharsets.UTF_8);
+ }
+
+ private static byte[] keyBytes(String keyName, long objectId, long parentId,
long dataSize) throws Exception {
+ OmKeyInfo keyInfo = new OmKeyInfo.Builder()
+ .setVolumeName(VOLUME)
+ .setBucketName(BUCKET)
+ .setKeyName(keyName)
+
.setReplicationConfig(RatisReplicationConfig.getInstance(ReplicationFactor.ONE))
+ .setObjectID(objectId)
+ .setParentObjectID(parentId)
+ .setUpdateID(10L)
+ .setDataSize(dataSize)
+ .build();
+ return OmKeyInfo.getKeyTableCodec().toPersistedFormat(keyInfo);
+ }
+
+ private static byte[] dirBytes(String name, long objectId, long parentId)
throws Exception {
+ return dirBytes(name, objectId, parentId, Collections.emptyMap());
+ }
+
+ private static byte[] dirBytes(String name, long objectId, long parentId,
Map<String, String> metadata)
+ throws Exception {
+ OmDirectoryInfo.Builder builder = OmDirectoryInfo.newBuilder()
+ .setName(name)
+ .setObjectID(objectId)
+ .setParentObjectID(parentId)
+ .setUpdateID(10L);
+ if (!metadata.isEmpty()) {
+ builder.addAllMetadata(metadata);
+ }
+ return OmDirectoryInfo.getCodec().toPersistedFormat(builder.build());
+ }
+
+ private static Map<String, String> metadata(String key, String value) {
+ Map<String, String> metadata = new LinkedHashMap<>();
+ metadata.put(key, value);
+ return metadata;
+ }
+
+ private static void
assertTableFormatResourcesOpen(ManagedBlockBasedTableConfig tableConfig,
+ ManagedLRUCache blockCache, ManagedBloomFilter bloomFilter) {
+ assertFalse(tableConfig.isClosed(), "table format config must stay open");
+ assertTrue(blockCache.isOwningHandle(), "block cache native handle must be
open");
+ assertTrue(bloomFilter.isOwningHandle(), "bloom filter native handle must
be open");
+ }
+
+ private static final class DirectoryTables {
+ private final Table<byte[], byte[]> fromTable;
+ private final Table<byte[], byte[]> toTable;
+
+ private DirectoryTables(Table<byte[], byte[]> fromTable, Table<byte[],
byte[]> toTable) {
+ this.fromTable = fromTable;
+ this.toTable = toTable;
+ }
+ }
+}
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestFullDiffSequentialReader.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestFullDiffSequentialReader.java
index 03bb2de1f46..db0005c51f5 100644
---
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestFullDiffSequentialReader.java
+++
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestFullDiffSequentialReader.java
@@ -224,7 +224,7 @@ void testDiffCandidatesSpillToRocksDb() throws Exception {
putKey(fromTable, "k3", keyInfo("c", 3L, 0L, 10L, 100L));
SnapDiffJobStore store = spy(SnapDiffJobStore.open(db, codecRegistry,
columnFamilyOptions,
- "job" + JOB_ID.incrementAndGet(), false, snapDiffReportCfh, null, 2L));
+ "job" + JOB_ID.incrementAndGet(), false, snapDiffReportCfh, null, 2));
try (SnapDiffJobStore ignored = store) {
doAnswer(invocation ->
invocation.callRealMethod()).when(store).spillDiffCandidates();
doAnswer(invocation -> {
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestMergeJoinSnapDiffWriter.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestMergeJoinSnapDiffWriter.java
index b029f7761bd..c75a84e35b4 100644
---
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestMergeJoinSnapDiffWriter.java
+++
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestMergeJoinSnapDiffWriter.java
@@ -295,7 +295,7 @@ void testDependencyOrderingUsesBatchedReportLookup() throws
Exception {
@Test
void testDependencyOrderingFallsBackWhenOverLimit() throws Exception {
byte[] sig = signature("s");
- SnapDiffJobStore store = spy(newStore(true, 1L));
+ SnapDiffJobStore store = spy(newStore(true, 1));
try (SnapDiffJobStore ignored = store) {
store.putToEdge(BUCKET_OBJECT_ID, 200L, nameBytes("parent"));
store.putNewList(201L, entry(200L, "child1", false, sig));
@@ -340,10 +340,10 @@ private static SnapshotDiffManager
mockManagerWithRealDeleteRetention() throws E
}
private static SnapDiffJobStore newStore(boolean fso) throws IOException {
- return newStore(fso, 1_000_000L);
+ return newStore(fso, 1_000_000);
}
- private static SnapDiffJobStore newStore(boolean fso, long
maxInMemoryEntries) throws IOException {
+ private static SnapDiffJobStore newStore(boolean fso, int
maxInMemoryEntries) throws IOException {
return SnapDiffJobStore.open(db, codecRegistry, columnFamilyOptions,
jobName(), fso, snapDiffReportCfh, null, maxInMemoryEntries);
}
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestSnapDiffPathResolver.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestSnapDiffPathResolver.java
index c670e8e0c45..c28724e3772 100644
---
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestSnapDiffPathResolver.java
+++
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestSnapDiffPathResolver.java
@@ -166,7 +166,7 @@ void testBrokenChainReturnsNull() throws Exception {
@Test
void testBatchResolveSurvivesLruEvictionWithinBatch() throws Exception {
- try (SnapDiffJobStore store = newStoreWithPathCacheCapacity(2L)) {
+ try (SnapDiffJobStore store = newStoreWithPathCacheCapacity(2)) {
putFromEdge(store, BUCKET_OBJECT_ID, 10L, "dir");
putFromEdge(store, 10L, 11L, "a");
putFromEdge(store, 10L, 12L, "b");
@@ -213,7 +213,7 @@ private static SnapDiffJobStore newStore() throws
IOException {
return newStoreWithPathCacheCapacity(null);
}
- private static SnapDiffJobStore newStoreWithPathCacheCapacity(Long
maxInMemoryEntries)
+ private static SnapDiffJobStore newStoreWithPathCacheCapacity(Integer
maxInMemoryEntries)
throws IOException {
return SnapDiffJobStore.open(db, codecRegistry, columnFamilyOptions,
"path-resolver-" + JOB_ID.incrementAndGet(), true, snapDiffReportCfh,
null,
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]