-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathSplinterDBJNI.java
More file actions
62 lines (37 loc) · 1.33 KB
/
SplinterDBJNI.java
File metadata and controls
62 lines (37 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package org.splinterdb;
import java.util.concurrent.TimeUnit;
public class SplinterDBJNI {
static {
System.loadLibrary("splinterdbjni");
}
public native synchronized int createOrOpen(String filename, long cacheSize, long diskSize,
int maxKeySize, int valueSize, int open_existing);
public native synchronized int insert(int dbid, byte[] key, byte[] value);
public native synchronized byte[] lookup(int dbid, byte[] key);
public native synchronized int delete(int dbid, byte[] key);
public native synchronized int close(int dbid);
public native synchronized String version();
public void myString() {
System.out.println("hello");
}
public static void main (String args[])
{
try {
SplinterDBJNI splinter = new SplinterDBJNI();
System.out.println(splinter.version());
int id = splinter.createOrOpen("mydb", 64, 1024, 100, 5, 0);
String keyStr = "key1";
byte[] keyBytes = keyStr.getBytes();
String valueStr = "value1";
byte[] valueBytes = valueStr.getBytes();
splinter.insert(id, keyBytes, valueBytes);
byte[] value = splinter.lookup(id, keyBytes);
String outputValueStr = new String(value);
System.out.println("My value is:" + outputValueStr);
splinter.delete(id, keyBytes);
splinter.close(id);
} catch (Exception ex) {
System.out.println(ex.toString());
}
}
}