Skip to content

Commit

Permalink
Update rocksdb to 8.10.2, fix bug in near keys
Browse files Browse the repository at this point in the history
  • Loading branch information
fireduck64 committed Feb 28, 2024
1 parent 2b9fe0c commit bfa5614
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 4 additions & 5 deletions lib/src/db/rocksdb/JRocksDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions lib/src/db/rocksdb/RocksDBMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,17 @@ public List<ByteString> getClosestKeys(ByteString key, int count)
try(RocksIterator it = db.newIterator())
{
it.seek(key_str.toByteArray());

// Empty set, doomed
if (!it.isValid()) return lst;

for(int i=0; i<count; i++)
{
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<count; i++)
{
Expand Down Expand Up @@ -155,7 +155,7 @@ public Map<ByteString, ByteString> 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++;

Expand Down
4 changes: 2 additions & 2 deletions lib/src/db/rocksdb/RocksDBMapMutationSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/db/rocksdb/TrieDBRocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void save(TrieNode node)
{
throw new RuntimeException(e);
}

}
public TrieNode load(ByteString key)
{
Expand All @@ -71,7 +71,7 @@ public void bulkSave(TreeMap<ByteString, TrieNode> updates)
try
{
WriteBatch wb = new WriteBatch();

for(Map.Entry<ByteString, TrieNode> me : updates.entrySet())
{
ByteString key = me.getKey();
Expand Down
16 changes: 8 additions & 8 deletions maven_install.json
Original file line number Diff line number Diff line change
@@ -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"
},
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit bfa5614

Please sign in to comment.