Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Prepare user comparator

  • Loading branch information...
commit d027393439764d5577597b1c6cb18b5f0a92b5f6 1 parent f748e27
Victor Shcherb authored
2  README.md
View
@@ -40,7 +40,7 @@ What is to be verified and implemented
--------------------
There are some operations not linked with C++ [API](http://code.google.com/p/leveldb/source/browse/#svn%2Ftrunk%2Finclude%2Fleveldb) :
-* [Comparator](http://code.google.com/p/leveldb/source/browse/trunk/include/leveldb/comparator.h) - important enough (callback)
+* [Comparator](http://code.google.com/p/leveldb/source/browse/trunk/include/leveldb/comparator.h) - important enough. But require callback from C to Java which is difficult to do in SWIG.
* [TableBuilder](http://code.google.com/p/leveldb/source/browse/trunk/include/leveldb/table_builder.h) and [Table](http://code.google.com/p/leveldb/source/browse/trunk/include/leveldb/table.h) - should be properly tested. There is no default API to read Table from middle of file but it can be implemented.
44 db.i
View
@@ -5,13 +5,49 @@
#include "leveldb/write_batch.h"
#include "leveldb/db.h"
#include "leveldb/env.h"
+#include "leveldb/comparator.h"
#include "leveldb/table_builder.h"
#include "leveldb/table.h"
#include "leveldb/options.h"
%}
+
+%{
+ namespace leveldb {
+ class UserComparator : private Comparator {
+ private :
+ std::string comparatorName;
+ int (*comparatorFunc)(const std::string& a, const std::string& b);
+ public :
+ UserComparator(std::string name, int (*c)(const std::string& a, const std::string& b)) : comparatorName(name){
+ this-> comparatorFunc = c;
+ }
+
+ // If *start < limit, changes *start to a short string in [start,limit).
+ void FindShortestSeparator(std::string* start, const Slice& limit) {
+ // Does nothing that's correct to allow optimization
+ }
+
+ // Changes *key to a short string >= *key.
+ void FindShortSuccessor(std::string* key) {
+ // Does nothing that's correct to allow optimization
+ }
+ int Compare(const leveldb::Slice& a, const leveldb::Slice& b) const {
+ return 0;
+ }
+
+
+ const char* Name() const {
+ return comparatorName.c_str();
+ }
+ };
+ }
+%}
+
+
namespace leveldb {
+ %nodefaultctor;
%nodefaultdtor Snapshot;
class Snapshot {
};
@@ -30,7 +66,6 @@ namespace leveldb {
// DB::ReleaseSnapshot(*post_write_snapshotsnapshot) when the
// snapshot is no longer needed.
// Default: NULL
-
%rename(postWriteSnapshot) post_write_snapshot;
const Snapshot** post_write_snapshot;
@@ -90,6 +125,9 @@ namespace leveldb {
int block_restart_interval;
CompressionType compression;
+
+ // const Comparator* comparator;
+
};
@@ -115,7 +153,8 @@ namespace leveldb {
%inline %{
namespace leveldb {
-
+
+
class DBWriteBatch {
friend class DBAccessor;
private :
@@ -208,6 +247,7 @@ namespace leveldb {
long long approximateOffsetOf(const std::string& key) { table -> ApproximateOffsetOf(Slice(key)); }
};
+
class DBTableBuilder {
TableBuilder* tableBuilder;
WritableFile* wf;
1  src/com/anvisics/jleveldb/ext/LeveldbJNI.java
View
@@ -9,7 +9,6 @@
package com.anvisics.jleveldb.ext;
class LeveldbJNI {
- public final static native long new_Snapshot();
public final static native long new_WriteOptions();
public final static native void WriteOptions_sync_set(long jarg1, WriteOptions jarg1_, boolean jarg2);
public final static native boolean WriteOptions_sync_get(long jarg1, WriteOptions jarg1_);
4 src/com/anvisics/jleveldb/ext/Snapshot.java
View
@@ -31,8 +31,4 @@ public synchronized void delete() {
}
}
- public Snapshot() {
- this(LeveldbJNI.new_Snapshot(), true);
- }
-
}
Please sign in to comment.
Something went wrong with that request. Please try again.