|
Project Information
Featured
Downloads
|
TreapDB is a key-value store based on TreapNews
Unit TestFeatures
All Operations
namespace java fx.sunjoy.server.gen
struct Pair {
1: string key,
2: binary value,
}
service TreapDBService{
void put(1:string key, 2:binary value);
binary get(1:string key),
void bulkPut(1:map<string,binary> kvMap);
list<Pair> bulkGet(1:list<string> keyList);
list<Pair> prefix(1:string prefixStr,2:i32 limit,3:string startK,4:bool asc),
list<Pair> bulkPrefix(1:list<string> prefixList,2:i32 limit,3:string startK,4:bool asc),
list<Pair> kmax(1:i32 k),
list<Pair> kmin(1:i32 k),
list<Pair> range(1:string kStart, 2:string kEnd,3:i32 limit),
list<Pair> before(1:string key,2:i32 limit),
list<Pair> after(1:string key,2:i32 limit),
i32 length(),
bool remove(1:string key),
bool removePrefix(1:string key),
void optimize(1:i32 amount)
}
Operations of TreapDB
Samplehttp://code.google.com/p/treapdb/wiki/SomeBenchmark RPC Server
Download & Configure
TreapDBConf.xml
<?xml version="1.0" encoding="UTF-8"?>
<TreapDB>
<Params>
<Port>
<Memcache>11811</Memcache>
//Listening port of memcache protocol
<Thrift>11812</Thrift>
//Listening port of thrift protocol
</Port>
<Index>
<FilePath>/var/log/treapdb/master</FilePath>
//Index file name
<BlockSize>64</BlockSize>
//size of index-block-item;
//default key length is 26(=64-38),38 is the node-overhead,
//TreapDB supports max key-length: 127 bytes)
</Index>
<MMapSize>128</MMapSize> //the more the better, 128MB is enough for 2 Million keys
<Replication>
<Role>Master</Role>
</Replication>
</Params>
</TreapDB>
TreapDBConf_Slave.xml <?xml version="1.0" encoding="UTF-8"?>
<TreapDB>
<Params>
<Port>
<Memcache>11911</Memcache>
<Thrift>11912</Thrift>
</Port>
<Index>
<FilePath>/var/log/treapdb/slave</FilePath>
<BlockSize>64</BlockSize>
</Index>
<MMapSize>128</MMapSize>
<Replication>
<Role>Slave</Role>
<Source>10.61.1.170:11811</Source>
//Set master address and port here!
</Replication>
</Params>
</TreapDB>
How to build from source
How to write client codeJava: Can TreapDB be used in an embedded way?Yes,put libtreap-xx.jar in your app's classpath.
Only Java?
any programming language.
thrift --gen py res/service.txt Python client: http://code.google.com/p/treapdb/wiki/PythonClientExample What is treap?In computer science, the treap and the randomized binary search tree are two closely-related forms of binary search tree data structures that maintain a dynamic set of ordered keys and allow binary searches among the keys. After any sequence of insertions and deletions of keys, the shape of the tree is a random variable with the same probability distribution as a random binary tree; in particular, with high probability its height is proportional to the logarithm of the number of keys, so that each search, insertion, or deletion operation takes logarithmic time to perform. http://en.wikipedia.org/wiki/Treap Contact the author
Welcome your valuable suggestions. My microblog: http://www.weibo.com/treapdb |