From bfa5614184a74a8d205ca0be563a97479c0dbc9b Mon Sep 17 00:00:00 2001 From: fireduck64 Date: Tue, 27 Feb 2024 22:49:33 -0800 Subject: [PATCH] Update rocksdb to 8.10.2, fix bug in near keys --- WORKSPACE | 2 +- lib/src/db/rocksdb/JRocksDB.java | 9 ++++----- lib/src/db/rocksdb/RocksDBMap.java | 8 ++++---- lib/src/db/rocksdb/RocksDBMapMutationSet.java | 4 ++-- lib/src/db/rocksdb/TrieDBRocks.java | 4 ++-- maven_install.json | 16 ++++++++-------- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index a0941ca7..4ecde6dd 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -44,7 +44,7 @@ git_repository( maven_install( artifacts = [ "com.google.protobuf:protobuf-java:3.5.1", - "org.rocksdb:rocksdbjni:8.9.1", + "org.rocksdb:rocksdbjni:8.10.2", "junit:junit:4.12", "commons-codec:commons-codec:1.11", "org.apache.commons:commons-math3:3.6.1", diff --git a/lib/src/db/rocksdb/JRocksDB.java b/lib/src/db/rocksdb/JRocksDB.java index 2990280d..380bcd0c 100644 --- a/lib/src/db/rocksdb/JRocksDB.java +++ b/lib/src/db/rocksdb/JRocksDB.java @@ -2,10 +2,9 @@ import com.google.common.collect.ImmutableList; import duckutil.Config; -import duckutil.PeriodicThread; import java.io.File; -import java.util.TreeMap; import java.util.List; +import java.util.TreeMap; import java.util.logging.Level; import java.util.logging.Logger; import org.rocksdb.FlushOptions; @@ -36,9 +35,9 @@ public JRocksDB(Config config) super(config); use_separate_dbs=config.getBoolean("db_separate"); - + config.require("db_path"); - + String path = config.get("db_path"); base_path = new File(path); @@ -56,7 +55,7 @@ public JRocksDB(Config config) // Separate DBs should only be used when you don't care about syncing between // the databases, If you are fine with writes to them being preserved out of order // relative to each other it should be fine. - // For example, in combined DBs if you write a to A then b to B, you will either get {}, {a}, or {a,b} + // For example, in combined DBs if you write a to A then b to B, you will either get {}, {a}, or {a,b} // on a bad shutdown. If you use separate, you could very well get {b}. if (use_separate_dbs) diff --git a/lib/src/db/rocksdb/RocksDBMap.java b/lib/src/db/rocksdb/RocksDBMap.java index d3ee6940..ffeb7c20 100644 --- a/lib/src/db/rocksdb/RocksDBMap.java +++ b/lib/src/db/rocksdb/RocksDBMap.java @@ -106,7 +106,7 @@ public List getClosestKeys(ByteString key, int count) try(RocksIterator it = db.newIterator()) { it.seek(key_str.toByteArray()); - + // Empty set, doomed if (!it.isValid()) return lst; @@ -114,9 +114,9 @@ public List getClosestKeys(ByteString key, int count) { lst.add(ByteString.copyFrom(it.key()).substring(prefix.size())); it.next(); - if (it.isValid()) it.seekToFirst(); //wrap around + if (!it.isValid()) it.seekToFirst(); //wrap around } - + it.seek(key_str.toByteArray()); for(int i=0; i getByPrefix(ByteString key, int max_reply, bo if (!curr_key.startsWith(key_str)) break; ByteString k = curr_key.substring(prefix.size()); - + map.put(k, ByteString.copyFrom(it.value())); count++; diff --git a/lib/src/db/rocksdb/RocksDBMapMutationSet.java b/lib/src/db/rocksdb/RocksDBMapMutationSet.java index c9c7402d..0e3fdc19 100644 --- a/lib/src/db/rocksdb/RocksDBMapMutationSet.java +++ b/lib/src/db/rocksdb/RocksDBMapMutationSet.java @@ -34,7 +34,7 @@ private ByteString getDBKey(ByteString key, ByteString value) ByteString.Output out = ByteString.newOutput(100); out.write(name_bytes); out.write(key.toByteArray()); - out.write(sep); + out.write(sep); out.write(value.toByteArray()); ByteString w = out.toByteString(); return w; @@ -68,7 +68,7 @@ public void add(ByteString key, ByteString value) byte b[]=new byte[0]; ByteString w = getDBKey(key, value); - + try { db.put(jdb.getWriteOption(), w.toByteArray(), b); diff --git a/lib/src/db/rocksdb/TrieDBRocks.java b/lib/src/db/rocksdb/TrieDBRocks.java index 1a3e9b9d..3c5cc684 100644 --- a/lib/src/db/rocksdb/TrieDBRocks.java +++ b/lib/src/db/rocksdb/TrieDBRocks.java @@ -45,7 +45,7 @@ public void save(TrieNode node) { throw new RuntimeException(e); } - + } public TrieNode load(ByteString key) { @@ -71,7 +71,7 @@ public void bulkSave(TreeMap updates) try { WriteBatch wb = new WriteBatch(); - + for(Map.Entry me : updates.entrySet()) { ByteString key = me.getKey(); diff --git a/maven_install.json b/maven_install.json index 6575b3e8..202f4045 100644 --- a/maven_install.json +++ b/maven_install.json @@ -1,8 +1,8 @@ { "dependency_tree": { "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", - "__INPUT_ARTIFACTS_HASH": 402877155, - "__RESOLVED_ARTIFACTS_HASH": 120048851, + "__INPUT_ARTIFACTS_HASH": -1578023204, + "__RESOLVED_ARTIFACTS_HASH": -1851281014, "conflict_resolution": { "com.google.protobuf:protobuf-java:3.5.1": "com.google.protobuf:protobuf-java:3.6.1" }, @@ -472,16 +472,16 @@ "url": "https://repo1.maven.org/maven2/org/ow2/asm/asm/9.1/asm-9.1.jar" }, { - "coord": "org.rocksdb:rocksdbjni:8.9.1", + "coord": "org.rocksdb:rocksdbjni:8.10.2", "dependencies": [], "directDependencies": [], - "file": "v1/https/repo1.maven.org/maven2/org/rocksdb/rocksdbjni/8.9.1/rocksdbjni-8.9.1.jar", + "file": "v1/https/repo1.maven.org/maven2/org/rocksdb/rocksdbjni/8.10.2/rocksdbjni-8.10.2.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/org/rocksdb/rocksdbjni/8.9.1/rocksdbjni-8.9.1.jar", - "https://maven.google.com/org/rocksdb/rocksdbjni/8.9.1/rocksdbjni-8.9.1.jar" + "https://repo1.maven.org/maven2/org/rocksdb/rocksdbjni/8.10.2/rocksdbjni-8.10.2.jar", + "https://maven.google.com/org/rocksdb/rocksdbjni/8.10.2/rocksdbjni-8.10.2.jar" ], - "sha256": "b43284df61c6cd8aa88b061807684a2e8d3bf4aad67ecbb0cacefb49646c20c9", - "url": "https://repo1.maven.org/maven2/org/rocksdb/rocksdbjni/8.9.1/rocksdbjni-8.9.1.jar" + "sha256": "a59c02c628dd3bec82de027c7e6edb5b11c1c09c251a85325c7f5ff081948133", + "url": "https://repo1.maven.org/maven2/org/rocksdb/rocksdbjni/8.10.2/rocksdbjni-8.10.2.jar" }, { "coord": "org.slf4j:slf4j-api:1.7.30",