Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify EventListenerTest.java
Browse files Browse the repository at this point in the history
mszeszko-meta committed Jan 24, 2025
1 parent 9bdb1f8 commit 9ea1079
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions java/src/test/java/org/rocksdb/EventListenerTest.java
Original file line number Diff line number Diff line change
@@ -78,16 +78,10 @@ void deleteTableFile(final AbstractEventListener el, final AtomicBoolean wasCbCa
final int KEY_SIZE = 20;
final int VALUE_SIZE = 1000;
final int FILE_SIZE = 64000;
final int NUM_FILES = 10;

final int NUM_FILES = 2;
final int KEY_INTERVAL = 10000;
/*
* Intention of these options is to end up reliably with 10 files
* we will be deleting using deleteFilesInRange.
* It is writing roughly number of keys that will fit in 10 files (target size)
* It is writing interleaved so that files from memory on L0 will overlap
* Then compaction cleans everything, and we should end up with 10 files
*/
final int records = FILE_SIZE / (KEY_SIZE + VALUE_SIZE);
final FlushOptions flushOptions = new FlushOptions().setWaitForFlush(true);
try (final Options opt = new Options()
.setCreateIfMissing(true)
.setListeners(Collections.singletonList(el))
@@ -97,9 +91,6 @@ void deleteTableFile(final AbstractEventListener el, final AtomicBoolean wasCbCa
.setDisableAutoCompactions(true)
.setLevelCompactionDynamicLevelBytes(false);
final RocksDB db = RocksDB.open(opt, dbFolder.getRoot().getAbsolutePath())) {
final int records = FILE_SIZE / (KEY_SIZE + VALUE_SIZE);

// fill database with key/value pairs
final byte[] value = new byte[VALUE_SIZE];
int key_init = 0;
for (int o = 0; o < NUM_FILES; ++o) {
@@ -110,11 +101,10 @@ void deleteTableFile(final AbstractEventListener el, final AtomicBoolean wasCbCa

db.put(String.format("%020d", int_key).getBytes(), value);
}
}
try (final FlushOptions flushOptions = new FlushOptions().setWaitForFlush(true)) {
// Produce NUM_FILES files - all with the same contents.
db.flush(flushOptions);
int_key = 0;
}
db.compactRange();
db.deleteFilesInRanges(null, Arrays.asList(null, null), false /* includeEnd */);
}
assertThat(wasCbCalled.get()).isTrue();

0 comments on commit 9ea1079

Please sign in to comment.