mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Change namespace from leveldb to rocksdb
Summary: Change namespace from leveldb to rocksdb. This allows a single application to link in open-source leveldb code as well as rocksdb code into the same process. Test Plan: compile rocksdb Reviewers: emayanke Reviewed By: emayanke CC: leveldb Differential Revision: https://reviews.facebook.net/D13287
This commit is contained in:
@@ -39,19 +39,19 @@ import static org.fusesource.hawtjni.runtime.ClassFlag.CPP;
|
||||
import static org.fusesource.hawtjni.runtime.MethodFlag.CPP_DELETE;
|
||||
|
||||
/**
|
||||
* Provides a java interface to the C++ leveldb::Cache class.
|
||||
* Provides a java interface to the C++ rocksdb::Cache class.
|
||||
*
|
||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||
*/
|
||||
public class NativeCache extends NativeObject {
|
||||
|
||||
@JniClass(name="leveldb::Cache", flags={CPP})
|
||||
@JniClass(name="rocksdb::Cache", flags={CPP})
|
||||
private static class CacheJNI {
|
||||
static {
|
||||
NativeDB.LIBRARY.load();
|
||||
}
|
||||
|
||||
@JniMethod(cast="leveldb::Cache *", accessor="leveldb::NewLRUCache")
|
||||
@JniMethod(cast="rocksdb::Cache *", accessor="rocksdb::NewLRUCache")
|
||||
public static final native long NewLRUCache(
|
||||
@JniArg(cast="size_t") long capacity);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import static org.fusesource.hawtjni.runtime.ClassFlag.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Provides a java interface to the C++ leveldb::Comparator class.
|
||||
* Provides a java interface to the C++ rocksdb::Comparator class.
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||
@@ -85,7 +85,7 @@ public abstract class NativeComparator extends NativeObject {
|
||||
@JniField(flags={CONSTANT}, accessor="sizeof(struct JNIComparator)")
|
||||
static int SIZEOF;
|
||||
|
||||
@JniField(flags={CONSTANT}, cast="const Comparator*", accessor="leveldb::BytewiseComparator()")
|
||||
@JniField(flags={CONSTANT}, cast="const Comparator*", accessor="rocksdb::BytewiseComparator()")
|
||||
private static long BYTEWISE_COMPARATOR;
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
package org.fusesource.leveldbjni.internal;
|
||||
|
||||
/**
|
||||
* Provides a java interface to the C++ leveldb::CompressionType enum.
|
||||
* Provides a java interface to the C++ rocksdb::CompressionType enum.
|
||||
*
|
||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||
*/
|
||||
|
||||
@@ -52,7 +52,7 @@ public class NativeDB extends NativeObject {
|
||||
|
||||
public static final Library LIBRARY = new Library("leveldbjni", NativeDB.class);
|
||||
|
||||
@JniClass(name="leveldb::DB", flags={CPP})
|
||||
@JniClass(name="rocksdb::DB", flags={CPP})
|
||||
static class DBJNI {
|
||||
static {
|
||||
NativeDB.LIBRARY.load();
|
||||
@@ -79,13 +79,13 @@ public class NativeDB extends NativeObject {
|
||||
long self
|
||||
);
|
||||
|
||||
@JniMethod(copy="leveldb::Status", accessor = "leveldb::DB::Open")
|
||||
@JniMethod(copy="rocksdb::Status", accessor = "rocksdb::DB::Open")
|
||||
static final native long Open(
|
||||
@JniArg(flags={BY_VALUE, NO_OUT}) NativeOptions options,
|
||||
@JniArg(cast="const char*") String path,
|
||||
@JniArg(cast="leveldb::DB**") long[] self);
|
||||
@JniArg(cast="rocksdb::DB**") long[] self);
|
||||
|
||||
@JniMethod(copy="leveldb::Status", flags={CPP_METHOD})
|
||||
@JniMethod(copy="rocksdb::Status", flags={CPP_METHOD})
|
||||
static final native long Put(
|
||||
long self,
|
||||
@JniArg(flags={BY_VALUE, NO_OUT}) NativeWriteOptions options,
|
||||
@@ -93,21 +93,21 @@ public class NativeDB extends NativeObject {
|
||||
@JniArg(flags={BY_VALUE, NO_OUT}) NativeSlice value
|
||||
);
|
||||
|
||||
@JniMethod(copy="leveldb::Status", flags={CPP_METHOD})
|
||||
@JniMethod(copy="rocksdb::Status", flags={CPP_METHOD})
|
||||
static final native long Delete(
|
||||
long self,
|
||||
@JniArg(flags={BY_VALUE, NO_OUT}) NativeWriteOptions options,
|
||||
@JniArg(flags={BY_VALUE, NO_OUT}) NativeSlice key
|
||||
);
|
||||
|
||||
@JniMethod(copy="leveldb::Status", flags={CPP_METHOD})
|
||||
@JniMethod(copy="rocksdb::Status", flags={CPP_METHOD})
|
||||
static final native long Write(
|
||||
long self,
|
||||
@JniArg(flags={BY_VALUE}) NativeWriteOptions options,
|
||||
@JniArg(cast="leveldb::WriteBatch *") long updates
|
||||
@JniArg(cast="rocksdb::WriteBatch *") long updates
|
||||
);
|
||||
|
||||
@JniMethod(copy="leveldb::Status", flags={CPP_METHOD})
|
||||
@JniMethod(copy="rocksdb::Status", flags={CPP_METHOD})
|
||||
static final native long Get(
|
||||
long self,
|
||||
@JniArg(flags={NO_OUT, BY_VALUE}) NativeReadOptions options,
|
||||
@@ -115,26 +115,26 @@ public class NativeDB extends NativeObject {
|
||||
@JniArg(cast="std::string *") long value
|
||||
);
|
||||
|
||||
@JniMethod(cast="leveldb::Iterator *", flags={CPP_METHOD})
|
||||
@JniMethod(cast="rocksdb::Iterator *", flags={CPP_METHOD})
|
||||
static final native long NewIterator(
|
||||
long self,
|
||||
@JniArg(flags={NO_OUT, BY_VALUE}) NativeReadOptions options
|
||||
);
|
||||
|
||||
@JniMethod(cast="leveldb::Snapshot *", flags={CPP_METHOD})
|
||||
@JniMethod(cast="rocksdb::Snapshot *", flags={CPP_METHOD})
|
||||
static final native long GetSnapshot(
|
||||
long self);
|
||||
|
||||
@JniMethod(flags={CPP_METHOD})
|
||||
static final native void ReleaseSnapshot(
|
||||
long self,
|
||||
@JniArg(cast="const leveldb::Snapshot *") long snapshot
|
||||
@JniArg(cast="const rocksdb::Snapshot *") long snapshot
|
||||
);
|
||||
|
||||
@JniMethod(flags={CPP_METHOD})
|
||||
static final native void GetApproximateSizes(
|
||||
long self,
|
||||
@JniArg(cast="const leveldb::Range *") long range,
|
||||
@JniArg(cast="const rocksdb::Range *") long range,
|
||||
int n,
|
||||
@JniArg(cast="uint64_t*") long[] sizes
|
||||
);
|
||||
@@ -146,12 +146,12 @@ public class NativeDB extends NativeObject {
|
||||
@JniArg(cast="std::string *") long value
|
||||
);
|
||||
|
||||
@JniMethod(copy="leveldb::Status", accessor = "leveldb::DestroyDB")
|
||||
@JniMethod(copy="rocksdb::Status", accessor = "rocksdb::DestroyDB")
|
||||
static final native long DestroyDB(
|
||||
@JniArg(cast="const char*") String path,
|
||||
@JniArg(flags={BY_VALUE, NO_OUT}) NativeOptions options);
|
||||
|
||||
@JniMethod(copy="leveldb::Status", accessor = "leveldb::RepairDB")
|
||||
@JniMethod(copy="rocksdb::Status", accessor = "rocksdb::RepairDB")
|
||||
static final native long RepairDB(
|
||||
@JniArg(cast="const char*") String path,
|
||||
@JniArg(flags={BY_VALUE, NO_OUT}) NativeOptions options);
|
||||
|
||||
@@ -38,13 +38,13 @@ import static org.fusesource.hawtjni.runtime.ArgFlag.*;
|
||||
import static org.fusesource.hawtjni.runtime.ClassFlag.*;
|
||||
|
||||
/**
|
||||
* Provides a java interface to the C++ leveldb::Iterator class.
|
||||
* Provides a java interface to the C++ rocksdb::Iterator class.
|
||||
*
|
||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||
*/
|
||||
public class NativeIterator extends NativeObject {
|
||||
|
||||
@JniClass(name="leveldb::Iterator", flags={CPP})
|
||||
@JniClass(name="rocksdb::Iterator", flags={CPP})
|
||||
private static class IteratorJNI {
|
||||
static {
|
||||
NativeDB.LIBRARY.load();
|
||||
@@ -86,17 +86,17 @@ public class NativeIterator extends NativeObject {
|
||||
long self
|
||||
);
|
||||
|
||||
@JniMethod(copy="leveldb::Slice", flags={CPP_METHOD})
|
||||
@JniMethod(copy="rocksdb::Slice", flags={CPP_METHOD})
|
||||
static final native long key(
|
||||
long self
|
||||
);
|
||||
|
||||
@JniMethod(copy="leveldb::Slice", flags={CPP_METHOD})
|
||||
@JniMethod(copy="rocksdb::Slice", flags={CPP_METHOD})
|
||||
static final native long value(
|
||||
long self
|
||||
);
|
||||
|
||||
@JniMethod(copy="leveldb::Status", flags={CPP_METHOD})
|
||||
@JniMethod(copy="rocksdb::Status", flags={CPP_METHOD})
|
||||
static final native long status(
|
||||
long self
|
||||
);
|
||||
|
||||
@@ -46,7 +46,7 @@ import static org.fusesource.hawtjni.runtime.MethodFlag.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Provides a java interface to the C++ leveldb::Logger class.
|
||||
* Provides a java interface to the C++ rocksdb::Logger class.
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||
|
||||
@@ -42,11 +42,11 @@ import static org.fusesource.hawtjni.runtime.FieldFlag.FIELD_SKIP;
|
||||
import static org.fusesource.hawtjni.runtime.MethodFlag.CONSTANT_INITIALIZER;
|
||||
|
||||
/**
|
||||
* Provides a java interface to the C++ leveldb::Options class.
|
||||
* Provides a java interface to the C++ rocksdb::Options class.
|
||||
*
|
||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||
*/
|
||||
@JniClass(name="leveldb::Options", flags={STRUCT, CPP})
|
||||
@JniClass(name="rocksdb::Options", flags={STRUCT, CPP})
|
||||
public class NativeOptions {
|
||||
|
||||
static {
|
||||
@@ -57,7 +57,7 @@ public class NativeOptions {
|
||||
@JniMethod(flags={CONSTANT_INITIALIZER})
|
||||
private static final native void init();
|
||||
|
||||
@JniField(flags={CONSTANT}, cast="Env*", accessor="leveldb::Env::Default()")
|
||||
@JniField(flags={CONSTANT}, cast="Env*", accessor="rocksdb::Env::Default()")
|
||||
private static long DEFAULT_ENV;
|
||||
|
||||
private boolean create_if_missing = false;
|
||||
@@ -83,7 +83,7 @@ public class NativeOptions {
|
||||
|
||||
@JniField(flags={FIELD_SKIP})
|
||||
private NativeComparator comparatorObject = NativeComparator.BYTEWISE_COMPARATOR;
|
||||
@JniField(cast="const leveldb::Comparator*")
|
||||
@JniField(cast="const rocksdb::Comparator*")
|
||||
private long comparator = comparatorObject.pointer();
|
||||
|
||||
@JniField(cast="uint64_t")
|
||||
@@ -110,17 +110,17 @@ public class NativeOptions {
|
||||
|
||||
@JniField(flags={FIELD_SKIP})
|
||||
private NativeLogger infoLogObject = null;
|
||||
@JniField(cast="leveldb::Logger*")
|
||||
@JniField(cast="rocksdb::Logger*")
|
||||
private long info_log = 0;
|
||||
|
||||
@JniField(cast="leveldb::Env*")
|
||||
@JniField(cast="rocksdb::Env*")
|
||||
private long env = DEFAULT_ENV;
|
||||
@JniField(cast="leveldb::Cache*")
|
||||
@JniField(cast="rocksdb::Cache*")
|
||||
private long block_cache = 0;
|
||||
@JniField(flags={FIELD_SKIP})
|
||||
private NativeCache cache;
|
||||
|
||||
@JniField(cast="leveldb::CompressionType")
|
||||
@JniField(cast="rocksdb::CompressionType")
|
||||
private int compression = NativeCompressionType.kSnappyCompression.value;
|
||||
|
||||
public NativeOptions createIfMissing(boolean value) {
|
||||
|
||||
@@ -41,13 +41,13 @@ import static org.fusesource.hawtjni.runtime.FieldFlag.FIELD_SKIP;
|
||||
import static org.fusesource.hawtjni.runtime.MethodFlag.CONSTANT_INITIALIZER;
|
||||
|
||||
/**
|
||||
* Provides a java interface to the C++ leveldb::ReadOptions class.
|
||||
* Provides a java interface to the C++ rocksdb::ReadOptions class.
|
||||
*
|
||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||
*/
|
||||
public class NativeRange {
|
||||
|
||||
@JniClass(name="leveldb::Range", flags={STRUCT, CPP})
|
||||
@JniClass(name="rocksdb::Range", flags={STRUCT, CPP})
|
||||
static public class RangeJNI {
|
||||
|
||||
static {
|
||||
@@ -69,7 +69,7 @@ public class NativeRange {
|
||||
@JniMethod(flags={CONSTANT_INITIALIZER})
|
||||
private static final native void init();
|
||||
|
||||
@JniField(flags={CONSTANT}, accessor="sizeof(struct leveldb::Range)")
|
||||
@JniField(flags={CONSTANT}, accessor="sizeof(struct rocksdb::Range)")
|
||||
static int SIZEOF;
|
||||
|
||||
@JniField
|
||||
|
||||
@@ -38,11 +38,11 @@ import static org.fusesource.hawtjni.runtime.ClassFlag.CPP;
|
||||
import static org.fusesource.hawtjni.runtime.ClassFlag.STRUCT;
|
||||
|
||||
/**
|
||||
* Provides a java interface to the C++ leveldb::ReadOptions class.
|
||||
* Provides a java interface to the C++ rocksdb::ReadOptions class.
|
||||
*
|
||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||
*/
|
||||
@JniClass(name="leveldb::ReadOptions", flags={STRUCT, CPP})
|
||||
@JniClass(name="rocksdb::ReadOptions", flags={STRUCT, CPP})
|
||||
public class NativeReadOptions {
|
||||
|
||||
@JniField
|
||||
@@ -51,7 +51,7 @@ public class NativeReadOptions {
|
||||
@JniField
|
||||
private boolean fill_cache = true;
|
||||
|
||||
@JniField(cast="const leveldb::Snapshot*")
|
||||
@JniField(cast="const rocksdb::Snapshot*")
|
||||
private long snapshot=0;
|
||||
|
||||
public boolean fillCache() {
|
||||
|
||||
@@ -41,14 +41,14 @@ import static org.fusesource.hawtjni.runtime.MethodFlag.CONSTANT_INITIALIZER;
|
||||
import static org.fusesource.hawtjni.runtime.MethodFlag.CPP_DELETE;
|
||||
|
||||
/**
|
||||
* Provides a java interface to the C++ leveldb::Slice class.
|
||||
* Provides a java interface to the C++ rocksdb::Slice class.
|
||||
*
|
||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||
*/
|
||||
@JniClass(name="leveldb::Slice", flags={STRUCT, CPP})
|
||||
@JniClass(name="rocksdb::Slice", flags={STRUCT, CPP})
|
||||
class NativeSlice {
|
||||
|
||||
@JniClass(name="leveldb::Slice", flags={CPP})
|
||||
@JniClass(name="rocksdb::Slice", flags={CPP})
|
||||
static class SliceJNI {
|
||||
static {
|
||||
NativeDB.LIBRARY.load();
|
||||
@@ -74,7 +74,7 @@ class NativeSlice {
|
||||
@JniMethod(flags={CONSTANT_INITIALIZER})
|
||||
private static final native void init();
|
||||
|
||||
@JniField(flags={CONSTANT}, accessor="sizeof(struct leveldb::Slice)")
|
||||
@JniField(flags={CONSTANT}, accessor="sizeof(struct rocksdb::Slice)")
|
||||
static int SIZEOF;
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
package org.fusesource.leveldbjni.internal;
|
||||
|
||||
/**
|
||||
* Provides a java interface to the C++ leveldb::Snapshot class.
|
||||
* Provides a java interface to the C++ rocksdb::Snapshot class.
|
||||
*
|
||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||
*/
|
||||
|
||||
@@ -39,13 +39,13 @@ import static org.fusesource.hawtjni.runtime.MethodFlag.CPP_DELETE;
|
||||
import static org.fusesource.hawtjni.runtime.MethodFlag.CPP_METHOD;
|
||||
|
||||
/**
|
||||
* Provides a java interface to the C++ leveldb::Status class.
|
||||
* Provides a java interface to the C++ rocksdb::Status class.
|
||||
*
|
||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||
*/
|
||||
class NativeStatus extends NativeObject{
|
||||
|
||||
@JniClass(name="leveldb::Status", flags={CPP})
|
||||
@JniClass(name="rocksdb::Status", flags={CPP})
|
||||
static class StatusJNI {
|
||||
static {
|
||||
NativeDB.LIBRARY.load();
|
||||
|
||||
@@ -41,13 +41,13 @@ import static org.fusesource.hawtjni.runtime.ClassFlag.CPP;
|
||||
import static org.fusesource.hawtjni.runtime.MethodFlag.*;
|
||||
|
||||
/**
|
||||
* Provides a java interface to the C++ leveldb::WriteBatch class.
|
||||
* Provides a java interface to the C++ rocksdb::WriteBatch class.
|
||||
*
|
||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||
*/
|
||||
public class NativeWriteBatch extends NativeObject {
|
||||
|
||||
@JniClass(name="leveldb::WriteBatch", flags={CPP})
|
||||
@JniClass(name="rocksdb::WriteBatch", flags={CPP})
|
||||
private static class WriteBatchJNI {
|
||||
static {
|
||||
NativeDB.LIBRARY.load();
|
||||
|
||||
@@ -38,11 +38,11 @@ import static org.fusesource.hawtjni.runtime.ClassFlag.CPP;
|
||||
import static org.fusesource.hawtjni.runtime.ClassFlag.STRUCT;
|
||||
|
||||
/**
|
||||
* Provides a java interface to the C++ leveldb::WriteOptions class.
|
||||
* Provides a java interface to the C++ rocksdb::WriteOptions class.
|
||||
*
|
||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||
*/
|
||||
@JniClass(name="leveldb::WriteOptions", flags={STRUCT, CPP})
|
||||
@JniClass(name="rocksdb::WriteOptions", flags={STRUCT, CPP})
|
||||
public class NativeWriteOptions {
|
||||
|
||||
@JniField
|
||||
|
||||
@@ -51,14 +51,14 @@ import static org.fusesource.hawtjni.runtime.ArgFlag.*;
|
||||
*/
|
||||
public class Util {
|
||||
|
||||
@JniClass(name="leveldb::Env", flags={CPP})
|
||||
@JniClass(name="rocksdb::Env", flags={CPP})
|
||||
static class EnvJNI {
|
||||
|
||||
static {
|
||||
NativeDB.LIBRARY.load();
|
||||
}
|
||||
|
||||
@JniMethod(cast = "leveldb::Env *", accessor = "leveldb::Env::Default")
|
||||
@JniMethod(cast = "rocksdb::Env *", accessor = "rocksdb::Env::Default")
|
||||
public static final native long Default();
|
||||
|
||||
@JniMethod(flags = {CPP_METHOD})
|
||||
|
||||
@@ -74,12 +74,12 @@
|
||||
#include "leveldb/env.h"
|
||||
#include "leveldb/slice.h"
|
||||
|
||||
struct JNIComparator : public leveldb::Comparator {
|
||||
struct JNIComparator : public rocksdb::Comparator {
|
||||
jobject target;
|
||||
jmethodID compare_method;
|
||||
const char *name;
|
||||
|
||||
int Compare(const leveldb::Slice& a, const leveldb::Slice& b) const {
|
||||
int Compare(const rocksdb::Slice& a, const rocksdb::Slice& b) const {
|
||||
JNIEnv *env;
|
||||
if ( hawtjni_attach_thread(&env, "leveldb") ) {
|
||||
return 0;
|
||||
@@ -93,11 +93,11 @@ struct JNIComparator : public leveldb::Comparator {
|
||||
return name;
|
||||
}
|
||||
|
||||
void FindShortestSeparator(std::string*, const leveldb::Slice&) const { }
|
||||
void FindShortestSeparator(std::string*, const rocksdb::Slice&) const { }
|
||||
void FindShortSuccessor(std::string*) const { }
|
||||
};
|
||||
|
||||
struct JNILogger : public leveldb::Logger {
|
||||
struct JNILogger : public rocksdb::Logger {
|
||||
jobject target;
|
||||
jmethodID log_method;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user