kyotocabinet-java 0.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +15 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +62 -0
- data/VERSION +1 -0
- data/ext/kyotocabinet-java/.gitignore +2 -0
- data/ext/kyotocabinet-java/COPYING +674 -0
- data/ext/kyotocabinet-java/Cursor.java +268 -0
- data/ext/kyotocabinet-java/DB.java +650 -0
- data/ext/kyotocabinet-java/Error.java +257 -0
- data/ext/kyotocabinet-java/FileProcessor.java +42 -0
- data/ext/kyotocabinet-java/Loader.java +60 -0
- data/ext/kyotocabinet-java/Makefile.in +246 -0
- data/ext/kyotocabinet-java/MapReduce.java +127 -0
- data/ext/kyotocabinet-java/README +26 -0
- data/ext/kyotocabinet-java/Test.java +1494 -0
- data/ext/kyotocabinet-java/Utility.java +131 -0
- data/ext/kyotocabinet-java/VCmakefile +150 -0
- data/ext/kyotocabinet-java/ValueIterator.java +49 -0
- data/ext/kyotocabinet-java/Visitor.java +56 -0
- data/ext/kyotocabinet-java/configure.in +310 -0
- data/ext/kyotocabinet-java/doc/allclasses-frame.html +26 -0
- data/ext/kyotocabinet-java/doc/allclasses-noframe.html +26 -0
- data/ext/kyotocabinet-java/doc/constant-values.html +344 -0
- data/ext/kyotocabinet-java/doc/index-all.html +848 -0
- data/ext/kyotocabinet-java/doc/index.html +30 -0
- data/ext/kyotocabinet-java/doc/kyotocabinet/Cursor.html +711 -0
- data/ext/kyotocabinet-java/doc/kyotocabinet/DB.html +1674 -0
- data/ext/kyotocabinet-java/doc/kyotocabinet/Error.html +604 -0
- data/ext/kyotocabinet-java/doc/kyotocabinet/FileProcessor.html +210 -0
- data/ext/kyotocabinet-java/doc/kyotocabinet/MapReduce.html +461 -0
- data/ext/kyotocabinet-java/doc/kyotocabinet/Test.html +220 -0
- data/ext/kyotocabinet-java/doc/kyotocabinet/Utility.html +413 -0
- data/ext/kyotocabinet-java/doc/kyotocabinet/ValueIterator.html +221 -0
- data/ext/kyotocabinet-java/doc/kyotocabinet/Visitor.html +283 -0
- data/ext/kyotocabinet-java/doc/kyotocabinet/package-frame.html +33 -0
- data/ext/kyotocabinet-java/doc/kyotocabinet/package-summary.html +199 -0
- data/ext/kyotocabinet-java/doc/kyotocabinet/package-tree.html +141 -0
- data/ext/kyotocabinet-java/doc/overview-summary.html +285 -0
- data/ext/kyotocabinet-java/doc/overview-tree.html +145 -0
- data/ext/kyotocabinet-java/doc/package-list +1 -0
- data/ext/kyotocabinet-java/doc/resources/background.gif +0 -0
- data/ext/kyotocabinet-java/doc/resources/tab.gif +0 -0
- data/ext/kyotocabinet-java/doc/resources/titlebar.gif +0 -0
- data/ext/kyotocabinet-java/doc/resources/titlebar_end.gif +0 -0
- data/ext/kyotocabinet-java/doc/serialized-form.html +141 -0
- data/ext/kyotocabinet-java/doc/stylesheet.css +474 -0
- data/ext/kyotocabinet-java/example/KCDBEX1.java +44 -0
- data/ext/kyotocabinet-java/example/KCDBEX2.java +44 -0
- data/ext/kyotocabinet-java/example/Makefile +59 -0
- data/ext/kyotocabinet-java/kyotocabinet.cc +2187 -0
- data/ext/kyotocabinet-java/kyotocabinet_Cursor.h +157 -0
- data/ext/kyotocabinet-java/kyotocabinet_DB.h +353 -0
- data/ext/kyotocabinet-java/kyotocabinet_Error.h +49 -0
- data/ext/kyotocabinet-java/kyotocabinet_Error_XBROKEN.h +41 -0
- data/ext/kyotocabinet-java/kyotocabinet_Error_XDUPREC.h +41 -0
- data/ext/kyotocabinet-java/kyotocabinet_Error_XINVALID.h +41 -0
- data/ext/kyotocabinet-java/kyotocabinet_Error_XLOGIC.h +41 -0
- data/ext/kyotocabinet-java/kyotocabinet_Error_XMISC.h +41 -0
- data/ext/kyotocabinet-java/kyotocabinet_Error_XNOIMPL.h +41 -0
- data/ext/kyotocabinet-java/kyotocabinet_Error_XNOPERM.h +41 -0
- data/ext/kyotocabinet-java/kyotocabinet_Error_XNOREC.h +41 -0
- data/ext/kyotocabinet-java/kyotocabinet_Error_XNOREPOS.h +41 -0
- data/ext/kyotocabinet-java/kyotocabinet_Error_XSUCCESS.h +41 -0
- data/ext/kyotocabinet-java/kyotocabinet_Error_XSYSTEM.h +41 -0
- data/ext/kyotocabinet-java/kyotocabinet_MapReduce.h +33 -0
- data/ext/kyotocabinet-java/kyotocabinet_Utility.h +101 -0
- data/ext/kyotocabinet-java/kyotocabinet_ValueIterator.h +21 -0
- data/ext/kyotocabinet-java/overview.html +177 -0
- data/kyotocabinet-java.gemspec +129 -0
- data/lib/kyotocabinet-java.rb +141 -0
- data/lib/kyotocabinet-java/version.rb +5 -0
- metadata +222 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
/* DO NOT EDIT THIS FILE - it is machine generated */
|
2
|
+
#include <jni.h>
|
3
|
+
/* Header for class kyotocabinet_Error_XSYSTEM */
|
4
|
+
|
5
|
+
#ifndef _Included_kyotocabinet_Error_XSYSTEM
|
6
|
+
#define _Included_kyotocabinet_Error_XSYSTEM
|
7
|
+
#ifdef __cplusplus
|
8
|
+
extern "C" {
|
9
|
+
#endif
|
10
|
+
#undef kyotocabinet_Error_XSYSTEM_serialVersionUID
|
11
|
+
#define kyotocabinet_Error_XSYSTEM_serialVersionUID -3042686055658047285LL
|
12
|
+
#undef kyotocabinet_Error_XSYSTEM_serialVersionUID
|
13
|
+
#define kyotocabinet_Error_XSYSTEM_serialVersionUID -3387516993124229948LL
|
14
|
+
#undef kyotocabinet_Error_XSYSTEM_serialVersionUID
|
15
|
+
#define kyotocabinet_Error_XSYSTEM_serialVersionUID -7034897190745766939LL
|
16
|
+
#undef kyotocabinet_Error_XSYSTEM_SUCCESS
|
17
|
+
#define kyotocabinet_Error_XSYSTEM_SUCCESS 0L
|
18
|
+
#undef kyotocabinet_Error_XSYSTEM_NOIMPL
|
19
|
+
#define kyotocabinet_Error_XSYSTEM_NOIMPL 1L
|
20
|
+
#undef kyotocabinet_Error_XSYSTEM_INVALID
|
21
|
+
#define kyotocabinet_Error_XSYSTEM_INVALID 2L
|
22
|
+
#undef kyotocabinet_Error_XSYSTEM_NOREPOS
|
23
|
+
#define kyotocabinet_Error_XSYSTEM_NOREPOS 3L
|
24
|
+
#undef kyotocabinet_Error_XSYSTEM_NOPERM
|
25
|
+
#define kyotocabinet_Error_XSYSTEM_NOPERM 4L
|
26
|
+
#undef kyotocabinet_Error_XSYSTEM_BROKEN
|
27
|
+
#define kyotocabinet_Error_XSYSTEM_BROKEN 5L
|
28
|
+
#undef kyotocabinet_Error_XSYSTEM_DUPREC
|
29
|
+
#define kyotocabinet_Error_XSYSTEM_DUPREC 6L
|
30
|
+
#undef kyotocabinet_Error_XSYSTEM_NOREC
|
31
|
+
#define kyotocabinet_Error_XSYSTEM_NOREC 7L
|
32
|
+
#undef kyotocabinet_Error_XSYSTEM_LOGIC
|
33
|
+
#define kyotocabinet_Error_XSYSTEM_LOGIC 8L
|
34
|
+
#undef kyotocabinet_Error_XSYSTEM_SYSTEM
|
35
|
+
#define kyotocabinet_Error_XSYSTEM_SYSTEM 9L
|
36
|
+
#undef kyotocabinet_Error_XSYSTEM_MISC
|
37
|
+
#define kyotocabinet_Error_XSYSTEM_MISC 15L
|
38
|
+
#ifdef __cplusplus
|
39
|
+
}
|
40
|
+
#endif
|
41
|
+
#endif
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/* DO NOT EDIT THIS FILE - it is machine generated */
|
2
|
+
#include <jni.h>
|
3
|
+
/* Header for class kyotocabinet_MapReduce */
|
4
|
+
|
5
|
+
#ifndef _Included_kyotocabinet_MapReduce
|
6
|
+
#define _Included_kyotocabinet_MapReduce
|
7
|
+
#ifdef __cplusplus
|
8
|
+
extern "C" {
|
9
|
+
#endif
|
10
|
+
#undef kyotocabinet_MapReduce_XNOLOCK
|
11
|
+
#define kyotocabinet_MapReduce_XNOLOCK 1L
|
12
|
+
#undef kyotocabinet_MapReduce_XNOCOMP
|
13
|
+
#define kyotocabinet_MapReduce_XNOCOMP 256L
|
14
|
+
/*
|
15
|
+
* Class: kyotocabinet_MapReduce
|
16
|
+
* Method: execute
|
17
|
+
* Signature: (Lkyotocabinet/DB;Ljava/lang/String;I)Z
|
18
|
+
*/
|
19
|
+
JNIEXPORT jboolean JNICALL Java_kyotocabinet_MapReduce_execute
|
20
|
+
(JNIEnv *, jobject, jobject, jstring, jint);
|
21
|
+
|
22
|
+
/*
|
23
|
+
* Class: kyotocabinet_MapReduce
|
24
|
+
* Method: emit
|
25
|
+
* Signature: ([B[B)Z
|
26
|
+
*/
|
27
|
+
JNIEXPORT jboolean JNICALL Java_kyotocabinet_MapReduce_emit
|
28
|
+
(JNIEnv *, jobject, jbyteArray, jbyteArray);
|
29
|
+
|
30
|
+
#ifdef __cplusplus
|
31
|
+
}
|
32
|
+
#endif
|
33
|
+
#endif
|
@@ -0,0 +1,101 @@
|
|
1
|
+
/* DO NOT EDIT THIS FILE - it is machine generated */
|
2
|
+
#include <jni.h>
|
3
|
+
/* Header for class kyotocabinet_Utility */
|
4
|
+
|
5
|
+
#ifndef _Included_kyotocabinet_Utility
|
6
|
+
#define _Included_kyotocabinet_Utility
|
7
|
+
#ifdef __cplusplus
|
8
|
+
extern "C" {
|
9
|
+
#endif
|
10
|
+
/*
|
11
|
+
* Class: kyotocabinet_Utility
|
12
|
+
* Method: atoi
|
13
|
+
* Signature: (Ljava/lang/String;)J
|
14
|
+
*/
|
15
|
+
JNIEXPORT jlong JNICALL Java_kyotocabinet_Utility_atoi
|
16
|
+
(JNIEnv *, jclass, jstring);
|
17
|
+
|
18
|
+
/*
|
19
|
+
* Class: kyotocabinet_Utility
|
20
|
+
* Method: atoix
|
21
|
+
* Signature: (Ljava/lang/String;)J
|
22
|
+
*/
|
23
|
+
JNIEXPORT jlong JNICALL Java_kyotocabinet_Utility_atoix
|
24
|
+
(JNIEnv *, jclass, jstring);
|
25
|
+
|
26
|
+
/*
|
27
|
+
* Class: kyotocabinet_Utility
|
28
|
+
* Method: atof
|
29
|
+
* Signature: (Ljava/lang/String;)D
|
30
|
+
*/
|
31
|
+
JNIEXPORT jdouble JNICALL Java_kyotocabinet_Utility_atof
|
32
|
+
(JNIEnv *, jclass, jstring);
|
33
|
+
|
34
|
+
/*
|
35
|
+
* Class: kyotocabinet_Utility
|
36
|
+
* Method: hash_murmur
|
37
|
+
* Signature: ([B)J
|
38
|
+
*/
|
39
|
+
JNIEXPORT jlong JNICALL Java_kyotocabinet_Utility_hash_1murmur
|
40
|
+
(JNIEnv *, jclass, jbyteArray);
|
41
|
+
|
42
|
+
/*
|
43
|
+
* Class: kyotocabinet_Utility
|
44
|
+
* Method: hash_fnv
|
45
|
+
* Signature: ([B)J
|
46
|
+
*/
|
47
|
+
JNIEXPORT jlong JNICALL Java_kyotocabinet_Utility_hash_1fnv
|
48
|
+
(JNIEnv *, jclass, jbyteArray);
|
49
|
+
|
50
|
+
/*
|
51
|
+
* Class: kyotocabinet_Utility
|
52
|
+
* Method: levdist
|
53
|
+
* Signature: ([B[B)J
|
54
|
+
*/
|
55
|
+
JNIEXPORT jlong JNICALL Java_kyotocabinet_Utility_levdist___3B_3B
|
56
|
+
(JNIEnv *, jclass, jbyteArray, jbyteArray);
|
57
|
+
|
58
|
+
/*
|
59
|
+
* Class: kyotocabinet_Utility
|
60
|
+
* Method: levdist
|
61
|
+
* Signature: (Ljava/lang/String;Ljava/lang/String;)J
|
62
|
+
*/
|
63
|
+
JNIEXPORT jlong JNICALL Java_kyotocabinet_Utility_levdist__Ljava_lang_String_2Ljava_lang_String_2
|
64
|
+
(JNIEnv *, jclass, jstring, jstring);
|
65
|
+
|
66
|
+
/*
|
67
|
+
* Class: kyotocabinet_Utility
|
68
|
+
* Method: remove_files_recursively
|
69
|
+
* Signature: (Ljava/lang/String;)Z
|
70
|
+
*/
|
71
|
+
JNIEXPORT jboolean JNICALL Java_kyotocabinet_Utility_remove_1files_1recursively
|
72
|
+
(JNIEnv *, jclass, jstring);
|
73
|
+
|
74
|
+
/*
|
75
|
+
* Class: kyotocabinet_Utility
|
76
|
+
* Method: version
|
77
|
+
* Signature: ()Ljava/lang/String;
|
78
|
+
*/
|
79
|
+
JNIEXPORT jstring JNICALL Java_kyotocabinet_Utility_version
|
80
|
+
(JNIEnv *, jclass);
|
81
|
+
|
82
|
+
/*
|
83
|
+
* Class: kyotocabinet_Utility
|
84
|
+
* Method: init_visitor_NOP
|
85
|
+
* Signature: ()[B
|
86
|
+
*/
|
87
|
+
JNIEXPORT jbyteArray JNICALL Java_kyotocabinet_Utility_init_1visitor_1NOP
|
88
|
+
(JNIEnv *, jclass);
|
89
|
+
|
90
|
+
/*
|
91
|
+
* Class: kyotocabinet_Utility
|
92
|
+
* Method: init_visitor_REMOVE
|
93
|
+
* Signature: ()[B
|
94
|
+
*/
|
95
|
+
JNIEXPORT jbyteArray JNICALL Java_kyotocabinet_Utility_init_1visitor_1REMOVE
|
96
|
+
(JNIEnv *, jclass);
|
97
|
+
|
98
|
+
#ifdef __cplusplus
|
99
|
+
}
|
100
|
+
#endif
|
101
|
+
#endif
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/* DO NOT EDIT THIS FILE - it is machine generated */
|
2
|
+
#include <jni.h>
|
3
|
+
/* Header for class kyotocabinet_ValueIterator */
|
4
|
+
|
5
|
+
#ifndef _Included_kyotocabinet_ValueIterator
|
6
|
+
#define _Included_kyotocabinet_ValueIterator
|
7
|
+
#ifdef __cplusplus
|
8
|
+
extern "C" {
|
9
|
+
#endif
|
10
|
+
/*
|
11
|
+
* Class: kyotocabinet_ValueIterator
|
12
|
+
* Method: next
|
13
|
+
* Signature: ()[B
|
14
|
+
*/
|
15
|
+
JNIEXPORT jbyteArray JNICALL Java_kyotocabinet_ValueIterator_next
|
16
|
+
(JNIEnv *, jobject);
|
17
|
+
|
18
|
+
#ifdef __cplusplus
|
19
|
+
}
|
20
|
+
#endif
|
21
|
+
#endif
|
@@ -0,0 +1,177 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
|
3
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
6
|
+
|
7
|
+
<head>
|
8
|
+
<meta http-equiv="Content-Language" content="en" />
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
10
|
+
<meta http-equiv="Content-Style-Type" content="text/css" />
|
11
|
+
<meta name="author" content="FAL Labs" />
|
12
|
+
<meta name="keywords" content="Kyoto Cabinet, Java" />
|
13
|
+
<meta name="description" content="API specifications of Java binding" />
|
14
|
+
<link rel="contents" href="./" />
|
15
|
+
<link rev="made" href="mailto:info@fallabs.com" />
|
16
|
+
<title>Java Binding of Kyoto Cabinet</title>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
|
21
|
+
<h1>Java Binding of Kyoto Cabinet.</h1>
|
22
|
+
|
23
|
+
<div>Kyoto Cabinet is a straightforward implementation of DBM.</div>
|
24
|
+
|
25
|
+
<h2>Introduction</h2>
|
26
|
+
|
27
|
+
<p>Kyoto Cabinet is a library of routines for managing a database. The database is a simple data file containing records, each is a pair of a key and a value. Every key and value is serial bytes with variable length. Both binary data and character string can be used as a key and a value. Each key must be unique within a database. There is neither concept of data tables nor data types. Records are organized in hash table or B+ tree.</p>
|
28
|
+
|
29
|
+
<p>The following access methods are provided to the database: storing a record with a key and a value, deleting a record by a key, retrieving a record by a key. Moreover, traversal access to every key are provided. These access methods are similar to ones of the original DBM (and its followers: NDBM and GDBM) library defined in the UNIX standard. Kyoto Cabinet is an alternative for the DBM because of its higher performance.</p>
|
30
|
+
|
31
|
+
<p>Each operation of the hash database has the time complexity of "O(1)". Therefore, in theory, the performance is constant regardless of the scale of the database. In practice, the performance is determined by the speed of the main memory or the storage device. If the size of the database is less than the capacity of the main memory, the performance will seem on-memory speed, which is faster than std::map of STL. Of course, the database size can be greater than the capacity of the main memory and the upper limit is 8 exabytes. Even in that case, each operation needs only one or two seeking of the storage device.</p>
|
32
|
+
|
33
|
+
<p>Each operation of the B+ tree database has the time complexity of "O(log N)". Therefore, in theory, the performance is logarithmic to the scale of the database. Although the performance of random access of the B+ tree database is slower than that of the hash database, the B+ tree database supports sequential access in order of the keys, which realizes forward matching search for strings and range search for integers. The performance of sequential access is much faster than that of random access.</p>
|
34
|
+
|
35
|
+
<p>This library wraps the polymorphic database of the C++ API. So, you can select the internal data structure by specifying the database name in runtime. This library is thread-safe.</p>
|
36
|
+
|
37
|
+
<h2>Installation</h2>
|
38
|
+
|
39
|
+
<p>Install the latest version of Kyoto Cabinet beforehand and get the package of the Java binding of Kyoto Cabinet. JDK 6 or later is also required.</p>
|
40
|
+
|
41
|
+
<p>Enter the directory of the extracted package then perform installation.</p>
|
42
|
+
|
43
|
+
<pre style="margin: 0em 0.8em; padding: 0.3em; background: #eeeeff none; border: 1px solid #cccccc; font-size: 90%;">./configure
|
44
|
+
make
|
45
|
+
make check
|
46
|
+
su
|
47
|
+
make install
|
48
|
+
</pre>
|
49
|
+
|
50
|
+
<p>When a series of work finishes, the JAR file `kyotocabinet.jar' and the shared object files `libjkyotocabinet.so' and so on are installed under `/usr/local/lib'.</p>
|
51
|
+
|
52
|
+
<p>Let the class search path include `/usr/local/lib/kyotocabinet.jar' and let the library search path include `/usr/local/lib'.</p>
|
53
|
+
|
54
|
+
<pre style="margin: 0em 0.8em; padding: 0.3em; background: #eeeeff none; border: 1px solid #cccccc; font-size: 90%;">CLASSPATH="$CLASSPATH:/usr/local/lib/kyotocabinet.jar"
|
55
|
+
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"
|
56
|
+
export CLASSPATH LD_LIBRARY_PATH
|
57
|
+
</pre>
|
58
|
+
|
59
|
+
<p>The above settings can be specified by options of the runtime command.</p>
|
60
|
+
|
61
|
+
<pre style="margin: 0em 0.8em; padding: 0.3em; background: #eeeeff none; border: 1px solid #cccccc; font-size: 90%;">java -cp .:kyotocabinet.jar -Djava.library.path=.:/usr/local/lib FooBarBaz ...
|
62
|
+
</pre>
|
63
|
+
|
64
|
+
<p>All symbols of Kyoto Cabinet are defined in the package `kyotocabinet'. You can access them without any prefix by importing the package.</p>
|
65
|
+
|
66
|
+
<pre style="margin: 0em 0.8em; padding: 0.3em; background: #eeeeff none; border: 1px solid #cccccc; font-size: 90%;">import kyotocabinet.*;
|
67
|
+
</pre>
|
68
|
+
|
69
|
+
<h2>Example</h2>
|
70
|
+
|
71
|
+
<p>The following code is a typical example to use a database. </p>
|
72
|
+
|
73
|
+
<pre style="margin: 0em 0.8em; padding: 0.3em; background: #eeeeff none; border: 1px solid #cccccc; font-size: 90%;">import kyotocabinet.*;
|
74
|
+
|
75
|
+
public class KCDBEX1 {
|
76
|
+
public static void main(String[] args) {
|
77
|
+
|
78
|
+
// create the object
|
79
|
+
DB db = new DB();
|
80
|
+
|
81
|
+
// open the database
|
82
|
+
if (!db.open("casket.kch", DB.OWRITER | DB.OCREATE)){
|
83
|
+
System.err.println("open error: " + db.error());
|
84
|
+
}
|
85
|
+
|
86
|
+
// store records
|
87
|
+
if (!db.set("foo", "hop") ||
|
88
|
+
!db.set("bar", "step") ||
|
89
|
+
!db.set("baz", "jump")){
|
90
|
+
System.err.println("set error: " + db.error());
|
91
|
+
}
|
92
|
+
|
93
|
+
// retrieve records
|
94
|
+
String value = db.get("foo");
|
95
|
+
if (value != null){
|
96
|
+
System.out.println(value);
|
97
|
+
} else {
|
98
|
+
System.err.println("set error: " + db.error());
|
99
|
+
}
|
100
|
+
|
101
|
+
// traverse records
|
102
|
+
Cursor cur = db.cursor();
|
103
|
+
cur.jump();
|
104
|
+
String[] rec;
|
105
|
+
while ((rec = cur.get_str(true)) != null) {
|
106
|
+
System.out.println(rec[0] + ":" + rec[1]);
|
107
|
+
}
|
108
|
+
cur.disable();
|
109
|
+
|
110
|
+
// close the database
|
111
|
+
if(!db.close()){
|
112
|
+
System.err.println("close error: " + db.error());
|
113
|
+
}
|
114
|
+
|
115
|
+
}
|
116
|
+
}
|
117
|
+
</pre>
|
118
|
+
|
119
|
+
<p>The following code is a more complex example, which uses the Visitor pattern.</p>
|
120
|
+
|
121
|
+
<pre style="margin: 0em 0.8em; padding: 0.3em; background: #eeeeff none; border: 1px solid #cccccc; font-size: 90%;">import kyotocabinet.*;
|
122
|
+
|
123
|
+
public class KCDBEX2 {
|
124
|
+
public static void main(String[] args) {
|
125
|
+
|
126
|
+
// create the object
|
127
|
+
DB db = new DB();
|
128
|
+
|
129
|
+
// open the database
|
130
|
+
if (!db.open("casket.kch", DB.OREADER)) {
|
131
|
+
System.err.println("open error: " + db.error());
|
132
|
+
}
|
133
|
+
|
134
|
+
// define the visitor
|
135
|
+
class VisitorImpl implements Visitor {
|
136
|
+
public byte[] visit_full(byte[] key, byte[] value) {
|
137
|
+
System.out.println(new String(key) + ":" + new String(value));
|
138
|
+
return NOP;
|
139
|
+
}
|
140
|
+
public byte[] visit_empty(byte[] key) {
|
141
|
+
System.err.println(new String(key) + " is missing");
|
142
|
+
return NOP;
|
143
|
+
}
|
144
|
+
}
|
145
|
+
Visitor visitor = new VisitorImpl();
|
146
|
+
|
147
|
+
// retrieve a record with visitor
|
148
|
+
if (!db.accept("foo".getBytes(), visitor, false) ||
|
149
|
+
!db.accept("dummy".getBytes(), visitor, false)) {
|
150
|
+
System.err.println("accept error: " + db.error());
|
151
|
+
}
|
152
|
+
|
153
|
+
// traverse records with visitor
|
154
|
+
if (!db.iterate(visitor, false)) {
|
155
|
+
System.err.println("iterate error: " + db.error());
|
156
|
+
}
|
157
|
+
|
158
|
+
// close the database
|
159
|
+
if(!db.close()){
|
160
|
+
System.err.println("close error: " + db.error());
|
161
|
+
}
|
162
|
+
|
163
|
+
}
|
164
|
+
}
|
165
|
+
</pre>
|
166
|
+
|
167
|
+
<h2>License</h2>
|
168
|
+
|
169
|
+
<div>Copyright (C) 2009-2011 FAL Labs</div>
|
170
|
+
|
171
|
+
<p>Kyoto Cabinet is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.</p>
|
172
|
+
|
173
|
+
<p>Kyoto Cabinet is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</p>
|
174
|
+
|
175
|
+
</body>
|
176
|
+
|
177
|
+
</html>
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "kyotocabinet-java"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
s.platform = "java"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.authors = ["Clayton Wheeler"]
|
13
|
+
s.date = "2012-06-26"
|
14
|
+
s.description = "Wrapper for Kyoto Cabinet's Java library for use with JRuby, to provide the same interface as the native kyotocabinet-ruby gem for MRI."
|
15
|
+
s.email = "cswh@umich.edu"
|
16
|
+
s.extensions = ["ext/kyotocabinet-java/configure"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
"Gemfile",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"ext/kyotocabinet-java/.gitignore",
|
29
|
+
"ext/kyotocabinet-java/COPYING",
|
30
|
+
"ext/kyotocabinet-java/Cursor.java",
|
31
|
+
"ext/kyotocabinet-java/DB.java",
|
32
|
+
"ext/kyotocabinet-java/Error.java",
|
33
|
+
"ext/kyotocabinet-java/FileProcessor.java",
|
34
|
+
"ext/kyotocabinet-java/Loader.java",
|
35
|
+
"ext/kyotocabinet-java/Makefile.in",
|
36
|
+
"ext/kyotocabinet-java/MapReduce.java",
|
37
|
+
"ext/kyotocabinet-java/README",
|
38
|
+
"ext/kyotocabinet-java/Test.java",
|
39
|
+
"ext/kyotocabinet-java/Utility.java",
|
40
|
+
"ext/kyotocabinet-java/VCmakefile",
|
41
|
+
"ext/kyotocabinet-java/ValueIterator.java",
|
42
|
+
"ext/kyotocabinet-java/Visitor.java",
|
43
|
+
"ext/kyotocabinet-java/configure.in",
|
44
|
+
"ext/kyotocabinet-java/doc/allclasses-frame.html",
|
45
|
+
"ext/kyotocabinet-java/doc/allclasses-noframe.html",
|
46
|
+
"ext/kyotocabinet-java/doc/constant-values.html",
|
47
|
+
"ext/kyotocabinet-java/doc/index-all.html",
|
48
|
+
"ext/kyotocabinet-java/doc/index.html",
|
49
|
+
"ext/kyotocabinet-java/doc/kyotocabinet/Cursor.html",
|
50
|
+
"ext/kyotocabinet-java/doc/kyotocabinet/DB.html",
|
51
|
+
"ext/kyotocabinet-java/doc/kyotocabinet/Error.html",
|
52
|
+
"ext/kyotocabinet-java/doc/kyotocabinet/FileProcessor.html",
|
53
|
+
"ext/kyotocabinet-java/doc/kyotocabinet/MapReduce.html",
|
54
|
+
"ext/kyotocabinet-java/doc/kyotocabinet/Test.html",
|
55
|
+
"ext/kyotocabinet-java/doc/kyotocabinet/Utility.html",
|
56
|
+
"ext/kyotocabinet-java/doc/kyotocabinet/ValueIterator.html",
|
57
|
+
"ext/kyotocabinet-java/doc/kyotocabinet/Visitor.html",
|
58
|
+
"ext/kyotocabinet-java/doc/kyotocabinet/package-frame.html",
|
59
|
+
"ext/kyotocabinet-java/doc/kyotocabinet/package-summary.html",
|
60
|
+
"ext/kyotocabinet-java/doc/kyotocabinet/package-tree.html",
|
61
|
+
"ext/kyotocabinet-java/doc/overview-summary.html",
|
62
|
+
"ext/kyotocabinet-java/doc/overview-tree.html",
|
63
|
+
"ext/kyotocabinet-java/doc/package-list",
|
64
|
+
"ext/kyotocabinet-java/doc/resources/background.gif",
|
65
|
+
"ext/kyotocabinet-java/doc/resources/tab.gif",
|
66
|
+
"ext/kyotocabinet-java/doc/resources/titlebar.gif",
|
67
|
+
"ext/kyotocabinet-java/doc/resources/titlebar_end.gif",
|
68
|
+
"ext/kyotocabinet-java/doc/serialized-form.html",
|
69
|
+
"ext/kyotocabinet-java/doc/stylesheet.css",
|
70
|
+
"ext/kyotocabinet-java/example/KCDBEX1.java",
|
71
|
+
"ext/kyotocabinet-java/example/KCDBEX2.java",
|
72
|
+
"ext/kyotocabinet-java/example/Makefile",
|
73
|
+
"ext/kyotocabinet-java/kyotocabinet.cc",
|
74
|
+
"ext/kyotocabinet-java/kyotocabinet_Cursor.h",
|
75
|
+
"ext/kyotocabinet-java/kyotocabinet_DB.h",
|
76
|
+
"ext/kyotocabinet-java/kyotocabinet_Error.h",
|
77
|
+
"ext/kyotocabinet-java/kyotocabinet_Error_XBROKEN.h",
|
78
|
+
"ext/kyotocabinet-java/kyotocabinet_Error_XDUPREC.h",
|
79
|
+
"ext/kyotocabinet-java/kyotocabinet_Error_XINVALID.h",
|
80
|
+
"ext/kyotocabinet-java/kyotocabinet_Error_XLOGIC.h",
|
81
|
+
"ext/kyotocabinet-java/kyotocabinet_Error_XMISC.h",
|
82
|
+
"ext/kyotocabinet-java/kyotocabinet_Error_XNOIMPL.h",
|
83
|
+
"ext/kyotocabinet-java/kyotocabinet_Error_XNOPERM.h",
|
84
|
+
"ext/kyotocabinet-java/kyotocabinet_Error_XNOREC.h",
|
85
|
+
"ext/kyotocabinet-java/kyotocabinet_Error_XNOREPOS.h",
|
86
|
+
"ext/kyotocabinet-java/kyotocabinet_Error_XSUCCESS.h",
|
87
|
+
"ext/kyotocabinet-java/kyotocabinet_Error_XSYSTEM.h",
|
88
|
+
"ext/kyotocabinet-java/kyotocabinet_MapReduce.h",
|
89
|
+
"ext/kyotocabinet-java/kyotocabinet_Utility.h",
|
90
|
+
"ext/kyotocabinet-java/kyotocabinet_ValueIterator.h",
|
91
|
+
"ext/kyotocabinet-java/overview.html",
|
92
|
+
"kyotocabinet-java.gemspec",
|
93
|
+
"lib/kyotocabinet-java.rb",
|
94
|
+
"lib/kyotocabinet-java/version.rb"
|
95
|
+
]
|
96
|
+
s.homepage = "http://github.com/csw/kyotocabinet-java"
|
97
|
+
s.licenses = ["MIT"]
|
98
|
+
s.require_paths = ["lib"]
|
99
|
+
s.rubygems_version = "1.8.24"
|
100
|
+
s.summary = "Kyoto Cabinet Java library for JRuby"
|
101
|
+
|
102
|
+
if s.respond_to? :specification_version then
|
103
|
+
s.specification_version = 3
|
104
|
+
|
105
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
106
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
107
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
108
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.1.3"])
|
109
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
110
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
111
|
+
s.add_development_dependency(%q<jruby-openssl>, [">= 0"])
|
112
|
+
else
|
113
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
114
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
115
|
+
s.add_dependency(%q<bundler>, ["~> 1.1.3"])
|
116
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
117
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
118
|
+
s.add_dependency(%q<jruby-openssl>, [">= 0"])
|
119
|
+
end
|
120
|
+
else
|
121
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
122
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
123
|
+
s.add_dependency(%q<bundler>, ["~> 1.1.3"])
|
124
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
125
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
126
|
+
s.add_dependency(%q<jruby-openssl>, [">= 0"])
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|