-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abstract merge operator in Java + Thread JNI attachment automatic management + loader management for static variables #3432
Open
publicocean0
wants to merge
14
commits into
facebook:main
Choose a base branch
from
publicocean0:abstractMergeOperator
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5ea5bc0
fix std::unique_ptr<char[]>
publicocean0 c2e588f
first attempt to merge transactions api
publicocean0 dde032a
include transaction_db
publicocean0 8f1e628
fix transactions
publicocean0 6e73f37
associative /not asociative merge operator + automatic detaching thre…
publicocean0 6e0c351
associative /not asociative merge operator + automatic detaching thre…
publicocean0 093450e
remove debug folder in commit
publicocean0 ea6c238
fix: adding RocksdbException in the java signature
publicocean0 8fe4788
fix signature in AbstractNotAssociativeMergeOperator
publicocean0 b36b334
fix jni_vm_unload: it is not called, changed strategy. Improved abstr…
publicocean0 b63a0e4
remove std::cout
publicocean0 1cecf71
splitted pull request with java transactions from this pull request.S…
publicocean0 4e14bc7
Fix compilation problems
adamretter 4cb8946
Start of fixing code
adamretter File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ make_config.mk | |
CMakeCache.txt | ||
CMakeFiles/ | ||
build/ | ||
|
||
cmake-build-debug/ | ||
ldb | ||
manifest_dump | ||
sst_dump | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,7 +224,7 @@ public byte[] merge(byte[] key, byte[] oldvalue, byte[] newvalue) { | |
sb.append(','); | ||
//if (1==1)throw new IndexOutOfBoundsException(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove debug / commented lines in this file |
||
sb.append(new String(newvalue)); | ||
System.out.println("----execute merge---"); | ||
System.out.println("----execute merge---"+new String(newvalue)); | ||
return sb.toString().getBytes(); | ||
} | ||
} | ||
|
@@ -233,7 +233,7 @@ private class M1 extends AbstractNotAssociativeMergeOperator{ | |
|
||
|
||
public M1() throws RocksDBException { | ||
super(true,false,false); | ||
super(true,true,false); | ||
} | ||
|
||
private byte[] collect(byte[][] operands){ | ||
|
@@ -250,32 +250,36 @@ private byte[] collect(byte[][] operands){ | |
|
||
@Override | ||
public byte[] fullMerge(byte[] key, byte[] oldvalue, byte[][] operands) throws RocksDBException { | ||
System.out.println("execute fullMerge"+oldvalue); | ||
if (oldvalue==null) return collect(operands); | ||
|
||
return (new String(oldvalue)+','+new String(collect(operands))).getBytes(); | ||
} | ||
|
||
@Override | ||
public byte[] partialMultiMerge(byte[] key, byte[] oldvalue, byte[][] operands) { | ||
if (oldvalue==null) return collect(operands); | ||
public byte[] partialMultiMerge(byte[] key, byte[][] operands) { | ||
System.out.println("execute partialMultiMerge"); | ||
|
||
return (new String(oldvalue)+','+new String(collect(operands))).getBytes(); | ||
|
||
return (new String(collect(operands))).getBytes(); | ||
|
||
} | ||
|
||
@Override | ||
public byte[] partialMerge(byte[] key, byte[] left, byte[] right) { | ||
|
||
System.out.println("execute partialMerge"); | ||
StringBuffer sb=new StringBuffer(new String(left)); | ||
sb.append(','); | ||
sb.append(new String(right)); | ||
System.out.println("----execute merge---"); | ||
|
||
return sb.toString().getBytes(); | ||
} | ||
|
||
@Override | ||
public boolean shouldMerge(byte[][] operands) { | ||
return false; | ||
System.out.println("execute shouldMerge"); | ||
|
||
return true; | ||
} | ||
} | ||
|
||
|
@@ -298,19 +302,17 @@ public void run() { | |
|
||
|
||
db.put("key1".getBytes(), "value".getBytes()); | ||
assertThat(db.get("key1".getBytes())).isEqualTo( | ||
"value".getBytes()); | ||
assertThat(db.get("key1".getBytes())).isEqualTo("value".getBytes()); | ||
// merge key1 with another value portion | ||
db.merge("key1".getBytes(), "value2".getBytes()); | ||
assertThat(db.get("key1".getBytes())).isEqualTo( | ||
"value,value2".getBytes()); | ||
System.out.println(new String(db.get("key1".getBytes()))); | ||
// assertThat(db.get("key1".getBytes())).isEqualTo("value,value2".getBytes()); | ||
// merge key1 with another value portion | ||
db.merge(wOpt, "key1".getBytes(), "value3".getBytes()); | ||
assertThat(db.get("key1".getBytes())).isEqualTo( | ||
"value,value2,value3".getBytes()); | ||
// assertThat(db.get("key1".getBytes())).isEqualTo("value,value2,value3".getBytes()); | ||
db.merge(wOpt, "key1".getBytes(), "value4".getBytes()); | ||
assertThat(db.get("key1".getBytes())).isEqualTo( | ||
"value,value2,value3,value4".getBytes()); | ||
System.out.println(new String(db.get("key1".getBytes()))); | ||
//assertThat(db.get("key1".getBytes())).isEqualTo("value,value2,value3,value4".getBytes()); | ||
// merge on non existent key shall insert the value | ||
db.merge(wOpt, "key2".getBytes(), "xxxx".getBytes()); | ||
assertThat(db.get("key2".getBytes())).isEqualTo( | ||
|
@@ -320,7 +322,7 @@ public void run() { | |
}catch (Exception e){ | ||
throw new RuntimeException(e); | ||
}finally { | ||
org.rocksdb.util.Environment.detachCurrentThreadIfPossible(); | ||
|
||
} | ||
|
||
} | ||
|
@@ -330,7 +332,7 @@ public void run() { | |
|
||
t.setDaemon(false); | ||
t.start(); | ||
org.rocksdb.util.Environment.detachCurrentThreadIfPossible(); | ||
|
||
t.join(); | ||
|
||
} | ||
|
@@ -353,18 +355,24 @@ public void run() { | |
) { | ||
|
||
|
||
db.put("key1".getBytes(), "value".getBytes()); | ||
db.merge("key1".getBytes(), "value".getBytes()); | ||
assertThat(db.get("key1".getBytes())).isEqualTo( | ||
"value".getBytes()); | ||
// merge key1 with another value portion | ||
System.out.println("->merge value2"); | ||
db.merge("key1".getBytes(), "value2".getBytes()); | ||
System.out.println("->get"); | ||
assertThat(db.get("key1".getBytes())).isEqualTo( | ||
"value,value2".getBytes()); | ||
System.out.println("->merge value3"); | ||
// merge key1 with another value portion | ||
db.merge(wOpt, "key1".getBytes(), "value3".getBytes()); | ||
System.out.println("->get"); | ||
assertThat(db.get("key1".getBytes())).isEqualTo( | ||
"value,value2,value3".getBytes()); | ||
System.out.println("->merge value4"); | ||
db.merge(wOpt, "key1".getBytes(), "value4".getBytes()); | ||
System.out.println("->get"); | ||
assertThat(db.get("key1".getBytes())).isEqualTo( | ||
"value,value2,value3,value4".getBytes()); | ||
// merge on non existent key shall insert the value | ||
|
@@ -376,7 +384,7 @@ public void run() { | |
}catch (Exception e){ | ||
throw new RuntimeException(e); | ||
}finally { | ||
org.rocksdb.util.Environment.detachCurrentThreadIfPossible(); | ||
|
||
} | ||
|
||
} | ||
|
@@ -386,7 +394,7 @@ public void run() { | |
|
||
t.setDaemon(false); | ||
t.start(); | ||
org.rocksdb.util.Environment.detachCurrentThreadIfPossible(); | ||
|
||
t.join(); | ||
|
||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed? Looks like it got included anyway.