Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 82 lines (60 sloc) 3.815 kb
e27d76f Edited README.md via GitHub
osmandapp authored
1 JavaLevelDB is java bridge to C++ library [leveldb](http://code.google.com/p/leveldb/).
3fb74b7 Add readme
Victor Shcherb authored
2 ========
3 LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.
a4ed065 Edited README.md via GitHub
osmandapp authored
4 That project provides tiny access to library making transparent access to C++ [classes](http://code.google.com/p/leveldb/source/browse/#svn%2Ftrunk%2Finclude%2Fleveldb) through Java facade.
3fb74b7 Add readme
Victor Shcherb authored
5
a4ed065 Edited README.md via GitHub
osmandapp authored
6 How to build
7 --------------------
8 Checkout the project and run in command line :
8aaf3c5 Edited README.md via GitHub
osmandapp authored
9 'make' - checkout leveldb project from svn, compile it and build ready to use jar.
a4ed065 Edited README.md via GitHub
osmandapp authored
10
11 Build is only tested under Linux.
12 Possible problems :
d13fb0d Edited README.md via GitHub
osmandapp authored
13
14 * No internet connection to checkout leveldb from googlecode
aeff5b9 Edited README.md via GitHub
osmandapp authored
15 * [leveldb](http://code.google.com/p/leveldb/source/browse/trunk/build_detect_platform) can not be built under certain environment (under Cygwin in Windows)
a4ed065 Edited README.md via GitHub
osmandapp authored
16 * JAVA_HOME variable is not defined
d13fb0d Edited README.md via GitHub
osmandapp authored
17 * [swig](http://www.swig.org/) is not installed
a4ed065 Edited README.md via GitHub
osmandapp authored
18
e27d76f Edited README.md via GitHub
osmandapp authored
19 How to use
aeff5b9 Edited README.md via GitHub
osmandapp authored
20 -----------
21
dae6ea5 Add documentation
Victor Shcherb authored
22 // Loads library to corresponding OS if it is not loaded exception is thrown
23 // Before library is loaded you can not create any object!
24 // Library can be loaded in class initializator : `static { boolean loaded = LevelDBAccess.load(); }`
25 DBAccessor dbAccessor = LevelDBAccess.getDBAcessor();
26
27 Options options = new Options();
28 options.setCreateIfMissing(true);
29 Status status = dbAccessor.open(options, "filepath");
30
31 if (status.ok()) {
32 WriteOptions opts = new WriteOptions();
33 ReadOptions ro = new ReadOptions();
34 dbAccessor.put(opts, "key", "value");
35 assert "value".equals(dbAccessor.get(ro, "key"));
36 }
37
aeff5b9 Edited README.md via GitHub
osmandapp authored
38
1600c45 Implement DBTable/DBTableBuilder
Victor Shcherb authored
39 What is to be verified and implemented
a4ed065 Edited README.md via GitHub
osmandapp authored
40 --------------------
dae6ea5 Add documentation
Victor Shcherb authored
41 There are some operations not linked with C++ [API](http://code.google.com/p/leveldb/source/browse/#svn%2Ftrunk%2Finclude%2Fleveldb) :
42
d027393 Prepare user comparator
Victor Shcherb authored
43 * [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.
5a1193c Implement table access
Victor Shcherb authored
44 * [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.
1600c45 Implement DBTable/DBTableBuilder
Victor Shcherb authored
45
8dd2f36 Edited README.md via GitHub
osmandapp authored
46
341639d Add snapshot additional functions
Victor Shcherb authored
47 Is it really needed ?
1ddf383 Edited README.md via GitHub
osmandapp authored
48
341639d Add snapshot additional functions
Victor Shcherb authored
49 * [Cache](http://code.google.com/p/leveldb/source/browse/trunk/include/leveldb/cache.h) - own implementation of cache
50 * [Environment](http://code.google.com/p/leveldb/source/browse/trunk/include/leveldb/env.h) - own implementation of RandomAccessFile, SequentialFile,...
dae6ea5 Add documentation
Victor Shcherb authored
51 * [Cleanup Function of Iterator](http://code.google.com/p/leveldb/source/browse/trunk/include/leveldb/iterator.h)
8dd2f36 Edited README.md via GitHub
osmandapp authored
52 * [WriteBatch Iterator](http://code.google.com/p/leveldb/source/browse/trunk/include/leveldb/write_batch.h) - iterate over entities to be writen
53
aeff5b9 Edited README.md via GitHub
osmandapp authored
54
a4ed065 Edited README.md via GitHub
osmandapp authored
55 Contribution
56 --------------------
dae6ea5 Add documentation
Victor Shcherb authored
57 Please feel free to make forks and provide your pull requests :)
a4ed065 Edited README.md via GitHub
osmandapp authored
58
59
60 Additional
61 --------------------
62
dae6ea5 Add documentation
Victor Shcherb authored
63 That project provides very fast ArraySerializer that allows to store array of strings into string. The stream parser processes String in place and not allocate new memory.
64 With that helper you can serialize/deserialize every data structure like as array of arrays or map (as doubled array).
65 The format of serialization is pretty simple : `[Value, Value2, [ Value3 ]]`. It also supports quotation of important for deserialization characters.
66
67 int next;
68 EntityValueTokenizer tokenizer = new EntityValueTokenizer();
69 tokenizer.tokenize(value);
a4ed065 Edited README.md via GitHub
osmandapp authored
70
dae6ea5 Add documentation
Victor Shcherb authored
71 while ((next = tokenizer.next()) != END) {
72 if (next == ELEMENT) {
73 // TODO process element
74 String value = tokenizer.value();
75 } else if (next == START_ARRAY) {
76 // TODO process start of inner array
77 } else if (next == END_ARRAY) {
78 // TODO process end of array
79 }
80 }
a4ed065 Edited README.md via GitHub
osmandapp authored
81
Something went wrong with that request. Please try again.