├── lmdbjni ├── src │ ├── main │ │ ├── resources │ │ │ └── org │ │ │ │ └── fusesource │ │ │ │ └── lmdbjni │ │ │ │ └── version.txt │ │ ├── native-package │ │ │ ├── m4 │ │ │ │ ├── ltversion.m4 │ │ │ │ ├── custom.m4 │ │ │ │ ├── osx-universal.m4 │ │ │ │ ├── ltsugar.m4 │ │ │ │ ├── jni.m4 │ │ │ │ ├── lt~obsolete.m4 │ │ │ │ └── ltoptions.m4 │ │ │ ├── src │ │ │ │ ├── buffer.c │ │ │ │ ├── lmdbjni.h │ │ │ │ └── config.h.in │ │ │ ├── Makefile.am │ │ │ ├── autotools │ │ │ │ ├── ar-lib │ │ │ │ ├── missing │ │ │ │ └── install-sh │ │ │ ├── license.txt │ │ │ └── vs2010.vcxproj │ │ └── java │ │ │ └── org │ │ │ └── fusesource │ │ │ └── lmdbjni │ │ │ ├── SeekOp.java │ │ │ ├── Entry.java │ │ │ ├── NativeObject.java │ │ │ ├── Transaction.java │ │ │ ├── GetOp.java │ │ │ ├── Value.java │ │ │ ├── Util.java │ │ │ ├── LMDBException.java │ │ │ ├── Cursor.java │ │ │ ├── Constants.java │ │ │ ├── Env.java │ │ │ ├── Database.java │ │ │ ├── NativeBuffer.java │ │ │ └── JNI.java │ └── test │ │ └── java │ │ └── org │ │ └── fusesource │ │ └── lmdbjni │ │ └── test │ │ └── EnvTest.java └── pom.xml ├── lmdbjni-all ├── src │ └── main │ │ └── java │ │ └── org │ │ └── fusesource │ │ └── leveldbjni │ │ └── All.java └── pom.xml ├── .travis.yml ├── .gitignore ├── changelog.md ├── src └── main │ └── resources │ └── license-header.txt ├── readme.md ├── lmdbjni-win64 └── pom.xml ├── lmdbjni-osx64 └── pom.xml ├── lmdbjni-linux64 └── pom.xml ├── pom.xml └── license.txt /lmdbjni/src/main/resources/org/fusesource/lmdbjni/version.txt: -------------------------------------------------------------------------------- 1 | ${project.version} -------------------------------------------------------------------------------- /lmdbjni-all/src/main/java/org/fusesource/leveldbjni/All.java: -------------------------------------------------------------------------------- 1 | package org.fusesource.lmdbjni; 2 | 3 | public class All { 4 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk8 4 | 5 | before_script: sudo apt-get install build-essential automake1.10 libtool 6 | script: "mvn install -P linux64" 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | .idea 4 | .idea/* 5 | *.iml 6 | *.ipr 7 | *.iws 8 | target 9 | .DS_Store 10 | .project 11 | .classpath 12 | .settings 13 | eclipse-classes 14 | test-data -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # [lmdbjni](https://github.com/fusesource/lmdbjni) 2 | 3 | ## [lmdbjni 1.0](http://repo.fusesource.com/nexus/content/groups/public/org/fusesource/lmdbjni/lmdbjni-all/1.0), unreleased 4 | 5 | * Initial Release 6 | -------------------------------------------------------------------------------- /src/main/resources/license-header.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013, RedHat, Inc. 2 | 3 | http://www.redhat.com/ 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 3337 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.2]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3337]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.2' 20 | macro_revision='1.3337' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/src/buffer.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "lmdbjni.h" 20 | 21 | void buffer_copy(const void *source, size_t source_pos, void *dest, size_t dest_pos, size_t length) { 22 | memmove(((char *)dest)+dest_pos, ((const char *)source)+source_pos, length); 23 | } 24 | -------------------------------------------------------------------------------- /lmdbjni/src/main/java/org/fusesource/lmdbjni/SeekOp.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.fusesource.lmdbjni; 20 | 21 | import static org.fusesource.lmdbjni.JNI.*; 22 | 23 | /** 24 | * @author Hiram Chirino 25 | */ 26 | public enum SeekOp { 27 | 28 | KEY (MDB_SET_KEY ), 29 | RANGE (MDB_SET_RANGE ); 30 | 31 | private final int value; 32 | 33 | SeekOp(int value) { 34 | 35 | this.value = value; 36 | } 37 | 38 | public int getValue() { 39 | return value; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/Makefile.am: -------------------------------------------------------------------------------- 1 | # --------------------------------------------------------------------------- 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # --------------------------------------------------------------------------- 17 | 18 | ACLOCAL_AMFLAGS = -I m4 19 | 20 | lib_LTLIBRARIES = liblmdbjni.la 21 | # liblmdbjni_la_CFLAGS = 22 | #liblmdbjni_la_LDFLAGS = 23 | 24 | liblmdbjni_la_SOURCES = src/buffer.c\ 25 | src/hawtjni.c\ 26 | src/lmdbjni.c\ 27 | src/lmdbjni_stats.c\ 28 | src/lmdbjni_structs.c 29 | -------------------------------------------------------------------------------- /lmdbjni/src/main/java/org/fusesource/lmdbjni/Entry.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.fusesource.lmdbjni; 20 | 21 | import java.util.Map; 22 | 23 | /** 24 | * @author Hiram Chirino 25 | */ 26 | public class Entry implements Map.Entry { 27 | 28 | private final byte[] key; 29 | private final byte[] value; 30 | 31 | public Entry(byte[] key, byte[] value) { 32 | this.key = key; 33 | this.value = value; 34 | } 35 | 36 | public byte[] getKey() { 37 | return key; 38 | } 39 | 40 | public byte[] getValue() { 41 | return value; 42 | } 43 | 44 | public byte[] setValue(byte[] value) { 45 | throw new UnsupportedOperationException(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/m4/custom.m4: -------------------------------------------------------------------------------- 1 | dnl --------------------------------------------------------------------------- 2 | dnl Copyright (C) 2013, RedHat, Inc. 3 | dnl 4 | dnl http://www.redhat.com/ 5 | dnl 6 | dnl Licensed under the Apache License, Version 2.0 (the "License"); 7 | dnl you may not use this file except in compliance with the License. 8 | dnl You may obtain a copy of the License at 9 | dnl 10 | dnl http://www.apache.org/licenses/LICENSE-2.0 11 | dnl 12 | dnl Unless required by applicable law or agreed to in writing, software 13 | dnl distributed under the License is distributed on an "AS IS" BASIS, 14 | dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | dnl See the License for the specific language governing permissions and 16 | dnl limitations under the License. 17 | dnl --------------------------------------------------------------------------- 18 | 19 | AC_DEFUN([CUSTOM_M4_SETUP], 20 | [ 21 | AC_CHECK_HEADER([pthread.h],[AC_DEFINE([HAVE_PTHREAD_H], [1], [Define to 1 if you have the header file.])]) 22 | 23 | AC_ARG_WITH([lmdb], 24 | [AS_HELP_STRING([--with-lmdb@<:@=PATH@:>@], [Directory where lmdb was built. Example: --with-lmdb=/opt/lmdb])], 25 | [ 26 | CFLAGS="$CFLAGS -I${withval}" 27 | CXXFLAGS="$CXXFLAGS -I${withval}" 28 | AC_SUBST(CXXFLAGS) 29 | LDFLAGS="$LDFLAGS -llmdb -L${withval}" 30 | AC_SUBST(LDFLAGS) 31 | ] 32 | ) 33 | 34 | AC_CHECK_HEADER([lmdb.h],,AC_MSG_ERROR([cannot find headers for lmdb])) 35 | AC_CHECK_HEADER([sys/errno.h],[AC_DEFINE([HAVE_SYS_ERRNO_H], [1], [Define to 1 if you have the header file.])]) 36 | ]) -------------------------------------------------------------------------------- /lmdbjni/src/main/java/org/fusesource/lmdbjni/NativeObject.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.fusesource.lmdbjni; 20 | 21 | import org.fusesource.lmdbjni.LMDBException; 22 | 23 | /** 24 | * A helper base class which is used to track a pointer to a native 25 | * structure or class. 26 | * 27 | * @author Hiram Chirino 28 | */ 29 | class NativeObject { 30 | 31 | protected long self; 32 | 33 | protected NativeObject(long self) { 34 | this.self = self; 35 | if( self ==0 ) { 36 | throw new OutOfMemoryError("Failure allocating native heap memory"); 37 | } 38 | } 39 | 40 | long pointer() { 41 | checkAllocated(); 42 | return self; 43 | } 44 | 45 | public boolean isAllocated() { 46 | return self !=0; 47 | } 48 | 49 | protected void checkAllocated() { 50 | if( !isAllocated() ) { 51 | throw new LMDBException("Native object has been freed."); 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /lmdbjni/src/main/java/org/fusesource/lmdbjni/Transaction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.fusesource.lmdbjni; 20 | 21 | import static org.fusesource.lmdbjni.JNI.*; 22 | import static org.fusesource.lmdbjni.Util.checkErrorCode; 23 | 24 | /** 25 | * @author Hiram Chirino 26 | */ 27 | public class Transaction extends NativeObject { 28 | 29 | private final Env env; 30 | 31 | Transaction(Env env, long self) { 32 | super(self); 33 | this.env = env; 34 | } 35 | 36 | public void renew() { 37 | checkErrorCode(mdb_txn_renew(pointer())); 38 | } 39 | 40 | public void commit() { 41 | if( self != 0 ) { 42 | checkErrorCode(mdb_txn_commit(self)); 43 | self = 0; 44 | } 45 | } 46 | 47 | public void reset() { 48 | checkAllocated(); 49 | mdb_txn_reset(pointer()); 50 | } 51 | 52 | public void abort() { 53 | if( self != 0 ) { 54 | mdb_txn_abort(self); 55 | self = 0; 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /lmdbjni/src/main/java/org/fusesource/lmdbjni/GetOp.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.fusesource.lmdbjni; 20 | 21 | import static org.fusesource.lmdbjni.JNI.*; 22 | 23 | /** 24 | * @author Hiram Chirino 25 | */ 26 | public enum GetOp { 27 | 28 | FIRST (MDB_FIRST ) , 29 | FIRST_DUP (MDB_FIRST_DUP ) , 30 | GET_BOTH (MDB_GET_BOTH ) , 31 | GET_BOTH_RANGE (MDB_GET_BOTH_RANGE) , 32 | GET_CURRENT (MDB_GET_CURRENT ) , 33 | GET_MULTIPLE (MDB_GET_MULTIPLE ) , 34 | LAST (MDB_LAST ) , 35 | LAST_DUP (MDB_LAST_DUP ) , 36 | NEXT (MDB_NEXT ) , 37 | NEXT_DUP (MDB_NEXT_DUP ) , 38 | NEXT_MULTIPLE (MDB_NEXT_MULTIPLE ) , 39 | NEXT_NODUP (MDB_NEXT_NODUP ) , 40 | PREV (MDB_PREV ) , 41 | PREV_DUP (MDB_PREV_DUP ) , 42 | PREV_NODUP (MDB_PREV_NODUP ); 43 | 44 | private final int value; 45 | 46 | GetOp(int value) { 47 | 48 | this.value = value; 49 | } 50 | 51 | public int getValue() { 52 | return value; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lmdbjni/src/main/java/org/fusesource/lmdbjni/Value.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.fusesource.lmdbjni; 20 | 21 | /** 22 | * @author Hiram Chirino 23 | */ 24 | class Value extends JNI.MDB_val { 25 | 26 | public Value() { 27 | } 28 | 29 | public Value(long data, long length) { 30 | this.mv_data = data; 31 | this.mv_size = length; 32 | } 33 | 34 | public Value(NativeBuffer buffer) { 35 | this(buffer.pointer(), buffer.capacity()); 36 | } 37 | 38 | public static Value create(NativeBuffer buffer) { 39 | if(buffer == null ) { 40 | return null; 41 | } else { 42 | return new Value(buffer); 43 | } 44 | } 45 | 46 | public byte[] toByteArray() { 47 | if( mv_data == 0 ) { 48 | return null; 49 | } 50 | if( mv_size > Integer.MAX_VALUE ) { 51 | throw new ArrayIndexOutOfBoundsException("Native slice is larger than the maximum Java array"); 52 | } 53 | byte []rc = new byte[(int) mv_size]; 54 | JNI.buffer_copy(mv_data, 0, rc, 0, rc.length); 55 | return rc; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/src/lmdbjni.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef LMDBJNI_H 20 | #define LMDBJNI_H 21 | 22 | #ifdef HAVE_CONFIG_H 23 | /* configure based build.. we will use what it discovered about the platform */ 24 | #include "config.h" 25 | #endif 26 | #if defined(_WIN32) || defined(_WIN64) 27 | /* Windows based build */ 28 | #define _WIN32_WINNT 0x0501 29 | #include 30 | #endif 31 | #if !defined(HAVE_CONFIG_H) && (defined(_WIN32) || defined(_WIN64)) 32 | #define HAVE_STDLIB_H 1 33 | #define HAVE_STRINGS_H 1 34 | #endif 35 | 36 | #ifdef HAVE_UNISTD_H 37 | #include 38 | #endif 39 | 40 | #ifdef HAVE_STDLIB_H 41 | #include 42 | #endif 43 | 44 | #ifdef HAVE_STRINGS_H 45 | #include 46 | #endif 47 | 48 | #ifdef HAVE_SYS_ERRNO_H 49 | #include 50 | #endif 51 | 52 | #include "hawtjni.h" 53 | #include 54 | #include 55 | #include "lmdb.h" 56 | 57 | #ifdef __cplusplus 58 | extern "C" { 59 | #endif 60 | 61 | void buffer_copy(const void *source, size_t source_pos, void *dest, size_t dest_pos, size_t length); 62 | 63 | #ifdef __cplusplus 64 | } /* extern "C" */ 65 | #endif 66 | 67 | 68 | #endif /* LMDBJNI_H */ 69 | -------------------------------------------------------------------------------- /lmdbjni/src/main/java/org/fusesource/lmdbjni/Util.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.fusesource.lmdbjni; 20 | 21 | import static org.fusesource.lmdbjni.JNI.mdb_strerror; 22 | import static org.fusesource.lmdbjni.JNI.strlen; 23 | 24 | /** 25 | * Some miscellaneous utility functions. 26 | * 27 | * @author Hiram Chirino 28 | */ 29 | class Util { 30 | 31 | public static int errno() { 32 | return errno(); 33 | } 34 | 35 | public static String strerror() { 36 | return string(JNI.strerror(errno())); 37 | } 38 | 39 | public static String string(long ptr) { 40 | if( ptr == 0 ) 41 | return null; 42 | return new String(NativeBuffer.create(ptr, strlen(ptr)).toByteArray()); 43 | } 44 | 45 | public static void checkErrorCode(int rc) { 46 | if( rc != 0 ) { 47 | String msg = string(mdb_strerror(rc)); 48 | throw new LMDBException(msg, rc); 49 | } 50 | } 51 | 52 | public static void checkArgNotNull(Object value, String name) { 53 | if(value==null) { 54 | throw new IllegalArgumentException("The "+name+" argument cannot be null"); 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /lmdbjni-all/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 23 | 24 | 4.0.0 25 | 26 | org.deephacks.lmdbjni 27 | lmdbjni-project 28 | 0.1.3-SNAPSHOT 29 | 30 | 31 | lmdbjni-all 32 | 0.1.3-SNAPSHOT 33 | jar 34 | 35 | ${project.artifactId} 36 | An uber jar which contains all the lmdbjni platform libraries and dependencies 37 | 38 | 39 | 40 | org.deephacks.lmdbjni 41 | lmdbjni 42 | 0.1.3-SNAPSHOT 43 | 44 | 45 | org.deephacks.lmdbjni 46 | lmdbjni-osx64 47 | 0.1.3-SNAPSHOT 48 | 49 | 50 | org.deephacks.lmdbjni 51 | lmdbjni-linux64 52 | 0.1.3-SNAPSHOT 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/src/config.h.in: -------------------------------------------------------------------------------- 1 | /* src/config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DLFCN_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_INTTYPES_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_MEMORY_H 11 | 12 | /* Define to 1 if you have the header file. */ 13 | #undef HAVE_PTHREAD_H 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_STDINT_H 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_STDLIB_H 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_STRINGS_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_STRING_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_SYS_ERRNO_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_SYS_STAT_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_SYS_TYPES_H 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_UNISTD_H 38 | 39 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 40 | */ 41 | #undef LT_OBJDIR 42 | 43 | /* Name of package */ 44 | #undef PACKAGE 45 | 46 | /* Define to the address where bug reports for this package should be sent. */ 47 | #undef PACKAGE_BUGREPORT 48 | 49 | /* Define to the full name of this package. */ 50 | #undef PACKAGE_NAME 51 | 52 | /* Define to the full name and version of this package. */ 53 | #undef PACKAGE_STRING 54 | 55 | /* Define to the one symbol short name of this package. */ 56 | #undef PACKAGE_TARNAME 57 | 58 | /* Define to the home page for this package. */ 59 | #undef PACKAGE_URL 60 | 61 | /* Define to the version of this package. */ 62 | #undef PACKAGE_VERSION 63 | 64 | /* Define to 1 if you have the ANSI C header files. */ 65 | #undef STDC_HEADERS 66 | 67 | /* Version number of package */ 68 | #undef VERSION 69 | -------------------------------------------------------------------------------- /lmdbjni/src/main/java/org/fusesource/lmdbjni/LMDBException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.fusesource.lmdbjni; 20 | 21 | import org.fusesource.hawtjni.runtime.JniField; 22 | 23 | import static org.fusesource.hawtjni.runtime.FieldFlag.CONSTANT; 24 | 25 | /** 26 | * @author Hiram Chirino 27 | */ 28 | public class LMDBException extends RuntimeException { 29 | 30 | public static final int KEYEXIST = JNI.MDB_KEYEXIST; 31 | public static final int NOTFOUND = JNI.MDB_NOTFOUND; 32 | public static final int PAGE_NOTFOUND = JNI.MDB_PAGE_NOTFOUND; 33 | public static final int CORRUPTED = JNI.MDB_CORRUPTED; 34 | public static final int PANIC = JNI.MDB_PANIC; 35 | public static final int VERSION_MISMATCH = JNI.MDB_VERSION_MISMATCH; 36 | public static final int INVALID = JNI.MDB_INVALID; 37 | public static final int MAP_FULL = JNI.MDB_MAP_FULL; 38 | public static final int DBS_FULL = JNI.MDB_DBS_FULL; 39 | public static final int READERS_FULL = JNI.MDB_READERS_FULL; 40 | public static final int TLS_FULL = JNI.MDB_TLS_FULL; 41 | public static final int TXN_FULL = JNI.MDB_TXN_FULL; 42 | public static final int CURSOR_FULL = JNI.MDB_CURSOR_FULL; 43 | public static final int PAGE_FULL = JNI.MDB_PAGE_FULL; 44 | public static final int MAP_RESIZED = JNI.MDB_MAP_RESIZED; 45 | public static final int INCOMPATIBLE = JNI.MDB_INCOMPATIBLE; 46 | public static final int BAD_RSLOT = JNI.MDB_BAD_RSLOT; 47 | 48 | int errorCode; 49 | 50 | public LMDBException() { 51 | } 52 | 53 | public LMDBException(String message) { 54 | super(message); 55 | } 56 | 57 | public LMDBException(String message, int errorCode) { 58 | super(message); 59 | this.errorCode = errorCode; 60 | } 61 | 62 | public int getErrorCode() { 63 | return errorCode; 64 | } 65 | 66 | public void setErrorCode(int errorCode) { 67 | this.errorCode = errorCode; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /lmdbjni/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 23 | 24 | 4.0.0 25 | 26 | org.deephacks.lmdbjni 27 | lmdbjni-project 28 | 0.1.3-SNAPSHOT 29 | 30 | 31 | lmdbjni 32 | 0.1.3-SNAPSHOT 33 | jar 34 | 35 | ${project.artifactId} 36 | 37 | 38 | false 39 | 40 | 41 | 42 | 43 | org.fusesource.hawtjni 44 | hawtjni-runtime 45 | ${hawtjni-version} 46 | 47 | 48 | 49 | 50 | 51 | 52 | ${project.basedir}/src/main/resources 53 | true 54 | 55 | **/* 56 | 57 | 58 | 59 | 60 | 61 | org.fusesource.hawtjni 62 | maven-hawtjni-plugin 63 | ${hawtjni-version} 64 | 65 | 66 | 67 | generate 68 | package-source 69 | 70 | 71 | 72 | 73 | ${skipAutogen} 74 | lmdbjni 75 | false 76 | 87 | 88 | 89 | 90 | 91 | org.apache.maven.plugins 92 | maven-surefire-plugin 93 | 2.4.3 94 | 95 | true 96 | once 97 | -ea 98 | false 99 | ${project.build.directory} 100 | 101 | **/* 102 | 103 | 104 | **/*Test.java 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /lmdbjni/src/main/java/org/fusesource/lmdbjni/Cursor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.fusesource.lmdbjni; 20 | 21 | 22 | import java.io.Closeable; 23 | 24 | import static org.fusesource.lmdbjni.JNI.*; 25 | import static org.fusesource.lmdbjni.Util.checkArgNotNull; 26 | import static org.fusesource.lmdbjni.Util.checkErrorCode; 27 | 28 | /** 29 | * @author Hiram Chirino 30 | */ 31 | public class Cursor extends NativeObject implements Closeable { 32 | 33 | private final Env env; 34 | 35 | Cursor(Env env, long self) { 36 | super(self); 37 | this.env = env; 38 | } 39 | 40 | public void close() { 41 | if( self!=0 ) { 42 | mdb_cursor_close(self); 43 | self=0; 44 | } 45 | } 46 | 47 | public void renew(Transaction tx) { 48 | checkErrorCode(mdb_cursor_renew(tx.pointer(), pointer())); 49 | } 50 | 51 | public Entry get(GetOp op) { 52 | checkArgNotNull(op, "op"); 53 | 54 | Value key = new Value(); 55 | Value value = new Value(); 56 | int rc = mdb_cursor_get(pointer(), key, value, op.getValue()); 57 | if( rc == MDB_NOTFOUND ) { 58 | return null; 59 | } 60 | checkErrorCode(rc); 61 | return new Entry(key.toByteArray(), value.toByteArray()); 62 | } 63 | 64 | public Entry seek(SeekOp op, byte[] key) { 65 | checkArgNotNull(key, "key"); 66 | checkArgNotNull(op, "op"); 67 | NativeBuffer keyBuffer = NativeBuffer.create(key); 68 | try { 69 | Value keyValue = new Value(keyBuffer); 70 | Value value = new Value(); 71 | int rc = mdb_cursor_get(pointer(), keyValue, value, op.getValue()); 72 | if( rc == MDB_NOTFOUND ) { 73 | return null; 74 | } 75 | checkErrorCode(rc); 76 | return new Entry(keyValue.toByteArray(), value.toByteArray()); 77 | } finally { 78 | keyBuffer.delete(); 79 | } 80 | 81 | } 82 | 83 | public byte[] put(byte[] key, byte[] value, int flags) { 84 | checkArgNotNull(key, "key"); 85 | checkArgNotNull(value, "value"); 86 | NativeBuffer keyBuffer = NativeBuffer.create(key); 87 | try { 88 | NativeBuffer valueBuffer = NativeBuffer.create(value); 89 | try { 90 | return put(keyBuffer, valueBuffer, flags); 91 | } finally { 92 | valueBuffer.delete(); 93 | } 94 | } finally { 95 | keyBuffer.delete(); 96 | } 97 | } 98 | 99 | private byte[] put(NativeBuffer keyBuffer, NativeBuffer valueBuffer, int flags) { 100 | return put(new Value(keyBuffer), new Value(valueBuffer), flags); 101 | } 102 | private byte[] put(Value keySlice, Value valueSlice, int flags) { 103 | mdb_cursor_put(pointer(), keySlice, valueSlice, flags); 104 | return valueSlice.toByteArray(); 105 | } 106 | 107 | public void delete() { 108 | checkErrorCode(mdb_cursor_del(pointer(), 0)); 109 | } 110 | 111 | public void deleteIncludingDups() { 112 | checkErrorCode(mdb_cursor_del(pointer(), MDB_NODUPDATA)); 113 | } 114 | 115 | public long count() { 116 | long rc[] = new long[1]; 117 | checkErrorCode(mdb_cursor_count(pointer(), rc)); 118 | return rc[0]; 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # LMDB JNI 2 | 3 | [![Build Status](https://travis-ci.org/deephacks/lmdbjni.png?branch=master)](https://travis-ci.org/deephacks/lmdbjni) 4 | 5 | ## Description 6 | 7 | LMDB JNI gives you a Java interface to the 8 | [OpenLDAP Lightning Memory-Mapped Database](http://symas.com/mdb/) library 9 | which is a fast key-value storage library written for OpenLDAP project. 10 | 11 | This is a fork that build on the work found at https://github.com/chirino/lmdbjni. 12 | 13 | ## Using Prebuilt Jar 14 | 15 | The prebuilt binary jars only work on 64 bit OS X or Linux machines. 16 | 17 | ### License 18 | 19 | This project is licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) but the binary jar it produces also includes `liblmdb` library version 0.9.10 of the OpenLDAP project which is licensed under the [The OpenLDAP Public License](http://www.openldap.org/software/release/license.html). 20 | 21 | ### Using as a Maven Dependency 22 | 23 | Add one (or all) of the following dependency to your Maven `pom.xml`. 24 | 25 | ```xml 26 | 27 | 28 | org.deephacks.lmdbjni 29 | lmdbjni-linux64 30 | 0.1.1 31 | 32 | 33 | 34 | org.deephacks.lmdbjni 35 | lmdbjni-osx64 36 | 0.1.1 37 | 38 | 39 | 40 | org.deephacks.lmdbjni 41 | lmdbjni-win64 42 | 0.1.1 43 | 44 | ``` 45 | 46 | ## API Usage: 47 | 48 | Recommended Package imports: 49 | 50 | import org.fusesource.lmdbjni.*; 51 | import static org.fusesource.lmdbjni.Constants.*; 52 | 53 | Opening and closing the database. 54 | 55 | Env env = new Env(); 56 | try { 57 | env.open("/tmp/mydb"); 58 | Database db = env.openDatabase("foo"); 59 | 60 | ... // use the db 61 | db.close(); 62 | } finally { 63 | // Make sure you close the env to avoid resource leaks. 64 | env.close(); 65 | } 66 | 67 | Putting, Getting, and Deleting key/values. 68 | 69 | db.put(bytes("Tampa"), bytes("rocks")); 70 | String value = string(db.get(bytes("Tampa"))); 71 | db.delete(bytes("Tampa")); 72 | 73 | Performing Atomic/Transacted Updates: 74 | 75 | Transaction tx = env.createTransaction(); 76 | boolean ok = false; 77 | try { 78 | db.delete(tx, bytes("Denver")); 79 | db.put(tx, bytes("Tampa"), bytes("green")); 80 | db.put(tx, bytes("London"), bytes("red")); 81 | ok = true; 82 | } finally { 83 | // Make sure you either commit or rollback to avoid resource leaks. 84 | if( ok ) { 85 | tx.commit(); 86 | } else { 87 | tx.abort(); 88 | } 89 | } 90 | 91 | Working against a Snapshot view of the Database: 92 | 93 | // cerate a read-only transaction... 94 | Transaction tx = env.createTransaction(true); 95 | try { 96 | 97 | // All read operations will now use the same 98 | // consistent view of the data. 99 | ... = db.db.openCursor(tx); 100 | ... = db.get(tx, bytes("Tampa")); 101 | 102 | } finally { 103 | // Make sure you commit the transaction to avoid resource leaks. 104 | tx.commit(); 105 | } 106 | 107 | Iterating key/values: 108 | 109 | Transaction tx = env.createTransaction(true); 110 | try { 111 | Cursor cursor = db.openCursor(tx); 112 | try { 113 | for( Entry entry = cursor.get(FIRST); entry !=null; entry = cursor.get(NEXT) ) { 114 | String key = string(entry.getKey()); 115 | String value = string(entry.getValue()); 116 | System.out.println(key+" = "+value); 117 | } 118 | } finally { 119 | // Make sure you close the cursor to avoid leaking reasources. 120 | cursor.close(); 121 | } 122 | 123 | } finally { 124 | // Make sure you commit the transaction to avoid resource leaks. 125 | tx.commit(); 126 | } 127 | 128 | Using a memory pool to make native memory allocations more efficient: 129 | 130 | Env.pushMemoryPool(1024 * 512); 131 | try { 132 | // .. work with the DB in here, 133 | } finally { 134 | Env.popMemoryPool(); 135 | } 136 | 137 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/m4/osx-universal.m4: -------------------------------------------------------------------------------- 1 | dnl --------------------------------------------------------------------------- 2 | dnl Copyright (C) 2009-2011 FuseSource Corp. 3 | dnl http://fusesource.com 4 | dnl 5 | dnl Licensed under the Apache License, Version 2.0 (the "License"); 6 | dnl you may not use this file except in compliance with the License. 7 | dnl You may obtain a copy of the License at 8 | dnl 9 | dnl http://www.apache.org/licenses/LICENSE-2.0 10 | dnl 11 | dnl Unless required by applicable law or agreed to in writing, software 12 | dnl distributed under the License is distributed on an "AS IS" BASIS, 13 | dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | dnl See the License for the specific language governing permissions and 15 | dnl limitations under the License. 16 | dnl --------------------------------------------------------------------------- 17 | dnl --------------------------------------------------------------------------- 18 | dnl SYNOPSIS: 19 | dnl 20 | dnl WITH_OSX_UNIVERSAL() 21 | dnl 22 | dnl Allows creating universal binaries on the 23 | dnl 24 | dnl Adds the --with-universal=ARCH option. This will will 25 | dnl set -isysroot option to the location of the MacOSX${OSX_VERSION}.sdk. 26 | dnl if OSX_VERSION is not defined, it will set it to the latest version 27 | dnl of the SDK installed on your system. 28 | dnl 29 | dnl You must use the no-dependencies option when automake is initialized. 30 | dnl for example: AM_INIT_AUTOMAKE([no-dependencies]) 31 | dnl 32 | dnl This macro calls: 33 | dnl AC_SUBST(CFLAGS) 34 | dnl AC_SUBST(CXXFLAGS) 35 | dnl AC_SUBST(LDFLAGS) 36 | dnl AC_SUBST(OSX_VERSION) 37 | dnl 38 | dnl AUTHOR: Hiram Chrino 39 | dnl --------------------------------------------------------------------------- 40 | 41 | AC_DEFUN([WITH_OSX_UNIVERSAL], 42 | [ 43 | AC_PREREQ([2.61]) 44 | case "$host_os" in 45 | darwin*) 46 | 47 | AC_MSG_CHECKING(OS X SDK version) 48 | AC_ARG_WITH([osxsdk], 49 | [AS_HELP_STRING([--with-osxsdk@<:@=VERSION@:>@], 50 | [OS X SDK version to build against. Example: --with-osxsdk=10.6])], 51 | [ 52 | OSX_UNIVERSAL="$withval" 53 | ],[ 54 | OSX_SDKS_DIR="" 55 | OSX_VERSION="" 56 | for v in 10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 10.10 10.11 10.12; do 57 | for location in "/Developer/SDKs" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" ; do 58 | if test -z "${OSX_VERSION}" && test -d "${location}/MacOSX${v}.sdk" ; then 59 | OSX_SDKS_DIR="${location}" 60 | OSX_VERSION="${v}" 61 | fi 62 | done 63 | done 64 | ]) 65 | AC_MSG_RESULT([$OSX_VERSION]) 66 | AC_SUBST(OSX_SDKS_DIR) 67 | AC_SUBST(OSX_VERSION) 68 | 69 | AC_MSG_CHECKING(whether to build universal binaries) 70 | AC_ARG_WITH([universal], 71 | [AS_HELP_STRING([--with-universal@<:@=ARCH@:>@], 72 | [Build a universal binary. Set to a space separated architecture list. Pick from: i386, x86_64, ppc, and/or ppc64. @<:@default="i386 x86_64"@:>@])], 73 | [ 74 | AS_IF(test "$withval" = "no", [ 75 | OSX_UNIVERSAL="" 76 | AC_MSG_RESULT([no]) 77 | ], test "$withval" = "yes", [ 78 | OSX_UNIVERSAL="i386 x86_64" 79 | AC_MSG_RESULT([yes, archs: $OSX_UNIVERSAL]) 80 | ],[ 81 | OSX_UNIVERSAL="$withval" 82 | AC_MSG_RESULT([yes, archs: $OSX_UNIVERSAL]) 83 | ]) 84 | ],[ 85 | OSX_UNIVERSAL="" 86 | AC_MSG_RESULT([no]) 87 | ]) 88 | 89 | AS_IF(test -n "$OSX_UNIVERSAL", [ 90 | for i in $OSX_UNIVERSAL ; do 91 | CFLAGS="-arch $i $CFLAGS" 92 | CXXFLAGS="-arch $i $CXXFLAGS" 93 | LDFLAGS="-arch $i $LDFLAGS" 94 | done 95 | 96 | 97 | for f in $__JNI_INCLUDE_EXTRAS ; do 98 | if test -d "$__JNI_INCLUDE/$f"; then 99 | __JNI_CFLAGS="$__JNI_CFLAGS -I$__JNI_INCLUDE/$f" 100 | fi 101 | done 102 | 103 | 104 | CFLAGS="-isysroot ${OSX_SDKS_DIR}/MacOSX${OSX_VERSION}.sdk $CFLAGS" 105 | CXXFLAGS="-isysroot ${OSX_SDKS_DIR}/MacOSX${OSX_VERSION}.sdk $CXXFLAGS" 106 | LDFLAGS="-syslibroot,${OSX_SDKS_DIR}/MacOSX${OSX_VERSION}.sdk $LDFLAGS" 107 | AC_SUBST(CFLAGS) 108 | AC_SUBST(CXXFLAGS) 109 | AC_SUBST(LDFLAGS) 110 | ]) 111 | ;; 112 | esac 113 | ]) 114 | 115 | 116 | -------------------------------------------------------------------------------- /lmdbjni/src/main/java/org/fusesource/lmdbjni/Constants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.fusesource.lmdbjni; 20 | 21 | import java.io.UnsupportedEncodingException; 22 | 23 | import static org.fusesource.lmdbjni.JNI.*; 24 | 25 | /** 26 | * @author Hiram Chirino 27 | */ 28 | public class Constants { 29 | 30 | public static final int FIXEDMAP = MDB_FIXEDMAP ; 31 | public static final int NOSUBDIR = MDB_NOSUBDIR ; 32 | public static final int NOSYNC = MDB_NOSYNC ; 33 | public static final int RDONLY = MDB_RDONLY ; 34 | public static final int NOMETASYNC = MDB_NOMETASYNC ; 35 | public static final int WRITEMAP = MDB_WRITEMAP ; 36 | public static final int MAPASYNC = MDB_MAPASYNC ; 37 | public static final int NOTLS = MDB_NOTLS ; 38 | 39 | //====================================================// 40 | // Database Flags 41 | //====================================================// 42 | public static final int REVERSEKEY = MDB_REVERSEKEY ; 43 | public static final int DUPSORT = MDB_DUPSORT ; 44 | public static final int INTEGERKEY = MDB_INTEGERKEY ; 45 | public static final int DUPFIXED = MDB_DUPFIXED ; 46 | public static final int INTEGERDUP = MDB_INTEGERDUP ; 47 | public static final int REVERSEDUP = MDB_REVERSEDUP ; 48 | public static final int CREATE = MDB_CREATE ; 49 | 50 | //====================================================// 51 | // Write Flags 52 | //====================================================// 53 | public static final int NOOVERWRITE = MDB_NOOVERWRITE ; 54 | public static final int NODUPDATA = MDB_NODUPDATA ; 55 | public static final int CURRENT = MDB_CURRENT ; 56 | public static final int RESERVE = MDB_RESERVE ; 57 | public static final int APPEND = MDB_APPEND ; 58 | public static final int APPENDDUP = MDB_APPENDDUP ; 59 | public static final int MULTIPLE = MDB_MULTIPLE ; 60 | 61 | public static final GetOp FIRST = GetOp.FIRST ; 62 | public static final GetOp FIRST_DUP = GetOp.FIRST_DUP ; 63 | public static final GetOp GET_BOTH = GetOp.GET_BOTH ; 64 | public static final GetOp GET_BOTH_RANGE = GetOp.GET_BOTH_RANGE ; 65 | public static final GetOp GET_CURRENT = GetOp.GET_CURRENT ; 66 | public static final GetOp GET_MULTIPLE = GetOp.GET_MULTIPLE ; 67 | public static final GetOp LAST = GetOp.LAST ; 68 | public static final GetOp LAST_DUP = GetOp.LAST_DUP ; 69 | public static final GetOp NEXT = GetOp.NEXT ; 70 | public static final GetOp NEXT_DUP = GetOp.NEXT_DUP ; 71 | public static final GetOp NEXT_MULTIPLE = GetOp.NEXT_MULTIPLE ; 72 | public static final GetOp NEXT_NODUP = GetOp.NEXT_NODUP ; 73 | public static final GetOp PREV = GetOp.PREV ; 74 | public static final GetOp PREV_DUP = GetOp.PREV_DUP ; 75 | public static final GetOp PREV_NODUP = GetOp.PREV_NODUP ; 76 | 77 | public static final SeekOp KEY = SeekOp.KEY; 78 | public static final SeekOp RANGE = SeekOp.RANGE; 79 | 80 | public static byte[] bytes(String value) { 81 | if( value == null) { 82 | return null; 83 | } 84 | try { 85 | return value.getBytes("UTF-8"); 86 | } catch (UnsupportedEncodingException e) { 87 | throw new RuntimeException(e); 88 | } 89 | } 90 | 91 | public static String string(byte value[]) { 92 | if( value == null) { 93 | return null; 94 | } 95 | try { 96 | return new String(value, "UTF-8"); 97 | } catch (UnsupportedEncodingException e) { 98 | throw new RuntimeException(e); 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /lmdbjni/src/test/java/org/fusesource/lmdbjni/test/EnvTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.fusesource.lmdbjni.test; 20 | 21 | import junit.framework.TestCase; 22 | import org.fusesource.lmdbjni.*; 23 | import org.junit.Test; 24 | 25 | import java.io.File; 26 | import java.io.IOException; 27 | import java.lang.reflect.Field; 28 | import java.util.Arrays; 29 | import java.util.LinkedList; 30 | 31 | import static org.fusesource.lmdbjni.Constants.FIRST; 32 | import static org.fusesource.lmdbjni.Constants.NEXT; 33 | import static org.fusesource.lmdbjni.Constants.*; 34 | 35 | /** 36 | * Unit tests for the LMDB API. 37 | * 38 | * @author Hiram Chirino 39 | */ 40 | public class EnvTest extends TestCase { 41 | 42 | static public void assertEquals(byte[] arg1, byte[] arg2) { 43 | assertTrue(Arrays.equals(arg1, arg2)); 44 | } 45 | 46 | static File getTestDirectory(String name) throws IOException { 47 | File rc = new File(new File("test-data"), name); 48 | rc.mkdirs(); 49 | return rc; 50 | } 51 | 52 | @Test 53 | public void testCRUD() throws Exception { 54 | addLibraryPath("/usr/local/lib" ); 55 | String path = getTestDirectory(getName()).getCanonicalPath(); 56 | Env env = new Env(); 57 | env.open(path); 58 | Database db = env.openDatabase("foo"); 59 | 60 | assertNull(db.put(bytes("Tampa"), bytes("green"))); 61 | assertNull(db.put(bytes("London"), bytes("red"))); 62 | 63 | assertNull(db.put(bytes("New York"), bytes("gray"))); 64 | assertNull(db.put(bytes("New York"), bytes("blue"))); 65 | assertEquals(db.put(bytes("New York"), bytes("silver"), NOOVERWRITE), bytes("blue")); 66 | 67 | assertEquals(db.get(bytes("Tampa")), bytes("green")); 68 | assertEquals(db.get(bytes("London")), bytes("red")); 69 | assertEquals(db.get(bytes("New York")), bytes("blue")); 70 | 71 | 72 | Transaction tx = env.createTransaction(); 73 | Cursor cursor = db.openCursor(tx); 74 | 75 | // Lets verify cursoring works.. 76 | LinkedList keys = new LinkedList(); 77 | LinkedList values = new LinkedList(); 78 | for( Entry entry = cursor.get(FIRST); entry !=null; entry = cursor.get(NEXT) ) { 79 | keys.add(string(entry.getKey())); 80 | values.add(string(entry.getValue())); 81 | } 82 | tx.commit(); 83 | assertEquals(Arrays.asList(new String[]{"London", "New York", "Tampa"}), keys); 84 | assertEquals(Arrays.asList(new String[]{"red", "blue", "green"}), values); 85 | 86 | assertTrue(db.delete(bytes("New York"))); 87 | assertNull(db.get(bytes("New York"))); 88 | 89 | // We should not be able to delete it again. 90 | assertFalse(db.delete(bytes("New York"))); 91 | 92 | // put /w readonly transaction should fail. 93 | tx = env.createTransaction(true); 94 | try { 95 | db.put(tx, bytes("New York"), bytes("silver")); 96 | fail("Expected LMDBException"); 97 | } catch (LMDBException e) { 98 | assertTrue(e.getErrorCode() > 0); 99 | } 100 | 101 | db.close(); 102 | env.close(); 103 | } 104 | public static void addLibraryPath(String pathToAdd) throws Exception{ 105 | final Field usrPathsField = ClassLoader.class.getDeclaredField("usr_paths"); 106 | usrPathsField.setAccessible(true); 107 | 108 | //get array of paths 109 | final String[] paths = (String[])usrPathsField.get(null); 110 | 111 | //check if the path to add is already present 112 | for(String path : paths) { 113 | if(path.equals(pathToAdd)) { 114 | return; 115 | } 116 | } 117 | 118 | //add the new path 119 | final String[] newPaths = Arrays.copyOf(paths, paths.length + 1); 120 | newPaths[newPaths.length-1] = pathToAdd; 121 | usrPathsField.set(null, newPaths); 122 | } 123 | 124 | 125 | } 126 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/m4/ltsugar.m4: -------------------------------------------------------------------------------- 1 | # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 4 | # Written by Gary V. Vaughan, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 6 ltsugar.m4 11 | 12 | # This is to help aclocal find these macros, as it can't see m4_define. 13 | AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 14 | 15 | 16 | # lt_join(SEP, ARG1, [ARG2...]) 17 | # ----------------------------- 18 | # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 19 | # associated separator. 20 | # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 21 | # versions in m4sugar had bugs. 22 | m4_define([lt_join], 23 | [m4_if([$#], [1], [], 24 | [$#], [2], [[$2]], 25 | [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 26 | m4_define([_lt_join], 27 | [m4_if([$#$2], [2], [], 28 | [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 29 | 30 | 31 | # lt_car(LIST) 32 | # lt_cdr(LIST) 33 | # ------------ 34 | # Manipulate m4 lists. 35 | # These macros are necessary as long as will still need to support 36 | # Autoconf-2.59 which quotes differently. 37 | m4_define([lt_car], [[$1]]) 38 | m4_define([lt_cdr], 39 | [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 40 | [$#], 1, [], 41 | [m4_dquote(m4_shift($@))])]) 42 | m4_define([lt_unquote], $1) 43 | 44 | 45 | # lt_append(MACRO-NAME, STRING, [SEPARATOR]) 46 | # ------------------------------------------ 47 | # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. 48 | # Note that neither SEPARATOR nor STRING are expanded; they are appended 49 | # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 50 | # No SEPARATOR is output if MACRO-NAME was previously undefined (different 51 | # than defined and empty). 52 | # 53 | # This macro is needed until we can rely on Autoconf 2.62, since earlier 54 | # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 55 | m4_define([lt_append], 56 | [m4_define([$1], 57 | m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 58 | 59 | 60 | 61 | # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 62 | # ---------------------------------------------------------- 63 | # Produce a SEP delimited list of all paired combinations of elements of 64 | # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 65 | # has the form PREFIXmINFIXSUFFIXn. 66 | # Needed until we can rely on m4_combine added in Autoconf 2.62. 67 | m4_define([lt_combine], 68 | [m4_if(m4_eval([$# > 3]), [1], 69 | [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 70 | [[m4_foreach([_Lt_prefix], [$2], 71 | [m4_foreach([_Lt_suffix], 72 | ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 73 | [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 74 | 75 | 76 | # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 77 | # ----------------------------------------------------------------------- 78 | # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 79 | # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 80 | m4_define([lt_if_append_uniq], 81 | [m4_ifdef([$1], 82 | [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 83 | [lt_append([$1], [$2], [$3])$4], 84 | [$5])], 85 | [lt_append([$1], [$2], [$3])$4])]) 86 | 87 | 88 | # lt_dict_add(DICT, KEY, VALUE) 89 | # ----------------------------- 90 | m4_define([lt_dict_add], 91 | [m4_define([$1($2)], [$3])]) 92 | 93 | 94 | # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 95 | # -------------------------------------------- 96 | m4_define([lt_dict_add_subkey], 97 | [m4_define([$1($2:$3)], [$4])]) 98 | 99 | 100 | # lt_dict_fetch(DICT, KEY, [SUBKEY]) 101 | # ---------------------------------- 102 | m4_define([lt_dict_fetch], 103 | [m4_ifval([$3], 104 | m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 105 | m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 106 | 107 | 108 | # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 109 | # ----------------------------------------------------------------- 110 | m4_define([lt_if_dict_fetch], 111 | [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 112 | [$5], 113 | [$6])]) 114 | 115 | 116 | # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 117 | # -------------------------------------------------------------- 118 | m4_define([lt_dict_filter], 119 | [m4_if([$5], [], [], 120 | [lt_join(m4_quote(m4_default([$4], [[, ]])), 121 | lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 122 | [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 123 | ]) 124 | -------------------------------------------------------------------------------- /lmdbjni-win64/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 23 | 24 | 4.0.0 25 | 26 | org.deephacks.lmdbjni 27 | lmdbjni-project 28 | 0.1.3-SNAPSHOT 29 | 30 | 31 | lmdbjni-win64 32 | 0.1.3-SNAPSHOT 33 | 34 | ${project.artifactId} 35 | The lmdbjni Windows 64 bit native libraries 36 | 37 | 38 | ${project.build.directory}/lmdb/META-INF/native/lmdb-win64 39 | 40 | 41 | 42 | 43 | org.deephacks.lmdb 44 | lmdb-win64 45 | ${lmdb-version} 46 | 47 | 48 | org.deephacks.lmdbjni 49 | lmdbjni 50 | 0.1.3-SNAPSHOT 51 | 52 | 53 | 54 | 55 | ${basedir}/../lmdbjni/src/test/java 56 | 57 | 58 | 59 | org.apache.maven.plugins 60 | maven-dependency-plugin 61 | 2.8 62 | 63 | 64 | unpack 65 | validate 66 | 67 | unpack 68 | 69 | 70 | 71 | 72 | org.deephacks.lmdb 73 | lmdb-win64 74 | ${lmdb-version} 75 | jar 76 | false 77 | ${project.build.directory}/lmdb 78 | META-INF/** 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | org.apache.maven.plugins 87 | maven-jar-plugin 88 | 2.3.1 89 | 90 | ${basedir}/target/generated-sources/hawtjni/lib 91 | 92 | 93 | 94 | maven-surefire-plugin 95 | 96 | once 97 | 98 | ${lmdb-home} 99 | 100 | 101 | 102 | java.library.tmpdir 103 | ${lmdb-home} 104 | 105 | 106 | 107 | 108 | 109 | org.fusesource.hawtjni 110 | maven-hawtjni-plugin 111 | ${hawtjni-version} 112 | 113 | 114 | 115 | build 116 | 117 | 118 | 119 | 120 | lmdbjni 121 | false 122 | 123 | org.deephacks.lmdbjni 124 | lmdbjni 125 | ${project.version} 126 | native-src 127 | zip 128 | 129 | ${basedir}/../lmdbjni/target/generated-sources/hawtjni/native-package 130 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /lmdbjni-osx64/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 23 | 24 | 4.0.0 25 | 26 | org.deephacks.lmdbjni 27 | lmdbjni-project 28 | 0.1.3-SNAPSHOT 29 | 30 | 31 | lmdbjni-osx64 32 | 0.1.3-SNAPSHOT 33 | 34 | ${project.artifactId} 35 | The lmdbjni osx 64 bit native libraries 36 | 37 | 38 | ${project.build.directory}/lmdb/META-INF/native/lmdb-osx64 39 | 40 | 41 | 42 | 43 | org.deephacks.lmdb 44 | lmdb-osx64 45 | ${lmdb-version} 46 | 47 | 48 | org.deephacks.lmdbjni 49 | lmdbjni 50 | 0.1.3-SNAPSHOT 51 | 52 | 53 | 54 | 55 | ${basedir}/../lmdbjni/src/test/java 56 | 57 | 58 | 59 | org.apache.maven.plugins 60 | maven-dependency-plugin 61 | 2.8 62 | 63 | 64 | unpack 65 | validate 66 | 67 | unpack 68 | 69 | 70 | 71 | 72 | org.deephacks.lmdb 73 | lmdb-osx64 74 | ${lmdb-version} 75 | jar 76 | false 77 | ${project.build.directory}/lmdb 78 | META-INF/** 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | org.apache.maven.plugins 87 | maven-jar-plugin 88 | 2.3.1 89 | 90 | ${basedir}/target/generated-sources/hawtjni/lib 91 | 92 | 93 | 94 | maven-surefire-plugin 95 | 96 | once 97 | 98 | ${lmdb-home} 99 | 100 | 101 | 102 | java.library.tmpdir 103 | ${lmdb-home} 104 | 105 | 106 | 107 | 108 | 109 | org.fusesource.hawtjni 110 | maven-hawtjni-plugin 111 | ${hawtjni-version} 112 | 113 | 114 | 115 | build 116 | 117 | 118 | 119 | 120 | lmdbjni 121 | false 122 | 123 | org.deephacks.lmdbjni 124 | lmdbjni 125 | ${project.version} 126 | native-src 127 | zip 128 | 129 | 130 | 131 | --with-lmdb=${lmdb-home} 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /lmdbjni-linux64/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 23 | 24 | 4.0.0 25 | 26 | org.deephacks.lmdbjni 27 | lmdbjni-project 28 | 0.1.3-SNAPSHOT 29 | 30 | 31 | lmdbjni-linux64 32 | 0.1.3-SNAPSHOT 33 | 34 | ${project.artifactId} 35 | The lmdbjni linux 64 bit native libraries 36 | 37 | 38 | ${project.build.directory}/lmdb/META-INF/native/lmdb-linux64 39 | 40 | 41 | 42 | 43 | org.deephacks.lmdb 44 | lmdb-linux64 45 | ${lmdb-version} 46 | 47 | 48 | org.deephacks.lmdbjni 49 | lmdbjni 50 | 0.1.3-SNAPSHOT 51 | 52 | 53 | 54 | 55 | ${basedir}/../lmdbjni/src/test/java 56 | 57 | 58 | 59 | org.apache.maven.plugins 60 | maven-dependency-plugin 61 | 2.8 62 | 63 | 64 | unpack 65 | validate 66 | 67 | unpack 68 | 69 | 70 | 71 | 72 | org.deephacks.lmdb 73 | lmdb-linux64 74 | ${lmdb-version} 75 | jar 76 | false 77 | ${project.build.directory}/lmdb 78 | META-INF/** 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | org.apache.maven.plugins 87 | maven-jar-plugin 88 | 2.3.1 89 | 90 | ${basedir}/target/generated-sources/hawtjni/lib 91 | 92 | 93 | 94 | maven-surefire-plugin 95 | 96 | once 97 | 98 | ${lmdb-home} 99 | 100 | 101 | 102 | java.library.tmpdir 103 | ${lmdb-home} 104 | 105 | 106 | 107 | 108 | 109 | org.fusesource.hawtjni 110 | maven-hawtjni-plugin 111 | ${hawtjni-version} 112 | 113 | 114 | 115 | build 116 | 117 | 118 | 119 | 120 | lmdbjni 121 | false 122 | 123 | org.deephacks.lmdbjni 124 | lmdbjni 125 | ${project.version} 126 | native-src 127 | zip 128 | 129 | 130 | 131 | --with-lmdb=${lmdb-home} 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /lmdbjni/src/main/java/org/fusesource/lmdbjni/Env.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.fusesource.lmdbjni; 20 | 21 | import java.io.Closeable; 22 | 23 | import static org.fusesource.lmdbjni.JNI.*; 24 | import static org.fusesource.lmdbjni.Util.*; 25 | 26 | /** 27 | * @author Hiram Chirino 28 | */ 29 | public class Env extends NativeObject implements Closeable { 30 | 31 | public static String version() { 32 | return string(JNI.MDB_VERSION_STRING); 33 | } 34 | 35 | public Env() { 36 | super(create()); 37 | setMaxDbs(1); 38 | } 39 | 40 | private static long create() { 41 | long env_ptr[] = new long[1]; 42 | checkErrorCode(mdb_env_create(env_ptr)); 43 | return env_ptr[0]; 44 | } 45 | 46 | public void open(String path) { 47 | open(path, 0); 48 | } 49 | 50 | public void open(String path, int flags) { 51 | open(path, flags, 0644); 52 | } 53 | 54 | public void open(String path, int flags, int mode) { 55 | int rc = mdb_env_open(pointer(), path, flags, mode); 56 | if( rc!=0 ) { 57 | close(); 58 | } 59 | checkErrorCode(rc); 60 | } 61 | 62 | public void close() { 63 | if( self!=0 ) { 64 | mdb_env_close(self); 65 | self=0; 66 | } 67 | } 68 | 69 | public void copy(String path) { 70 | checkArgNotNull(path, "path"); 71 | checkErrorCode(mdb_env_copy(pointer(), path)); 72 | } 73 | 74 | public void sync(boolean force) { 75 | checkErrorCode(mdb_env_sync(pointer(), force ? 1 : 0)); 76 | } 77 | 78 | 79 | public void setMapSize(long size) { 80 | checkErrorCode(mdb_env_set_mapsize(pointer(), size)); 81 | } 82 | 83 | public void setMaxDbs(long size) { 84 | checkErrorCode(mdb_env_set_maxdbs(pointer(), size)); 85 | } 86 | 87 | public long getMaxReaders() { 88 | long rc[] = new long[1]; 89 | checkErrorCode(mdb_env_get_maxreaders(pointer(), rc)); 90 | return rc[0]; 91 | } 92 | public void setMaxReaders(long size) { 93 | checkErrorCode(mdb_env_set_maxreaders(pointer(), size)); 94 | } 95 | 96 | public int getFlags() { 97 | long[] flags = new long[1]; 98 | checkErrorCode(mdb_env_get_flags(pointer(), flags)); 99 | return (int) flags[0]; 100 | } 101 | 102 | public void addFlags(int flags) { 103 | checkErrorCode(mdb_env_set_flags(pointer(), flags, 1)); 104 | } 105 | 106 | public void removeFlags(int flags) { 107 | checkErrorCode(mdb_env_set_flags(pointer(), flags, 0)); 108 | } 109 | 110 | public MDB_envinfo info() { 111 | MDB_envinfo rc = new MDB_envinfo(); 112 | mdb_env_info(pointer(), rc); 113 | return rc; 114 | } 115 | 116 | public MDB_stat stat() { 117 | MDB_stat rc = new MDB_stat(); 118 | mdb_env_stat(pointer(), rc); 119 | return rc; 120 | } 121 | 122 | public Transaction createTransaction() { 123 | return createTransaction(null, false); 124 | } 125 | public Transaction createTransaction(boolean readOnly) { 126 | return createTransaction(null, readOnly); 127 | } 128 | public Transaction createTransaction(Transaction parent) { 129 | return createTransaction(parent, false); 130 | } 131 | 132 | public Transaction createTransaction(Transaction parent, boolean readOnly) { 133 | long txpointer [] = new long[1]; 134 | checkErrorCode(mdb_txn_begin(pointer(), parent==null ? 0 : parent.pointer(), readOnly ? MDB_RDONLY : 0, txpointer)); 135 | return new Transaction(this, txpointer[0]); 136 | } 137 | 138 | public Database openDatabase(Transaction tx, String name, int flags) { 139 | checkArgNotNull(tx, "tx"); 140 | checkArgNotNull(name, "name"); 141 | long dbi[] = new long[1]; 142 | checkErrorCode(mdb_dbi_open(tx.pointer(), name, flags, dbi)); 143 | return new Database(this, dbi[0]); 144 | } 145 | 146 | public Database openDatabase(String name) { 147 | checkArgNotNull(name, "name"); 148 | return openDatabase(name, Constants.CREATE); 149 | } 150 | public Database openDatabase(String name, int flags) { 151 | checkArgNotNull(name, "name"); 152 | Transaction tx = createTransaction(); 153 | try { 154 | return openDatabase(tx, name, flags); 155 | } finally { 156 | tx.commit(); 157 | } 158 | } 159 | 160 | public static void pushMemoryPool(int size) { 161 | NativeBuffer.pushMemoryPool(size); 162 | } 163 | 164 | public static void popMemoryPool() { 165 | NativeBuffer.popMemoryPool(); 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/m4/jni.m4: -------------------------------------------------------------------------------- 1 | dnl --------------------------------------------------------------------------- 2 | dnl Copyright (C) 2009-2011 FuseSource Corp. 3 | dnl http://fusesource.com 4 | dnl 5 | dnl Licensed under the Apache License, Version 2.0 (the "License"); 6 | dnl you may not use this file except in compliance with the License. 7 | dnl You may obtain a copy of the License at 8 | dnl 9 | dnl http://www.apache.org/licenses/LICENSE-2.0 10 | dnl 11 | dnl Unless required by applicable law or agreed to in writing, software 12 | dnl distributed under the License is distributed on an "AS IS" BASIS, 13 | dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | dnl See the License for the specific language governing permissions and 15 | dnl limitations under the License. 16 | dnl --------------------------------------------------------------------------- 17 | dnl --------------------------------------------------------------------------- 18 | dnl SYNOPSIS: 19 | dnl 20 | dnl WITH_JNI_JDK() 21 | dnl 22 | dnl Adds the --with-jni-jdk=PATH option. If not provided, it searches 23 | dnl for the JDK in the default OS locations. 24 | dnl 25 | dnl This macro calls: 26 | dnl AC_SUBST(JNI_JDK) 27 | dnl AC_SUBST(JNI_EXTRA_CFLAGS) 28 | dnl AC_SUBST(JNI_EXTRA_LDFLAGS) 29 | dnl 30 | dnl AUTHOR: Hiram Chrino 31 | dnl --------------------------------------------------------------------------- 32 | 33 | AC_DEFUN([WITH_JNI_JDK], 34 | [ 35 | AC_PREREQ([2.61]) 36 | AC_ARG_WITH(jni-jdk, 37 | [AS_HELP_STRING([--with-jni-jdk=PATH], 38 | [Location of the Java Development Kit. Defaults to your JAVA_HOME setting and falls back to where it is typically installed on your OS])], 39 | [ 40 | if test "$withval" = "no" || test "$withval" = "yes"; then 41 | AC_MSG_ERROR([--with-jni-jdk: PATH to JDK not supplied]) 42 | fi 43 | CHECK_JNI_JDK([$withval], [], [AC_MSG_ERROR([JDK not found. Invalid --with-jni-jdk PATH])]) 44 | ],[ 45 | 46 | if test -n "$JAVA_HOME" ; then 47 | AC_MSG_NOTICE([JAVA_HOME was set, checking to see if it's a JDK we can use...]) 48 | CHECK_JNI_JDK([$JAVA_HOME], [], []) 49 | fi 50 | 51 | __JNI_GUESS=`which javac` 52 | AS_IF(test -z "$JNI_JDK" && test -n "$__JNI_GUESS", [ 53 | AC_MSG_NOTICE([javac was on your path, checking to see if it's part of a JDK we can use...]) 54 | # transitively resolve the symbolic links to javac 55 | while file -h "$__JNI_GUESS" 2>/dev/null | grep " symbolic link to " >/dev/null; do 56 | __JNI_LINK=$( file -h $__JNI_GUESS | sed 's/.*symbolic link to //' | sed "s/'$//" | sed 's/^`//' ) 57 | __JNI_GUESS=$(cd $(dirname $__JNI_GUESS); cd $(dirname $__JNI_LINK); echo "$(pwd)/$(basename $__JNI_LINK)") 58 | done 59 | # move 2 dirs up to the home dir... 60 | __JNI_GUESS=$(dirname $(dirname $__JNI_GUESS)) 61 | CHECK_JNI_JDK([$__JNI_GUESS], [], [],[]) 62 | ],[]) 63 | 64 | AS_IF(test -z "$JNI_JDK", [ 65 | case "$host_os" in 66 | darwin*) __JNI_GUESS="/System/Library/Frameworks/JavaVM.framework";; 67 | *) __JNI_GUESS="/usr";; 68 | esac 69 | AC_MSG_NOTICE([Taking a guess as to where your OS installs the JDK by default...]) 70 | CHECK_JNI_JDK([$__JNI_GUESS], [], [AC_MSG_ERROR([JDK not found. Please use the --with-jni-jdk option])]) 71 | ],[]) 72 | ]) 73 | ]) 74 | 75 | dnl --------------------------------------------------------------------------- 76 | dnl 77 | dnl JNI_CHECK_JDK_HOME(PATH, [ACTION-SUCCESS], [ACTION-FAILURE]) 78 | dnl 79 | dnl Tests to see if the given path is a valid JDK home location with 80 | dnl with a JNI headers and library that can be compiled against. 81 | dnl 82 | dnl This macro calls: 83 | dnl 84 | dnl AC_SUBST(JNI_JDK) 85 | dnl AC_SUBST(JNI_EXTRA_CFLAGS) 86 | dnl AC_SUBST(JNI_EXTRA_LDFLAGS) 87 | dnl 88 | dnl AUTHOR: Hiram Chrino 89 | dnl --------------------------------------------------------------------------- 90 | AC_DEFUN([CHECK_JNI_JDK],[ 91 | AC_PREREQ([2.61]) 92 | __JNI_JDK_HOME="$1" 93 | AC_MSG_CHECKING(if '$__JNI_JDK_HOME' is a JDK) 94 | # OSX had to be a little different. 95 | case "$host_os" in 96 | darwin*) __JNI_INCLUDE="$__JNI_JDK_HOME/Headers";; 97 | *) __JNI_INCLUDE="$__JNI_JDK_HOME/include";; 98 | esac 99 | 100 | AS_IF(test -r "$__JNI_INCLUDE/jni.h",[ 101 | 102 | # Also include the os specific include dirs in the JNI_CFLAGS 103 | __JNI_CFLAGS="-I$__JNI_INCLUDE" 104 | case "$host_os" in 105 | bsdi*) __JNI_INCLUDE_EXTRAS="bsdos";; 106 | linux*) __JNI_INCLUDE_EXTRAS="linux genunix";; 107 | osf*) __JNI_INCLUDE_EXTRAS="alpha";; 108 | solaris*) __JNI_INCLUDE_EXTRAS="solaris";; 109 | mingw*) __JNI_INCLUDE_EXTRAS="win32";; 110 | cygwin*) __JNI_INCLUDE_EXTRAS="win32";; 111 | *) __JNI_INCLUDE_EXTRAS="genunix";; 112 | esac 113 | 114 | for f in $__JNI_INCLUDE_EXTRAS ; do 115 | if test -d "$__JNI_INCLUDE/$f"; then 116 | __JNI_CFLAGS="$__JNI_CFLAGS -I$__JNI_INCLUDE/$f" 117 | fi 118 | done 119 | 120 | saved_CPPFLAGS="$CPPFLAGS" 121 | CPPFLAGS="$CPPFLAGS $__JNI_CFLAGS" 122 | JNI_VERSION="1_2" 123 | AC_LANG_PUSH(C) 124 | AC_COMPILE_IFELSE( 125 | [AC_LANG_PROGRAM([[@%:@include ]],[[ 126 | #ifndef JNI_VERSION_$JNI_VERSION 127 | # error JNI version $JNI_VERSION is not supported. 128 | #endif 129 | ]]) 130 | ],[ 131 | 132 | JNI_JDK=$"$__JNI_JDK_HOME" 133 | JNI_EXTRA_CFLAGS="$__JNI_CFLAGS" 134 | AC_SUBST(JNI_JDK) 135 | AC_SUBST(JNI_EXTRA_CFLAGS) 136 | case $host_os in 137 | darwin*) 138 | JNI_EXTRA_LDFLAGS="-shrext .jnilib -dynamiclib" ;; 139 | esac 140 | AC_SUBST(JNI_EXTRA_LDFLAGS) 141 | 142 | 143 | AC_MSG_RESULT([yes]) 144 | $2 145 | ],[ 146 | AC_MSG_RESULT([no]) 147 | $3 148 | ]) 149 | AC_LANG_POP() 150 | CPPFLAGS="$saved_CPPFLAGS" 151 | ],[ 152 | AC_MSG_RESULT([no]) 153 | $3 154 | ]) 155 | ]) 156 | 157 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/m4/lt~obsolete.m4: -------------------------------------------------------------------------------- 1 | # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004. 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 5 lt~obsolete.m4 11 | 12 | # These exist entirely to fool aclocal when bootstrapping libtool. 13 | # 14 | # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) 15 | # which have later been changed to m4_define as they aren't part of the 16 | # exported API, or moved to Autoconf or Automake where they belong. 17 | # 18 | # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN 19 | # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us 20 | # using a macro with the same name in our local m4/libtool.m4 it'll 21 | # pull the old libtool.m4 in (it doesn't see our shiny new m4_define 22 | # and doesn't know about Autoconf macros at all.) 23 | # 24 | # So we provide this file, which has a silly filename so it's always 25 | # included after everything else. This provides aclocal with the 26 | # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything 27 | # because those macros already exist, or will be overwritten later. 28 | # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 29 | # 30 | # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. 31 | # Yes, that means every name once taken will need to remain here until 32 | # we give up compatibility with versions before 1.7, at which point 33 | # we need to keep only those names which we still refer to. 34 | 35 | # This is to help aclocal find these macros, as it can't see m4_define. 36 | AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) 37 | 38 | m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) 39 | m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) 40 | m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) 41 | m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) 42 | m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) 43 | m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) 44 | m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) 45 | m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) 46 | m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) 47 | m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) 48 | m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) 49 | m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) 50 | m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) 51 | m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) 52 | m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) 53 | m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) 54 | m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) 55 | m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) 56 | m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) 57 | m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) 58 | m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) 59 | m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) 60 | m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) 61 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) 62 | m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) 63 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) 64 | m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) 65 | m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) 66 | m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) 67 | m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) 68 | m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) 69 | m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) 70 | m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) 71 | m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) 72 | m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) 73 | m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) 74 | m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) 75 | m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) 76 | m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) 77 | m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) 78 | m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) 79 | m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) 80 | m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) 81 | m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) 82 | m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) 83 | m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) 84 | m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) 85 | m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) 86 | m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) 87 | m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) 88 | m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) 89 | m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) 90 | m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) 91 | m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) 92 | m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) 93 | m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) 94 | m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) 95 | m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) 96 | m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) 97 | m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) 98 | m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) 99 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/autotools/ar-lib: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Wrapper for Microsoft lib.exe 3 | 4 | me=ar-lib 5 | scriptversion=2012-03-01.08; # UTC 6 | 7 | # Copyright (C) 2010-2012 Free Software Foundation, Inc. 8 | # Written by Peter Rosin . 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2, or (at your option) 13 | # any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program. If not, see . 22 | 23 | # As a special exception to the GNU General Public License, if you 24 | # distribute this file as part of a program that contains a 25 | # configuration script generated by Autoconf, you may include it under 26 | # the same distribution terms that you use for the rest of that program. 27 | 28 | # This file is maintained in Automake, please report 29 | # bugs to or send patches to 30 | # . 31 | 32 | 33 | # func_error message 34 | func_error () 35 | { 36 | echo "$me: $1" 1>&2 37 | exit 1 38 | } 39 | 40 | file_conv= 41 | 42 | # func_file_conv build_file 43 | # Convert a $build file to $host form and store it in $file 44 | # Currently only supports Windows hosts. 45 | func_file_conv () 46 | { 47 | file=$1 48 | case $file in 49 | / | /[!/]*) # absolute file, and not a UNC file 50 | if test -z "$file_conv"; then 51 | # lazily determine how to convert abs files 52 | case `uname -s` in 53 | MINGW*) 54 | file_conv=mingw 55 | ;; 56 | CYGWIN*) 57 | file_conv=cygwin 58 | ;; 59 | *) 60 | file_conv=wine 61 | ;; 62 | esac 63 | fi 64 | case $file_conv in 65 | mingw) 66 | file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` 67 | ;; 68 | cygwin) 69 | file=`cygpath -m "$file" || echo "$file"` 70 | ;; 71 | wine) 72 | file=`winepath -w "$file" || echo "$file"` 73 | ;; 74 | esac 75 | ;; 76 | esac 77 | } 78 | 79 | # func_at_file at_file operation archive 80 | # Iterate over all members in AT_FILE performing OPERATION on ARCHIVE 81 | # for each of them. 82 | # When interpreting the content of the @FILE, do NOT use func_file_conv, 83 | # since the user would need to supply preconverted file names to 84 | # binutils ar, at least for MinGW. 85 | func_at_file () 86 | { 87 | operation=$2 88 | archive=$3 89 | at_file_contents=`cat "$1"` 90 | eval set x "$at_file_contents" 91 | shift 92 | 93 | for member 94 | do 95 | $AR -NOLOGO $operation:"$member" "$archive" || exit $? 96 | done 97 | } 98 | 99 | case $1 in 100 | '') 101 | func_error "no command. Try '$0 --help' for more information." 102 | ;; 103 | -h | --h*) 104 | cat <Hiram Chirino 30 | */ 31 | public class Database extends NativeObject implements Closeable { 32 | 33 | private final Env env; 34 | 35 | Database(Env env, long self) { 36 | super(self); 37 | this.env = env; 38 | } 39 | 40 | public void close() { 41 | if( self!=0 ) { 42 | mdb_dbi_close(env.pointer(), self); 43 | self=0; 44 | } 45 | } 46 | 47 | 48 | public MDB_stat stat() { 49 | Transaction tx = env.createTransaction(); 50 | try { 51 | return stat(tx); 52 | } finally { 53 | tx.commit(); 54 | } 55 | } 56 | 57 | public MDB_stat stat(Transaction tx) { 58 | checkArgNotNull(tx, "tx"); 59 | MDB_stat rc = new MDB_stat(); 60 | mdb_stat(tx.pointer(), pointer(), rc); 61 | return rc; 62 | } 63 | 64 | public void drop(boolean delete) { 65 | Transaction tx = env.createTransaction(); 66 | try { 67 | drop(tx, delete); 68 | } finally { 69 | tx.commit(); 70 | } 71 | } 72 | 73 | public void drop(Transaction tx, boolean delete) { 74 | checkArgNotNull(tx, "tx"); 75 | mdb_drop(tx.pointer(), pointer(), delete ? 1 : 0); 76 | if( delete ) { 77 | self=0; 78 | } 79 | } 80 | 81 | 82 | public byte[] get(byte[] key) { 83 | checkArgNotNull(key, "key"); 84 | Transaction tx = env.createTransaction(); 85 | try { 86 | return get(tx, key); 87 | } finally { 88 | tx.commit(); 89 | } 90 | } 91 | 92 | public byte[] get(Transaction tx, byte[] key) { 93 | checkArgNotNull(tx, "tx"); 94 | checkArgNotNull(key, "key"); 95 | NativeBuffer keyBuffer = NativeBuffer.create(key); 96 | try { 97 | return get(tx, keyBuffer); 98 | } finally { 99 | keyBuffer.delete(); 100 | } 101 | } 102 | 103 | private byte[] get(Transaction tx, NativeBuffer keyBuffer) { 104 | return get(tx, new Value(keyBuffer)); 105 | } 106 | 107 | private byte[] get(Transaction tx, Value key) { 108 | Value value = new Value(); 109 | int rc = mdb_get(tx.pointer(), pointer(), key, value); 110 | if( rc == MDB_NOTFOUND ) { 111 | return null; 112 | } 113 | checkErrorCode(rc); 114 | return value.toByteArray(); 115 | } 116 | 117 | public byte[] put(byte[] key, byte[] value) { 118 | return put(key, value, 0); 119 | } 120 | 121 | public byte[] put(byte[] key, byte[] value, int flags) { 122 | checkArgNotNull(key, "key"); 123 | Transaction tx = env.createTransaction(); 124 | try { 125 | return put(tx, key, value, flags); 126 | } finally { 127 | tx.commit(); 128 | } 129 | } 130 | 131 | public byte[] put(Transaction tx, byte[] key, byte[] value) { 132 | return put(tx, key, value, 0); 133 | } 134 | 135 | public byte[] put(Transaction tx, byte[] key, byte[] value, int flags) { 136 | checkArgNotNull(tx, "tx"); 137 | checkArgNotNull(key, "key"); 138 | checkArgNotNull(value, "value"); 139 | NativeBuffer keyBuffer = NativeBuffer.create(key); 140 | try { 141 | NativeBuffer valueBuffer = NativeBuffer.create(value); 142 | try { 143 | return put(tx, keyBuffer, valueBuffer, flags); 144 | } finally { 145 | valueBuffer.delete(); 146 | } 147 | } finally { 148 | keyBuffer.delete(); 149 | } 150 | } 151 | 152 | private byte[] put(Transaction tx, NativeBuffer keyBuffer, NativeBuffer valueBuffer, int flags) { 153 | return put(tx, new Value(keyBuffer), new Value(valueBuffer), flags); 154 | } 155 | 156 | private byte[] put(Transaction tx, Value keySlice, Value valueSlice, int flags) { 157 | int rc = mdb_put(tx.pointer(), pointer(), keySlice, valueSlice, flags); 158 | if( (flags & MDB_NOOVERWRITE)!=0 && rc == MDB_KEYEXIST ) { 159 | // Return the existing value if it was a dup insert attempt. 160 | return valueSlice.toByteArray(); 161 | } else { 162 | // If the put failed, throw an exception.. 163 | checkErrorCode(rc); 164 | return null; 165 | } 166 | } 167 | 168 | 169 | public boolean delete(byte[] key) { 170 | return delete(key, null); 171 | } 172 | 173 | public boolean delete(byte[] key, byte[] value) { 174 | checkArgNotNull(key, "key"); 175 | Transaction tx = env.createTransaction(); 176 | try { 177 | return delete(tx, key, value); 178 | } finally { 179 | tx.commit(); 180 | } 181 | } 182 | 183 | public boolean delete(Transaction tx, byte[] key) { 184 | return delete(tx, key, null); 185 | } 186 | 187 | public boolean delete(Transaction tx, byte[] key, byte[] value) { 188 | checkArgNotNull(tx, "tx"); 189 | checkArgNotNull(key, "key"); 190 | NativeBuffer keyBuffer = NativeBuffer.create(key); 191 | try { 192 | NativeBuffer valueBuffer = NativeBuffer.create(value); 193 | try { 194 | return delete(tx, keyBuffer, valueBuffer); 195 | } finally { 196 | if( valueBuffer!=null ) { 197 | valueBuffer.delete(); 198 | } 199 | } 200 | } finally { 201 | keyBuffer.delete(); 202 | } 203 | } 204 | 205 | private boolean delete(Transaction tx, NativeBuffer keyBuffer, NativeBuffer valueBuffer) { 206 | return delete(tx, new Value(keyBuffer), Value.create(valueBuffer)); 207 | } 208 | 209 | private boolean delete(Transaction tx, Value keySlice, Value valueSlice) { 210 | int rc = mdb_del(tx.pointer(), pointer(), keySlice, valueSlice); 211 | if( rc == MDB_NOTFOUND ) { 212 | return false; 213 | } 214 | checkErrorCode(rc); 215 | return true; 216 | } 217 | 218 | public Cursor openCursor(Transaction tx) { 219 | long cursor[] = new long[1]; 220 | checkErrorCode(mdb_cursor_open(tx.pointer(), pointer(), cursor)); 221 | return new Cursor(env, cursor[0]); 222 | } 223 | 224 | } 225 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 4.0.0 22 | 23 | org.deephacks.lmdbjni 24 | lmdbjni-project 25 | 0.1.3-SNAPSHOT 26 | pom 27 | 28 | ${project.artifactId} 29 | lmdbjni is a jni library for accessing lmdb. 30 | http://lmdbjni.deephacks.org 31 | 32 | 33 | 1.9 34 | 0.1.1 35 | 36 | 37 | 38 | lmdbjni 39 | 40 | 41 | 42 | github 43 | https://github.com/deephacks/lmdbjni/issues 44 | 45 | 46 | scm:git:git@github.com:deephacks/lmdbjni.git 47 | scm:git:git@github.com:deephacks/lmdbjni.git 48 | scm:git:git@github.com/deephacks/lmdbjni 49 | 50 | 51 | 52 | The Apache Software License, Version 2.0 53 | http://www.apache.org/licenses/LICENSE-2.0.txt 54 | repo 55 | 56 | 57 | 58 | 59 | Kristoffer Sjogren 60 | krisskross 61 | stoffe -at- gmail.com 62 | 63 | 64 | Developer 65 | 66 | http://stoffe.deephacks.org/ 67 | +1 68 | 69 | 70 | 71 | 72 | 73 | junit 74 | junit 75 | 4.10 76 | test 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | org.apache.maven.plugins 86 | maven-clean-plugin 87 | 2.3 88 | 89 | 90 | 91 | org.apache.maven.plugins 92 | maven-compiler-plugin 93 | 2.3.2 94 | 95 | 1.8 96 | 1.8 97 | 98 | 99 | 100 | 101 | maven-surefire-plugin 102 | org.apache.maven.plugins 103 | 2.10 104 | 105 | true 106 | false 107 | true 108 | 109 | **/*TestCase.java 110 | **/*TestSuite.java 111 | **/*Test.java 112 | 113 | true 114 | 115 | 116 | 117 | maven-jar-plugin 118 | org.apache.maven.plugins 119 | 2.3.2 120 | 121 | 122 | 123 | ${project.name} 124 | ${project.version} 125 | deephacks 126 | ${project.name} 127 | ${project.version} 128 | deephacks 129 | org.deephacks 130 | http://lmdbjni.deephacks.org 131 | 132 | 133 | 134 | 135 | 136 | org.apache.maven.plugins 137 | maven-source-plugin 138 | 2.1.2 139 | 140 | 141 | attach-sources 142 | 143 | jar 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | sign-artifacts 154 | 155 | 156 | lmdbjni-linux64 157 | 158 | 159 | 160 | 161 | maven-javadoc-plugin 162 | org.apache.maven.plugins 163 | 2.8 164 | 165 | 166 | attach-javadocs 167 | 168 | jar 169 | 170 | 171 | 172 | 173 | aggregate 174 | 175 | site 176 | 177 | 178 | 179 | 180 | org.apache.maven.plugins 181 | maven-gpg-plugin 182 | 1.1 183 | 184 | 185 | sign-artifacts 186 | verify 187 | 188 | sign 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | full 199 | 200 | lmdbjni-osx64 201 | lmdbjni-linux64 202 | lmdbjni-win64 203 | lmdbjni-all 204 | 205 | 206 | 207 | 208 | all 209 | 210 | lmdbjni-all 211 | 212 | 213 | 214 | osx64 215 | 216 | lmdbjni-osx64 217 | 218 | 219 | 220 | 221 | linux64 222 | 223 | lmdbjni-linux64 224 | 225 | 226 | 227 | 228 | win64 229 | 230 | lmdbjni-win64 231 | 232 | 233 | 234 | 235 | 236 | 237 | sonatype-nexus-staging 238 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 239 | 240 | 241 | 242 | 243 | -------------------------------------------------------------------------------- /lmdbjni/src/main/java/org/fusesource/lmdbjni/NativeBuffer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.fusesource.lmdbjni; 20 | 21 | import org.fusesource.hawtjni.runtime.PointerMath; 22 | 23 | import java.util.concurrent.atomic.AtomicInteger; 24 | 25 | /** 26 | * A NativeBuffer allocates a native buffer on the heap. It supports 27 | * creating sub slices/views of that buffer and manages reference tracking 28 | * so that the the native buffer is freed once all NativeBuffer views 29 | * are deleted. 30 | * 31 | * @author Hiram Chirino 32 | */ 33 | class NativeBuffer extends NativeObject { 34 | 35 | private static class Allocation extends NativeObject { 36 | private final AtomicInteger retained = new AtomicInteger(0); 37 | 38 | private Allocation(long size) { 39 | super(JNI.malloc(size)); 40 | } 41 | 42 | void retain() { 43 | checkAllocated(); 44 | retained.incrementAndGet(); 45 | } 46 | 47 | void release() { 48 | checkAllocated(); 49 | int r = retained.decrementAndGet(); 50 | if( r < 0 ) { 51 | throw new Error("The object has already been deleted."); 52 | } else if( r==0 ) { 53 | JNI.free(self); 54 | self = 0; 55 | } 56 | } 57 | } 58 | 59 | private static class Pool { 60 | private final NativeBuffer.Pool prev; 61 | Allocation allocation; 62 | long pos; 63 | long remaining; 64 | int chunk; 65 | 66 | public Pool(int chunk, Pool prev) { 67 | this.chunk = chunk; 68 | this.prev = prev; 69 | } 70 | 71 | NativeBuffer create(long size) { 72 | if( size >= chunk ) { 73 | Allocation allocation = new Allocation(size); 74 | return new NativeBuffer(allocation, allocation.self, size); 75 | } 76 | 77 | if( remaining < size ) { 78 | delete(); 79 | } 80 | 81 | if( allocation == null ) { 82 | allocate(); 83 | } 84 | 85 | NativeBuffer rc = new NativeBuffer(allocation, pos, size); 86 | pos = PointerMath.add(pos, size); 87 | remaining -= size; 88 | return rc; 89 | } 90 | 91 | private void allocate() { 92 | allocation = new NativeBuffer.Allocation(chunk); 93 | allocation.retain(); 94 | remaining = chunk; 95 | pos = allocation.self; 96 | } 97 | 98 | public void delete() { 99 | if( allocation!=null ) { 100 | allocation.release(); 101 | allocation = null; 102 | } 103 | } 104 | } 105 | 106 | private final Allocation allocation; 107 | private final long capacity; 108 | 109 | static final private ThreadLocal CURRENT_POOL = new ThreadLocal(); 110 | 111 | static public NativeBuffer create(long capacity) { 112 | Pool pool = CURRENT_POOL.get(); 113 | if( pool == null ) { 114 | Allocation allocation = new Allocation(capacity); 115 | return new NativeBuffer(allocation, allocation.self, capacity); 116 | } else { 117 | return pool.create(capacity); 118 | } 119 | } 120 | 121 | 122 | public static void pushMemoryPool(int size) { 123 | Pool original = CURRENT_POOL.get(); 124 | Pool next = new Pool(size, original); 125 | CURRENT_POOL.set(next); 126 | } 127 | 128 | public static void popMemoryPool() { 129 | Pool next = CURRENT_POOL.get(); 130 | next.delete(); 131 | if( next.prev == null ) { 132 | CURRENT_POOL.remove(); 133 | } else { 134 | CURRENT_POOL.set(next.prev); 135 | } 136 | } 137 | 138 | static public NativeBuffer create(byte[] data) { 139 | if( data == null ) { 140 | return null; 141 | } else { 142 | return create(data, 0 , data.length); 143 | } 144 | } 145 | 146 | static public NativeBuffer create(String data) { 147 | return create(cbytes(data)); 148 | } 149 | 150 | static public NativeBuffer create(byte[] data, int offset, int length) { 151 | NativeBuffer rc = create(length); 152 | rc.write(0, data, offset, length); 153 | return rc; 154 | } 155 | 156 | static public NativeBuffer create(long pointer, int length) { 157 | return new NativeBuffer(null, pointer, length); 158 | } 159 | 160 | private NativeBuffer(Allocation allocation, long self, long capacity) { 161 | super(self); 162 | this.capacity = capacity; 163 | this.allocation = allocation; 164 | if( allocation!=null ) { 165 | allocation.retain(); 166 | } 167 | } 168 | 169 | public NativeBuffer slice(long offset, long length) { 170 | checkAllocated(); 171 | if( length < 0 ) throw new IllegalArgumentException("length cannot be negative"); 172 | if( offset < 0 ) throw new IllegalArgumentException("offset cannot be negative"); 173 | if( offset+length >= capacity) throw new ArrayIndexOutOfBoundsException("offset + length exceed the length of this buffer"); 174 | return new NativeBuffer(allocation, PointerMath.add(self, offset), length); 175 | } 176 | 177 | static byte[] cbytes(String strvalue) { 178 | byte[] value = strvalue.getBytes(); 179 | // expand by 1 so we get a null at the end. 180 | byte[] rc = new byte[value.length+1]; 181 | System.arraycopy(value, 0, rc, 0, value.length); 182 | return rc; 183 | } 184 | 185 | public NativeBuffer head(long length) { 186 | return slice(0, length); 187 | } 188 | 189 | public NativeBuffer tail(long length) { 190 | if( capacity-length < 0) throw new ArrayIndexOutOfBoundsException("capacity-length cannot be less than zero"); 191 | return slice(capacity-length, length); 192 | } 193 | 194 | public void delete() { 195 | allocation.release(); 196 | } 197 | 198 | public long capacity() { 199 | return capacity; 200 | } 201 | 202 | public void write(long at, byte []source, int offset, int length) { 203 | checkAllocated(); 204 | if( length < 0 ) throw new IllegalArgumentException("length cannot be negative"); 205 | if( offset < 0 ) throw new IllegalArgumentException("offset cannot be negative"); 206 | if( at < 0 ) throw new IllegalArgumentException("at cannot be negative"); 207 | if( at+length > capacity ) throw new ArrayIndexOutOfBoundsException("at + length exceeds the capacity of this object"); 208 | if( offset+length > source.length) throw new ArrayIndexOutOfBoundsException("offset + length exceed the length of the source buffer"); 209 | JNI.buffer_copy(source, offset, self, at, length); 210 | } 211 | 212 | public void read(long at, byte []target, int offset, int length) { 213 | checkAllocated(); 214 | if( length < 0 ) throw new IllegalArgumentException("length cannot be negative"); 215 | if( offset < 0 ) throw new IllegalArgumentException("offset cannot be negative"); 216 | if( at < 0 ) throw new IllegalArgumentException("at cannot be negative"); 217 | if( at+length > capacity ) throw new ArrayIndexOutOfBoundsException("at + length exceeds the capacity of this object"); 218 | if( offset+length > target.length) throw new ArrayIndexOutOfBoundsException("offset + length exceed the length of the target buffer"); 219 | JNI.buffer_copy(self, at, target, offset, length); 220 | } 221 | 222 | public byte[] toByteArray() { 223 | if( capacity > Integer.MAX_VALUE ) { 224 | throw new OutOfMemoryError("Native buffer larger than the largest allowed Java byte[]"); 225 | } 226 | byte [] rc = new byte[(int) capacity]; 227 | read(0, rc, 0, rc.length); 228 | return rc; 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/autotools/missing: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Common stub for a few missing GNU programs while installing. 3 | 4 | scriptversion=2012-01-06.18; # UTC 5 | 6 | # Copyright (C) 1996-2012 Free Software Foundation, Inc. 7 | # Originally by Fran,cois Pinard , 1996. 8 | 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | # As a special exception to the GNU General Public License, if you 23 | # distribute this file as part of a program that contains a 24 | # configuration script generated by Autoconf, you may include it under 25 | # the same distribution terms that you use for the rest of that program. 26 | 27 | if test $# -eq 0; then 28 | echo 1>&2 "Try '$0 --help' for more information" 29 | exit 1 30 | fi 31 | 32 | run=: 33 | sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' 34 | sed_minuso='s/.* -o \([^ ]*\).*/\1/p' 35 | 36 | # In the cases where this matters, 'missing' is being run in the 37 | # srcdir already. 38 | if test -f configure.ac; then 39 | configure_ac=configure.ac 40 | else 41 | configure_ac=configure.in 42 | fi 43 | 44 | msg="missing on your system" 45 | 46 | case $1 in 47 | --run) 48 | # Try to run requested program, and just exit if it succeeds. 49 | run= 50 | shift 51 | "$@" && exit 0 52 | # Exit code 63 means version mismatch. This often happens 53 | # when the user try to use an ancient version of a tool on 54 | # a file that requires a minimum version. In this case we 55 | # we should proceed has if the program had been absent, or 56 | # if --run hadn't been passed. 57 | if test $? = 63; then 58 | run=: 59 | msg="probably too old" 60 | fi 61 | ;; 62 | 63 | -h|--h|--he|--hel|--help) 64 | echo "\ 65 | $0 [OPTION]... PROGRAM [ARGUMENT]... 66 | 67 | Handle 'PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an 68 | error status if there is no known handling for PROGRAM. 69 | 70 | Options: 71 | -h, --help display this help and exit 72 | -v, --version output version information and exit 73 | --run try to run the given command, and emulate it if it fails 74 | 75 | Supported PROGRAM values: 76 | aclocal touch file 'aclocal.m4' 77 | autoconf touch file 'configure' 78 | autoheader touch file 'config.h.in' 79 | autom4te touch the output file, or create a stub one 80 | automake touch all 'Makefile.in' files 81 | bison create 'y.tab.[ch]', if possible, from existing .[ch] 82 | flex create 'lex.yy.c', if possible, from existing .c 83 | help2man touch the output file 84 | lex create 'lex.yy.c', if possible, from existing .c 85 | makeinfo touch the output file 86 | yacc create 'y.tab.[ch]', if possible, from existing .[ch] 87 | 88 | Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 89 | 'g' are ignored when checking the name. 90 | 91 | Send bug reports to ." 92 | exit $? 93 | ;; 94 | 95 | -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 96 | echo "missing $scriptversion (GNU Automake)" 97 | exit $? 98 | ;; 99 | 100 | -*) 101 | echo 1>&2 "$0: Unknown '$1' option" 102 | echo 1>&2 "Try '$0 --help' for more information" 103 | exit 1 104 | ;; 105 | 106 | esac 107 | 108 | # normalize program name to check for. 109 | program=`echo "$1" | sed ' 110 | s/^gnu-//; t 111 | s/^gnu//; t 112 | s/^g//; t'` 113 | 114 | # Now exit if we have it, but it failed. Also exit now if we 115 | # don't have it and --version was passed (most likely to detect 116 | # the program). This is about non-GNU programs, so use $1 not 117 | # $program. 118 | case $1 in 119 | lex*|yacc*) 120 | # Not GNU programs, they don't have --version. 121 | ;; 122 | 123 | *) 124 | if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 125 | # We have it, but it failed. 126 | exit 1 127 | elif test "x$2" = "x--version" || test "x$2" = "x--help"; then 128 | # Could not run --version or --help. This is probably someone 129 | # running '$TOOL --version' or '$TOOL --help' to check whether 130 | # $TOOL exists and not knowing $TOOL uses missing. 131 | exit 1 132 | fi 133 | ;; 134 | esac 135 | 136 | # If it does not exist, or fails to run (possibly an outdated version), 137 | # try to emulate it. 138 | case $program in 139 | aclocal*) 140 | echo 1>&2 "\ 141 | WARNING: '$1' is $msg. You should only need it if 142 | you modified 'acinclude.m4' or '${configure_ac}'. You might want 143 | to install the Automake and Perl packages. Grab them from 144 | any GNU archive site." 145 | touch aclocal.m4 146 | ;; 147 | 148 | autoconf*) 149 | echo 1>&2 "\ 150 | WARNING: '$1' is $msg. You should only need it if 151 | you modified '${configure_ac}'. You might want to install the 152 | Autoconf and GNU m4 packages. Grab them from any GNU 153 | archive site." 154 | touch configure 155 | ;; 156 | 157 | autoheader*) 158 | echo 1>&2 "\ 159 | WARNING: '$1' is $msg. You should only need it if 160 | you modified 'acconfig.h' or '${configure_ac}'. You might want 161 | to install the Autoconf and GNU m4 packages. Grab them 162 | from any GNU archive site." 163 | files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` 164 | test -z "$files" && files="config.h" 165 | touch_files= 166 | for f in $files; do 167 | case $f in 168 | *:*) touch_files="$touch_files "`echo "$f" | 169 | sed -e 's/^[^:]*://' -e 's/:.*//'`;; 170 | *) touch_files="$touch_files $f.in";; 171 | esac 172 | done 173 | touch $touch_files 174 | ;; 175 | 176 | automake*) 177 | echo 1>&2 "\ 178 | WARNING: '$1' is $msg. You should only need it if 179 | you modified 'Makefile.am', 'acinclude.m4' or '${configure_ac}'. 180 | You might want to install the Automake and Perl packages. 181 | Grab them from any GNU archive site." 182 | find . -type f -name Makefile.am -print | 183 | sed 's/\.am$/.in/' | 184 | while read f; do touch "$f"; done 185 | ;; 186 | 187 | autom4te*) 188 | echo 1>&2 "\ 189 | WARNING: '$1' is needed, but is $msg. 190 | You might have modified some files without having the 191 | proper tools for further handling them. 192 | You can get '$1' as part of Autoconf from any GNU 193 | archive site." 194 | 195 | file=`echo "$*" | sed -n "$sed_output"` 196 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 197 | if test -f "$file"; then 198 | touch $file 199 | else 200 | test -z "$file" || exec >$file 201 | echo "#! /bin/sh" 202 | echo "# Created by GNU Automake missing as a replacement of" 203 | echo "# $ $@" 204 | echo "exit 0" 205 | chmod +x $file 206 | exit 1 207 | fi 208 | ;; 209 | 210 | bison*|yacc*) 211 | echo 1>&2 "\ 212 | WARNING: '$1' $msg. You should only need it if 213 | you modified a '.y' file. You may need the Bison package 214 | in order for those modifications to take effect. You can get 215 | Bison from any GNU archive site." 216 | rm -f y.tab.c y.tab.h 217 | if test $# -ne 1; then 218 | eval LASTARG=\${$#} 219 | case $LASTARG in 220 | *.y) 221 | SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` 222 | if test -f "$SRCFILE"; then 223 | cp "$SRCFILE" y.tab.c 224 | fi 225 | SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` 226 | if test -f "$SRCFILE"; then 227 | cp "$SRCFILE" y.tab.h 228 | fi 229 | ;; 230 | esac 231 | fi 232 | if test ! -f y.tab.h; then 233 | echo >y.tab.h 234 | fi 235 | if test ! -f y.tab.c; then 236 | echo 'main() { return 0; }' >y.tab.c 237 | fi 238 | ;; 239 | 240 | lex*|flex*) 241 | echo 1>&2 "\ 242 | WARNING: '$1' is $msg. You should only need it if 243 | you modified a '.l' file. You may need the Flex package 244 | in order for those modifications to take effect. You can get 245 | Flex from any GNU archive site." 246 | rm -f lex.yy.c 247 | if test $# -ne 1; then 248 | eval LASTARG=\${$#} 249 | case $LASTARG in 250 | *.l) 251 | SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` 252 | if test -f "$SRCFILE"; then 253 | cp "$SRCFILE" lex.yy.c 254 | fi 255 | ;; 256 | esac 257 | fi 258 | if test ! -f lex.yy.c; then 259 | echo 'main() { return 0; }' >lex.yy.c 260 | fi 261 | ;; 262 | 263 | help2man*) 264 | echo 1>&2 "\ 265 | WARNING: '$1' is $msg. You should only need it if 266 | you modified a dependency of a manual page. You may need the 267 | Help2man package in order for those modifications to take 268 | effect. You can get Help2man from any GNU archive site." 269 | 270 | file=`echo "$*" | sed -n "$sed_output"` 271 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 272 | if test -f "$file"; then 273 | touch $file 274 | else 275 | test -z "$file" || exec >$file 276 | echo ".ab help2man is required to generate this page" 277 | exit $? 278 | fi 279 | ;; 280 | 281 | makeinfo*) 282 | echo 1>&2 "\ 283 | WARNING: '$1' is $msg. You should only need it if 284 | you modified a '.texi' or '.texinfo' file, or any other file 285 | indirectly affecting the aspect of the manual. The spurious 286 | call might also be the consequence of using a buggy 'make' (AIX, 287 | DU, IRIX). You might want to install the Texinfo package or 288 | the GNU make package. Grab either from any GNU archive site." 289 | # The file to touch is that specified with -o ... 290 | file=`echo "$*" | sed -n "$sed_output"` 291 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 292 | if test -z "$file"; then 293 | # ... or it is the one specified with @setfilename ... 294 | infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` 295 | file=`sed -n ' 296 | /^@setfilename/{ 297 | s/.* \([^ ]*\) *$/\1/ 298 | p 299 | q 300 | }' $infile` 301 | # ... or it is derived from the source name (dir/f.texi becomes f.info) 302 | test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info 303 | fi 304 | # If the file does not exist, the user really needs makeinfo; 305 | # let's fail without touching anything. 306 | test -f $file || exit 1 307 | touch $file 308 | ;; 309 | 310 | *) 311 | echo 1>&2 "\ 312 | WARNING: '$1' is needed, and is $msg. 313 | You might have modified some files without having the 314 | proper tools for further handling them. Check the 'README' file, 315 | it often tells you about the needed prerequisites for installing 316 | this package. You may also peek at any GNU archive site, in case 317 | some other package would contain this missing '$1' program." 318 | exit 1 319 | ;; 320 | esac 321 | 322 | exit 0 323 | 324 | # Local variables: 325 | # eval: (add-hook 'write-file-hooks 'time-stamp) 326 | # time-stamp-start: "scriptversion=" 327 | # time-stamp-format: "%:y-%02m-%02d.%02H" 328 | # time-stamp-time-zone: "UTC" 329 | # time-stamp-end: "; # UTC" 330 | # End: 331 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/license.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/vs2010.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | debug 7 | Win32 8 | 9 | 10 | debug 11 | x64 12 | 13 | 14 | release 15 | Win32 16 | 17 | 18 | release 19 | x64 20 | 21 | 22 | 23 | lmdbjni 24 | lmdbjni 25 | 26 | 27 | 28 | DynamicLibrary 29 | Unicode 30 | 31 | 32 | DynamicLibrary 33 | Unicode 34 | true 35 | 36 | 37 | DynamicLibrary 38 | Unicode 39 | 40 | 41 | DynamicLibrary 42 | Unicode 43 | true 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | <_ProjectFileVersion>10.0.30319.1 63 | $(ProjectDir)/target/$(Platform)-$(Configuration)/lib\ 64 | $(ProjectDir)/target/$(Platform)-$(Configuration)/obj\ 65 | false 66 | $(ProjectDir)/target/$(Platform)-$(Configuration)/lib\ 67 | $(ProjectDir)/target/$(Platform)-$(Configuration)/obj\ 68 | false 69 | $(ProjectDir)/target/$(Platform)-$(Configuration)/lib\ 70 | $(ProjectDir)/target/$(Platform)-$(Configuration)/obj\ 71 | true 72 | $(ProjectDir)/target/$(Platform)-$(Configuration)/lib\ 73 | $(ProjectDir)/target/$(Platform)-$(Configuration)/obj\ 74 | true 75 | 76 | 77 | 78 | $(ProjectDir)..\..\..\lmdbjni-win64\target\lmdb\META-INF\native\lmdb-win64;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\src\windows;%(AdditionalIncludeDirectories) 79 | MaxSpeed 80 | true 81 | Speed 82 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 83 | 84 | 85 | MultiThreadedDLL 86 | true 87 | false 88 | 89 | 90 | Level3 91 | ProgramDatabase 92 | StdCall 93 | CompileAsC 94 | 95 | 96 | $(ProjectDir)..\..\..\lmdbjni-win64\target\lmdb\META-INF\native\lmdb-win64\liblmdb.a;%(AdditionalDependencies) 97 | true 98 | Windows 99 | true 100 | true 101 | MachineX86 102 | 103 | 104 | 105 | 106 | $(ProjectDir)..\..\..\lmdbjni-win64\target\lmdb\META-INF\native\lmdb-win64;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\src\windows;%(AdditionalIncludeDirectories) 107 | MaxSpeed 108 | true 109 | Speed 110 | WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 111 | 112 | 113 | MultiThreadedDLL 114 | true 115 | false 116 | 117 | 118 | Level3 119 | ProgramDatabase 120 | StdCall 121 | CompileAsC 122 | 123 | 124 | $(ProjectDir)..\..\..\lmdbjni-win64\target\lmdb\META-INF\native\lmdb-win64\liblmdb.a;%(AdditionalDependencies) 125 | true 126 | Windows 127 | true 128 | true 129 | MachineX64 130 | 131 | 132 | 133 | 134 | $(ProjectDir)..\..\..\lmdbjni-win64\target\lmdb\META-INF\native\lmdb-win64;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\src\windows;%(AdditionalIncludeDirectories) 135 | Disabled 136 | Speed 137 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 138 | true 139 | 140 | 141 | EnableFastChecks 142 | MultiThreadedDebugDLL 143 | false 144 | 145 | 146 | Level3 147 | EditAndContinue 148 | StdCall 149 | CompileAsC 150 | 151 | 152 | $(ProjectDir)..\..\..\lmdbjni-win64\target\lmdb\META-INF\native\lmdb-win64\liblmdb.a;%(AdditionalDependencies) 153 | true 154 | Windows 155 | MachineX86 156 | 157 | 158 | 159 | 160 | $(ProjectDir)..\..\..\lmdbjni-win64\target\lmdb\META-INF\native\lmdb-win64;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\src\windows;%(AdditionalIncludeDirectories) 161 | Disabled 162 | Speed 163 | WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 164 | true 165 | 166 | 167 | EnableFastChecks 168 | MultiThreadedDebugDLL 169 | false 170 | 171 | 172 | Level3 173 | EditAndContinue 174 | StdCall 175 | CompileAsC 176 | 177 | 178 | $(ProjectDir)..\..\..\lmdbjni-win64\target\lmdb\META-INF\native\lmdb-win64\liblmdb.a;%(AdditionalDependencies) 179 | true 180 | Windows 181 | MachineX64 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/m4/ltoptions.m4: -------------------------------------------------------------------------------- 1 | # Helper functions for option handling. -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, 4 | # Inc. 5 | # Written by Gary V. Vaughan, 2004 6 | # 7 | # This file is free software; the Free Software Foundation gives 8 | # unlimited permission to copy and/or distribute it, with or without 9 | # modifications, as long as this notice is preserved. 10 | 11 | # serial 7 ltoptions.m4 12 | 13 | # This is to help aclocal find these macros, as it can't see m4_define. 14 | AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) 15 | 16 | 17 | # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) 18 | # ------------------------------------------ 19 | m4_define([_LT_MANGLE_OPTION], 20 | [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) 21 | 22 | 23 | # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) 24 | # --------------------------------------- 25 | # Set option OPTION-NAME for macro MACRO-NAME, and if there is a 26 | # matching handler defined, dispatch to it. Other OPTION-NAMEs are 27 | # saved as a flag. 28 | m4_define([_LT_SET_OPTION], 29 | [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl 30 | m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), 31 | _LT_MANGLE_DEFUN([$1], [$2]), 32 | [m4_warning([Unknown $1 option `$2'])])[]dnl 33 | ]) 34 | 35 | 36 | # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) 37 | # ------------------------------------------------------------ 38 | # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. 39 | m4_define([_LT_IF_OPTION], 40 | [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) 41 | 42 | 43 | # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) 44 | # ------------------------------------------------------- 45 | # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME 46 | # are set. 47 | m4_define([_LT_UNLESS_OPTIONS], 48 | [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), 49 | [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), 50 | [m4_define([$0_found])])])[]dnl 51 | m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 52 | ])[]dnl 53 | ]) 54 | 55 | 56 | # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) 57 | # ---------------------------------------- 58 | # OPTION-LIST is a space-separated list of Libtool options associated 59 | # with MACRO-NAME. If any OPTION has a matching handler declared with 60 | # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about 61 | # the unknown option and exit. 62 | m4_defun([_LT_SET_OPTIONS], 63 | [# Set options 64 | m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), 65 | [_LT_SET_OPTION([$1], _LT_Option)]) 66 | 67 | m4_if([$1],[LT_INIT],[ 68 | dnl 69 | dnl Simply set some default values (i.e off) if boolean options were not 70 | dnl specified: 71 | _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no 72 | ]) 73 | _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no 74 | ]) 75 | dnl 76 | dnl If no reference was made to various pairs of opposing options, then 77 | dnl we run the default mode handler for the pair. For example, if neither 78 | dnl `shared' nor `disable-shared' was passed, we enable building of shared 79 | dnl archives by default: 80 | _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) 81 | _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) 82 | _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) 83 | _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], 84 | [_LT_ENABLE_FAST_INSTALL]) 85 | ]) 86 | ])# _LT_SET_OPTIONS 87 | 88 | 89 | ## --------------------------------- ## 90 | ## Macros to handle LT_INIT options. ## 91 | ## --------------------------------- ## 92 | 93 | # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) 94 | # ----------------------------------------- 95 | m4_define([_LT_MANGLE_DEFUN], 96 | [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) 97 | 98 | 99 | # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) 100 | # ----------------------------------------------- 101 | m4_define([LT_OPTION_DEFINE], 102 | [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl 103 | ])# LT_OPTION_DEFINE 104 | 105 | 106 | # dlopen 107 | # ------ 108 | LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes 109 | ]) 110 | 111 | AU_DEFUN([AC_LIBTOOL_DLOPEN], 112 | [_LT_SET_OPTION([LT_INIT], [dlopen]) 113 | AC_DIAGNOSE([obsolete], 114 | [$0: Remove this warning and the call to _LT_SET_OPTION when you 115 | put the `dlopen' option into LT_INIT's first parameter.]) 116 | ]) 117 | 118 | dnl aclocal-1.4 backwards compatibility: 119 | dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) 120 | 121 | 122 | # win32-dll 123 | # --------- 124 | # Declare package support for building win32 dll's. 125 | LT_OPTION_DEFINE([LT_INIT], [win32-dll], 126 | [enable_win32_dll=yes 127 | 128 | case $host in 129 | *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) 130 | AC_CHECK_TOOL(AS, as, false) 131 | AC_CHECK_TOOL(DLLTOOL, dlltool, false) 132 | AC_CHECK_TOOL(OBJDUMP, objdump, false) 133 | ;; 134 | esac 135 | 136 | test -z "$AS" && AS=as 137 | _LT_DECL([], [AS], [1], [Assembler program])dnl 138 | 139 | test -z "$DLLTOOL" && DLLTOOL=dlltool 140 | _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl 141 | 142 | test -z "$OBJDUMP" && OBJDUMP=objdump 143 | _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl 144 | ])# win32-dll 145 | 146 | AU_DEFUN([AC_LIBTOOL_WIN32_DLL], 147 | [AC_REQUIRE([AC_CANONICAL_HOST])dnl 148 | _LT_SET_OPTION([LT_INIT], [win32-dll]) 149 | AC_DIAGNOSE([obsolete], 150 | [$0: Remove this warning and the call to _LT_SET_OPTION when you 151 | put the `win32-dll' option into LT_INIT's first parameter.]) 152 | ]) 153 | 154 | dnl aclocal-1.4 backwards compatibility: 155 | dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) 156 | 157 | 158 | # _LT_ENABLE_SHARED([DEFAULT]) 159 | # ---------------------------- 160 | # implement the --enable-shared flag, and supports the `shared' and 161 | # `disable-shared' LT_INIT options. 162 | # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. 163 | m4_define([_LT_ENABLE_SHARED], 164 | [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl 165 | AC_ARG_ENABLE([shared], 166 | [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], 167 | [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], 168 | [p=${PACKAGE-default} 169 | case $enableval in 170 | yes) enable_shared=yes ;; 171 | no) enable_shared=no ;; 172 | *) 173 | enable_shared=no 174 | # Look at the argument we got. We use all the common list separators. 175 | lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," 176 | for pkg in $enableval; do 177 | IFS="$lt_save_ifs" 178 | if test "X$pkg" = "X$p"; then 179 | enable_shared=yes 180 | fi 181 | done 182 | IFS="$lt_save_ifs" 183 | ;; 184 | esac], 185 | [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) 186 | 187 | _LT_DECL([build_libtool_libs], [enable_shared], [0], 188 | [Whether or not to build shared libraries]) 189 | ])# _LT_ENABLE_SHARED 190 | 191 | LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) 192 | LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) 193 | 194 | # Old names: 195 | AC_DEFUN([AC_ENABLE_SHARED], 196 | [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) 197 | ]) 198 | 199 | AC_DEFUN([AC_DISABLE_SHARED], 200 | [_LT_SET_OPTION([LT_INIT], [disable-shared]) 201 | ]) 202 | 203 | AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) 204 | AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) 205 | 206 | dnl aclocal-1.4 backwards compatibility: 207 | dnl AC_DEFUN([AM_ENABLE_SHARED], []) 208 | dnl AC_DEFUN([AM_DISABLE_SHARED], []) 209 | 210 | 211 | 212 | # _LT_ENABLE_STATIC([DEFAULT]) 213 | # ---------------------------- 214 | # implement the --enable-static flag, and support the `static' and 215 | # `disable-static' LT_INIT options. 216 | # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. 217 | m4_define([_LT_ENABLE_STATIC], 218 | [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl 219 | AC_ARG_ENABLE([static], 220 | [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], 221 | [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], 222 | [p=${PACKAGE-default} 223 | case $enableval in 224 | yes) enable_static=yes ;; 225 | no) enable_static=no ;; 226 | *) 227 | enable_static=no 228 | # Look at the argument we got. We use all the common list separators. 229 | lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," 230 | for pkg in $enableval; do 231 | IFS="$lt_save_ifs" 232 | if test "X$pkg" = "X$p"; then 233 | enable_static=yes 234 | fi 235 | done 236 | IFS="$lt_save_ifs" 237 | ;; 238 | esac], 239 | [enable_static=]_LT_ENABLE_STATIC_DEFAULT) 240 | 241 | _LT_DECL([build_old_libs], [enable_static], [0], 242 | [Whether or not to build static libraries]) 243 | ])# _LT_ENABLE_STATIC 244 | 245 | LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) 246 | LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) 247 | 248 | # Old names: 249 | AC_DEFUN([AC_ENABLE_STATIC], 250 | [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) 251 | ]) 252 | 253 | AC_DEFUN([AC_DISABLE_STATIC], 254 | [_LT_SET_OPTION([LT_INIT], [disable-static]) 255 | ]) 256 | 257 | AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) 258 | AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) 259 | 260 | dnl aclocal-1.4 backwards compatibility: 261 | dnl AC_DEFUN([AM_ENABLE_STATIC], []) 262 | dnl AC_DEFUN([AM_DISABLE_STATIC], []) 263 | 264 | 265 | 266 | # _LT_ENABLE_FAST_INSTALL([DEFAULT]) 267 | # ---------------------------------- 268 | # implement the --enable-fast-install flag, and support the `fast-install' 269 | # and `disable-fast-install' LT_INIT options. 270 | # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. 271 | m4_define([_LT_ENABLE_FAST_INSTALL], 272 | [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl 273 | AC_ARG_ENABLE([fast-install], 274 | [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], 275 | [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], 276 | [p=${PACKAGE-default} 277 | case $enableval in 278 | yes) enable_fast_install=yes ;; 279 | no) enable_fast_install=no ;; 280 | *) 281 | enable_fast_install=no 282 | # Look at the argument we got. We use all the common list separators. 283 | lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," 284 | for pkg in $enableval; do 285 | IFS="$lt_save_ifs" 286 | if test "X$pkg" = "X$p"; then 287 | enable_fast_install=yes 288 | fi 289 | done 290 | IFS="$lt_save_ifs" 291 | ;; 292 | esac], 293 | [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) 294 | 295 | _LT_DECL([fast_install], [enable_fast_install], [0], 296 | [Whether or not to optimize for fast installation])dnl 297 | ])# _LT_ENABLE_FAST_INSTALL 298 | 299 | LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) 300 | LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) 301 | 302 | # Old names: 303 | AU_DEFUN([AC_ENABLE_FAST_INSTALL], 304 | [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) 305 | AC_DIAGNOSE([obsolete], 306 | [$0: Remove this warning and the call to _LT_SET_OPTION when you put 307 | the `fast-install' option into LT_INIT's first parameter.]) 308 | ]) 309 | 310 | AU_DEFUN([AC_DISABLE_FAST_INSTALL], 311 | [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) 312 | AC_DIAGNOSE([obsolete], 313 | [$0: Remove this warning and the call to _LT_SET_OPTION when you put 314 | the `disable-fast-install' option into LT_INIT's first parameter.]) 315 | ]) 316 | 317 | dnl aclocal-1.4 backwards compatibility: 318 | dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) 319 | dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) 320 | 321 | 322 | # _LT_WITH_PIC([MODE]) 323 | # -------------------- 324 | # implement the --with-pic flag, and support the `pic-only' and `no-pic' 325 | # LT_INIT options. 326 | # MODE is either `yes' or `no'. If omitted, it defaults to `both'. 327 | m4_define([_LT_WITH_PIC], 328 | [AC_ARG_WITH([pic], 329 | [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], 330 | [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], 331 | [lt_p=${PACKAGE-default} 332 | case $withval in 333 | yes|no) pic_mode=$withval ;; 334 | *) 335 | pic_mode=default 336 | # Look at the argument we got. We use all the common list separators. 337 | lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," 338 | for lt_pkg in $withval; do 339 | IFS="$lt_save_ifs" 340 | if test "X$lt_pkg" = "X$lt_p"; then 341 | pic_mode=yes 342 | fi 343 | done 344 | IFS="$lt_save_ifs" 345 | ;; 346 | esac], 347 | [pic_mode=default]) 348 | 349 | test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) 350 | 351 | _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl 352 | ])# _LT_WITH_PIC 353 | 354 | LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) 355 | LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) 356 | 357 | # Old name: 358 | AU_DEFUN([AC_LIBTOOL_PICMODE], 359 | [_LT_SET_OPTION([LT_INIT], [pic-only]) 360 | AC_DIAGNOSE([obsolete], 361 | [$0: Remove this warning and the call to _LT_SET_OPTION when you 362 | put the `pic-only' option into LT_INIT's first parameter.]) 363 | ]) 364 | 365 | dnl aclocal-1.4 backwards compatibility: 366 | dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) 367 | 368 | ## ----------------- ## 369 | ## LTDL_INIT Options ## 370 | ## ----------------- ## 371 | 372 | m4_define([_LTDL_MODE], []) 373 | LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], 374 | [m4_define([_LTDL_MODE], [nonrecursive])]) 375 | LT_OPTION_DEFINE([LTDL_INIT], [recursive], 376 | [m4_define([_LTDL_MODE], [recursive])]) 377 | LT_OPTION_DEFINE([LTDL_INIT], [subproject], 378 | [m4_define([_LTDL_MODE], [subproject])]) 379 | 380 | m4_define([_LTDL_TYPE], []) 381 | LT_OPTION_DEFINE([LTDL_INIT], [installable], 382 | [m4_define([_LTDL_TYPE], [installable])]) 383 | LT_OPTION_DEFINE([LTDL_INIT], [convenience], 384 | [m4_define([_LTDL_TYPE], [convenience])]) 385 | -------------------------------------------------------------------------------- /lmdbjni/src/main/native-package/autotools/install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # install - install a program, script, or datafile 3 | 4 | scriptversion=2011-11-20.07; # UTC 5 | 6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was 7 | # later released in X11R6 (xc/config/util/install.sh) with the 8 | # following copyright and license. 9 | # 10 | # Copyright (C) 1994 X Consortium 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documentation files (the "Software"), to 14 | # deal in the Software without restriction, including without limitation the 15 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16 | # sell copies of the Software, and to permit persons to whom the Software is 17 | # furnished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27 | # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # Except as contained in this notice, the name of the X Consortium shall not 30 | # be used in advertising or otherwise to promote the sale, use or other deal- 31 | # ings in this Software without prior written authorization from the X Consor- 32 | # tium. 33 | # 34 | # 35 | # FSF changes to this file are in the public domain. 36 | # 37 | # Calling this script install-sh is preferred over install.sh, to prevent 38 | # 'make' implicit rules from creating a file called install from it 39 | # when there is no Makefile. 40 | # 41 | # This script is compatible with the BSD install script, but was written 42 | # from scratch. 43 | 44 | nl=' 45 | ' 46 | IFS=" "" $nl" 47 | 48 | # set DOITPROG to echo to test this script 49 | 50 | # Don't use :- since 4.3BSD and earlier shells don't like it. 51 | doit=${DOITPROG-} 52 | if test -z "$doit"; then 53 | doit_exec=exec 54 | else 55 | doit_exec=$doit 56 | fi 57 | 58 | # Put in absolute file names if you don't have them in your path; 59 | # or use environment vars. 60 | 61 | chgrpprog=${CHGRPPROG-chgrp} 62 | chmodprog=${CHMODPROG-chmod} 63 | chownprog=${CHOWNPROG-chown} 64 | cmpprog=${CMPPROG-cmp} 65 | cpprog=${CPPROG-cp} 66 | mkdirprog=${MKDIRPROG-mkdir} 67 | mvprog=${MVPROG-mv} 68 | rmprog=${RMPROG-rm} 69 | stripprog=${STRIPPROG-strip} 70 | 71 | posix_glob='?' 72 | initialize_posix_glob=' 73 | test "$posix_glob" != "?" || { 74 | if (set -f) 2>/dev/null; then 75 | posix_glob= 76 | else 77 | posix_glob=: 78 | fi 79 | } 80 | ' 81 | 82 | posix_mkdir= 83 | 84 | # Desired mode of installed file. 85 | mode=0755 86 | 87 | chgrpcmd= 88 | chmodcmd=$chmodprog 89 | chowncmd= 90 | mvcmd=$mvprog 91 | rmcmd="$rmprog -f" 92 | stripcmd= 93 | 94 | src= 95 | dst= 96 | dir_arg= 97 | dst_arg= 98 | 99 | copy_on_change=false 100 | no_target_directory= 101 | 102 | usage="\ 103 | Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 104 | or: $0 [OPTION]... SRCFILES... DIRECTORY 105 | or: $0 [OPTION]... -t DIRECTORY SRCFILES... 106 | or: $0 [OPTION]... -d DIRECTORIES... 107 | 108 | In the 1st form, copy SRCFILE to DSTFILE. 109 | In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 110 | In the 4th, create DIRECTORIES. 111 | 112 | Options: 113 | --help display this help and exit. 114 | --version display version info and exit. 115 | 116 | -c (ignored) 117 | -C install only if different (preserve the last data modification time) 118 | -d create directories instead of installing files. 119 | -g GROUP $chgrpprog installed files to GROUP. 120 | -m MODE $chmodprog installed files to MODE. 121 | -o USER $chownprog installed files to USER. 122 | -s $stripprog installed files. 123 | -t DIRECTORY install into DIRECTORY. 124 | -T report an error if DSTFILE is a directory. 125 | 126 | Environment variables override the default commands: 127 | CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG 128 | RMPROG STRIPPROG 129 | " 130 | 131 | while test $# -ne 0; do 132 | case $1 in 133 | -c) ;; 134 | 135 | -C) copy_on_change=true;; 136 | 137 | -d) dir_arg=true;; 138 | 139 | -g) chgrpcmd="$chgrpprog $2" 140 | shift;; 141 | 142 | --help) echo "$usage"; exit $?;; 143 | 144 | -m) mode=$2 145 | case $mode in 146 | *' '* | *' '* | *' 147 | '* | *'*'* | *'?'* | *'['*) 148 | echo "$0: invalid mode: $mode" >&2 149 | exit 1;; 150 | esac 151 | shift;; 152 | 153 | -o) chowncmd="$chownprog $2" 154 | shift;; 155 | 156 | -s) stripcmd=$stripprog;; 157 | 158 | -t) dst_arg=$2 159 | # Protect names problematic for 'test' and other utilities. 160 | case $dst_arg in 161 | -* | [=\(\)!]) dst_arg=./$dst_arg;; 162 | esac 163 | shift;; 164 | 165 | -T) no_target_directory=true;; 166 | 167 | --version) echo "$0 $scriptversion"; exit $?;; 168 | 169 | --) shift 170 | break;; 171 | 172 | -*) echo "$0: invalid option: $1" >&2 173 | exit 1;; 174 | 175 | *) break;; 176 | esac 177 | shift 178 | done 179 | 180 | if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 181 | # When -d is used, all remaining arguments are directories to create. 182 | # When -t is used, the destination is already specified. 183 | # Otherwise, the last argument is the destination. Remove it from $@. 184 | for arg 185 | do 186 | if test -n "$dst_arg"; then 187 | # $@ is not empty: it contains at least $arg. 188 | set fnord "$@" "$dst_arg" 189 | shift # fnord 190 | fi 191 | shift # arg 192 | dst_arg=$arg 193 | # Protect names problematic for 'test' and other utilities. 194 | case $dst_arg in 195 | -* | [=\(\)!]) dst_arg=./$dst_arg;; 196 | esac 197 | done 198 | fi 199 | 200 | if test $# -eq 0; then 201 | if test -z "$dir_arg"; then 202 | echo "$0: no input file specified." >&2 203 | exit 1 204 | fi 205 | # It's OK to call 'install-sh -d' without argument. 206 | # This can happen when creating conditional directories. 207 | exit 0 208 | fi 209 | 210 | if test -z "$dir_arg"; then 211 | do_exit='(exit $ret); exit $ret' 212 | trap "ret=129; $do_exit" 1 213 | trap "ret=130; $do_exit" 2 214 | trap "ret=141; $do_exit" 13 215 | trap "ret=143; $do_exit" 15 216 | 217 | # Set umask so as not to create temps with too-generous modes. 218 | # However, 'strip' requires both read and write access to temps. 219 | case $mode in 220 | # Optimize common cases. 221 | *644) cp_umask=133;; 222 | *755) cp_umask=22;; 223 | 224 | *[0-7]) 225 | if test -z "$stripcmd"; then 226 | u_plus_rw= 227 | else 228 | u_plus_rw='% 200' 229 | fi 230 | cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 231 | *) 232 | if test -z "$stripcmd"; then 233 | u_plus_rw= 234 | else 235 | u_plus_rw=,u+rw 236 | fi 237 | cp_umask=$mode$u_plus_rw;; 238 | esac 239 | fi 240 | 241 | for src 242 | do 243 | # Protect names problematic for 'test' and other utilities. 244 | case $src in 245 | -* | [=\(\)!]) src=./$src;; 246 | esac 247 | 248 | if test -n "$dir_arg"; then 249 | dst=$src 250 | dstdir=$dst 251 | test -d "$dstdir" 252 | dstdir_status=$? 253 | else 254 | 255 | # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 256 | # might cause directories to be created, which would be especially bad 257 | # if $src (and thus $dsttmp) contains '*'. 258 | if test ! -f "$src" && test ! -d "$src"; then 259 | echo "$0: $src does not exist." >&2 260 | exit 1 261 | fi 262 | 263 | if test -z "$dst_arg"; then 264 | echo "$0: no destination specified." >&2 265 | exit 1 266 | fi 267 | dst=$dst_arg 268 | 269 | # If destination is a directory, append the input filename; won't work 270 | # if double slashes aren't ignored. 271 | if test -d "$dst"; then 272 | if test -n "$no_target_directory"; then 273 | echo "$0: $dst_arg: Is a directory" >&2 274 | exit 1 275 | fi 276 | dstdir=$dst 277 | dst=$dstdir/`basename "$src"` 278 | dstdir_status=0 279 | else 280 | # Prefer dirname, but fall back on a substitute if dirname fails. 281 | dstdir=` 282 | (dirname "$dst") 2>/dev/null || 283 | expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 284 | X"$dst" : 'X\(//\)[^/]' \| \ 285 | X"$dst" : 'X\(//\)$' \| \ 286 | X"$dst" : 'X\(/\)' \| . 2>/dev/null || 287 | echo X"$dst" | 288 | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 289 | s//\1/ 290 | q 291 | } 292 | /^X\(\/\/\)[^/].*/{ 293 | s//\1/ 294 | q 295 | } 296 | /^X\(\/\/\)$/{ 297 | s//\1/ 298 | q 299 | } 300 | /^X\(\/\).*/{ 301 | s//\1/ 302 | q 303 | } 304 | s/.*/./; q' 305 | ` 306 | 307 | test -d "$dstdir" 308 | dstdir_status=$? 309 | fi 310 | fi 311 | 312 | obsolete_mkdir_used=false 313 | 314 | if test $dstdir_status != 0; then 315 | case $posix_mkdir in 316 | '') 317 | # Create intermediate dirs using mode 755 as modified by the umask. 318 | # This is like FreeBSD 'install' as of 1997-10-28. 319 | umask=`umask` 320 | case $stripcmd.$umask in 321 | # Optimize common cases. 322 | *[2367][2367]) mkdir_umask=$umask;; 323 | .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 324 | 325 | *[0-7]) 326 | mkdir_umask=`expr $umask + 22 \ 327 | - $umask % 100 % 40 + $umask % 20 \ 328 | - $umask % 10 % 4 + $umask % 2 329 | `;; 330 | *) mkdir_umask=$umask,go-w;; 331 | esac 332 | 333 | # With -d, create the new directory with the user-specified mode. 334 | # Otherwise, rely on $mkdir_umask. 335 | if test -n "$dir_arg"; then 336 | mkdir_mode=-m$mode 337 | else 338 | mkdir_mode= 339 | fi 340 | 341 | posix_mkdir=false 342 | case $umask in 343 | *[123567][0-7][0-7]) 344 | # POSIX mkdir -p sets u+wx bits regardless of umask, which 345 | # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 346 | ;; 347 | *) 348 | tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 349 | trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 350 | 351 | if (umask $mkdir_umask && 352 | exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 353 | then 354 | if test -z "$dir_arg" || { 355 | # Check for POSIX incompatibilities with -m. 356 | # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 357 | # other-writable bit of parent directory when it shouldn't. 358 | # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 359 | ls_ld_tmpdir=`ls -ld "$tmpdir"` 360 | case $ls_ld_tmpdir in 361 | d????-?r-*) different_mode=700;; 362 | d????-?--*) different_mode=755;; 363 | *) false;; 364 | esac && 365 | $mkdirprog -m$different_mode -p -- "$tmpdir" && { 366 | ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 367 | test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 368 | } 369 | } 370 | then posix_mkdir=: 371 | fi 372 | rmdir "$tmpdir/d" "$tmpdir" 373 | else 374 | # Remove any dirs left behind by ancient mkdir implementations. 375 | rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 376 | fi 377 | trap '' 0;; 378 | esac;; 379 | esac 380 | 381 | if 382 | $posix_mkdir && ( 383 | umask $mkdir_umask && 384 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 385 | ) 386 | then : 387 | else 388 | 389 | # The umask is ridiculous, or mkdir does not conform to POSIX, 390 | # or it failed possibly due to a race condition. Create the 391 | # directory the slow way, step by step, checking for races as we go. 392 | 393 | case $dstdir in 394 | /*) prefix='/';; 395 | [-=\(\)!]*) prefix='./';; 396 | *) prefix='';; 397 | esac 398 | 399 | eval "$initialize_posix_glob" 400 | 401 | oIFS=$IFS 402 | IFS=/ 403 | $posix_glob set -f 404 | set fnord $dstdir 405 | shift 406 | $posix_glob set +f 407 | IFS=$oIFS 408 | 409 | prefixes= 410 | 411 | for d 412 | do 413 | test X"$d" = X && continue 414 | 415 | prefix=$prefix$d 416 | if test -d "$prefix"; then 417 | prefixes= 418 | else 419 | if $posix_mkdir; then 420 | (umask=$mkdir_umask && 421 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 422 | # Don't fail if two instances are running concurrently. 423 | test -d "$prefix" || exit 1 424 | else 425 | case $prefix in 426 | *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 427 | *) qprefix=$prefix;; 428 | esac 429 | prefixes="$prefixes '$qprefix'" 430 | fi 431 | fi 432 | prefix=$prefix/ 433 | done 434 | 435 | if test -n "$prefixes"; then 436 | # Don't fail if two instances are running concurrently. 437 | (umask $mkdir_umask && 438 | eval "\$doit_exec \$mkdirprog $prefixes") || 439 | test -d "$dstdir" || exit 1 440 | obsolete_mkdir_used=true 441 | fi 442 | fi 443 | fi 444 | 445 | if test -n "$dir_arg"; then 446 | { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 447 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 448 | { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 449 | test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 450 | else 451 | 452 | # Make a couple of temp file names in the proper directory. 453 | dsttmp=$dstdir/_inst.$$_ 454 | rmtmp=$dstdir/_rm.$$_ 455 | 456 | # Trap to clean up those temp files at exit. 457 | trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 458 | 459 | # Copy the file name to the temp name. 460 | (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 461 | 462 | # and set any options; do chmod last to preserve setuid bits. 463 | # 464 | # If any of these fail, we abort the whole thing. If we want to 465 | # ignore errors from any of these, just make sure not to ignore 466 | # errors from the above "$doit $cpprog $src $dsttmp" command. 467 | # 468 | { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && 469 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && 470 | { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 471 | { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 472 | 473 | # If -C, don't bother to copy if it wouldn't change the file. 474 | if $copy_on_change && 475 | old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 476 | new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 477 | 478 | eval "$initialize_posix_glob" && 479 | $posix_glob set -f && 480 | set X $old && old=:$2:$4:$5:$6 && 481 | set X $new && new=:$2:$4:$5:$6 && 482 | $posix_glob set +f && 483 | 484 | test "$old" = "$new" && 485 | $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 486 | then 487 | rm -f "$dsttmp" 488 | else 489 | # Rename the file to the real destination. 490 | $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || 491 | 492 | # The rename failed, perhaps because mv can't rename something else 493 | # to itself, or perhaps because mv is so ancient that it does not 494 | # support -f. 495 | { 496 | # Now remove or move aside any old file at destination location. 497 | # We try this two ways since rm can't unlink itself on some 498 | # systems and the destination file might be busy for other 499 | # reasons. In this case, the final cleanup might fail but the new 500 | # file should still install successfully. 501 | { 502 | test ! -f "$dst" || 503 | $doit $rmcmd -f "$dst" 2>/dev/null || 504 | { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 505 | { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 506 | } || 507 | { echo "$0: cannot unlink or rename $dst" >&2 508 | (exit 1); exit 1 509 | } 510 | } && 511 | 512 | # Now rename the file to the real destination. 513 | $doit $mvcmd "$dsttmp" "$dst" 514 | } 515 | fi || exit 1 516 | 517 | trap '' 0 518 | fi 519 | done 520 | 521 | # Local variables: 522 | # eval: (add-hook 'write-file-hooks 'time-stamp) 523 | # time-stamp-start: "scriptversion=" 524 | # time-stamp-format: "%:y-%02m-%02d.%02H" 525 | # time-stamp-time-zone: "UTC" 526 | # time-stamp-end: "; # UTC" 527 | # End: 528 | -------------------------------------------------------------------------------- /lmdbjni/src/main/java/org/fusesource/lmdbjni/JNI.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013, RedHat, Inc. 3 | * 4 | * http://www.redhat.com/ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.fusesource.lmdbjni; 20 | 21 | import org.fusesource.hawtjni.runtime.*; 22 | 23 | import static org.fusesource.hawtjni.runtime.ClassFlag.STRUCT; 24 | import static org.fusesource.hawtjni.runtime.ClassFlag.TYPEDEF; 25 | import static org.fusesource.hawtjni.runtime.FieldFlag.CONSTANT; 26 | import static org.fusesource.hawtjni.runtime.MethodFlag.CONSTANT_GETTER; 27 | import static org.fusesource.hawtjni.runtime.MethodFlag.CONSTANT_INITIALIZER; 28 | import static org.fusesource.hawtjni.runtime.ArgFlag.*; 29 | 30 | /** 31 | * This class holds all the native constant, structure and function mappings. 32 | * 33 | * @author Hiram Chirino 34 | */ 35 | @JniClass 36 | class JNI { 37 | 38 | public static final Library LIBRARY = new Library("lmdbjni", JNI.class); 39 | 40 | static { 41 | JNI.LIBRARY.load(); 42 | init(); 43 | } 44 | 45 | @JniMethod(flags = {CONSTANT_INITIALIZER}) 46 | private static final native void init(); 47 | 48 | /////////////////////////////////////////////////////////////////////// 49 | // 50 | // Posix APIs: 51 | // 52 | /////////////////////////////////////////////////////////////////////// 53 | 54 | @JniMethod(flags={CONSTANT_GETTER}) 55 | public static final native int errno(); 56 | 57 | @JniMethod(cast="char *") 58 | public static final native long strerror(int errnum); 59 | 60 | public static final native int strlen( 61 | @JniArg(cast="const char *")long s); 62 | 63 | @JniMethod(cast="void *") 64 | public static final native long malloc( 65 | @JniArg(cast="size_t") long size); 66 | 67 | public static final native void free( 68 | @JniArg(cast="void *") long self); 69 | 70 | /////////////////////////////////////////////////////////////////////// 71 | // 72 | // Additional Helpers 73 | // 74 | /////////////////////////////////////////////////////////////////////// 75 | public static final native void buffer_copy ( 76 | @JniArg(cast="const void *", flags={NO_OUT, CRITICAL}) byte[] src, 77 | @JniArg(cast="size_t") long srcPos, 78 | @JniArg(cast="void *") long dest, 79 | @JniArg(cast="size_t") long destPos, 80 | @JniArg(cast="size_t") long length); 81 | 82 | public static final native void buffer_copy ( 83 | @JniArg(cast="const void *") long src, 84 | @JniArg(cast="size_t") long srcPos, 85 | @JniArg(cast="void *", flags={NO_IN, CRITICAL}) byte[] dest, 86 | @JniArg(cast="size_t") long destPos, 87 | @JniArg(cast="size_t") long length); 88 | 89 | /////////////////////////////////////////////////////////////////////// 90 | // 91 | // The lmdb API 92 | // 93 | /////////////////////////////////////////////////////////////////////// 94 | 95 | //====================================================// 96 | // Version Info 97 | //====================================================// 98 | @JniField(flags = {CONSTANT}) 99 | static public int MDB_VERSION_MAJOR; 100 | @JniField(flags = {CONSTANT}) 101 | static public int MDB_VERSION_MINOR; 102 | @JniField(flags = {CONSTANT}) 103 | static public int MDB_VERSION_PATCH; 104 | @JniField(flags = {CONSTANT}) 105 | static public int MDB_VERSION_FULL; 106 | 107 | @JniField(cast = "const char *", flags = {CONSTANT}) 108 | static long MDB_VERSION_DATE; 109 | @JniField(cast = "const char *", flags = {CONSTANT}) 110 | static long MDB_VERSION_STRING; 111 | 112 | //====================================================// 113 | // Environment Flags 114 | //====================================================// 115 | @JniField(flags = {CONSTANT}) 116 | static public int MDB_FIXEDMAP; 117 | @JniField(flags = {CONSTANT}) 118 | static public int MDB_NOSUBDIR; 119 | @JniField(flags = {CONSTANT}) 120 | static public int MDB_NOSYNC; 121 | @JniField(flags = {CONSTANT}) 122 | static public int MDB_RDONLY; 123 | @JniField(flags = {CONSTANT}) 124 | static public int MDB_NOMETASYNC; 125 | @JniField(flags = {CONSTANT}) 126 | static public int MDB_WRITEMAP; 127 | @JniField(flags = {CONSTANT}) 128 | static public int MDB_MAPASYNC; 129 | @JniField(flags = {CONSTANT}) 130 | static public int MDB_NOTLS; 131 | 132 | //====================================================// 133 | // Database Flags 134 | //====================================================// 135 | @JniField(flags = {CONSTANT}) 136 | static public int MDB_REVERSEKEY; 137 | @JniField(flags = {CONSTANT}) 138 | static public int MDB_DUPSORT; 139 | @JniField(flags = {CONSTANT}) 140 | static public int MDB_INTEGERKEY; 141 | @JniField(flags = {CONSTANT}) 142 | static public int MDB_DUPFIXED; 143 | @JniField(flags = {CONSTANT}) 144 | static public int MDB_INTEGERDUP; 145 | @JniField(flags = {CONSTANT}) 146 | static public int MDB_REVERSEDUP; 147 | @JniField(flags = {CONSTANT}) 148 | static public int MDB_CREATE; 149 | 150 | //====================================================// 151 | // Write Flags 152 | //====================================================// 153 | @JniField(flags = {CONSTANT}) 154 | static public int MDB_NOOVERWRITE; 155 | @JniField(flags = {CONSTANT}) 156 | static public int MDB_NODUPDATA; 157 | @JniField(flags = {CONSTANT}) 158 | static public int MDB_CURRENT; 159 | @JniField(flags = {CONSTANT}) 160 | static public int MDB_RESERVE; 161 | @JniField(flags = {CONSTANT}) 162 | static public int MDB_APPEND; 163 | @JniField(flags = {CONSTANT}) 164 | static public int MDB_APPENDDUP; 165 | @JniField(flags = {CONSTANT}) 166 | static public int MDB_MULTIPLE; 167 | 168 | //====================================================// 169 | // enum MDB_cursor_op: 170 | //====================================================// 171 | @JniField(flags = {CONSTANT}) 172 | static public int MDB_FIRST; 173 | @JniField(flags = {CONSTANT}) 174 | static public int MDB_FIRST_DUP; 175 | @JniField(flags = {CONSTANT}) 176 | static public int MDB_GET_BOTH; 177 | @JniField(flags = {CONSTANT}) 178 | static public int MDB_GET_BOTH_RANGE; 179 | @JniField(flags = {CONSTANT}) 180 | static public int MDB_GET_CURRENT; 181 | @JniField(flags = {CONSTANT}) 182 | static public int MDB_GET_MULTIPLE; 183 | @JniField(flags = {CONSTANT}) 184 | static public int MDB_LAST; 185 | @JniField(flags = {CONSTANT}) 186 | static public int MDB_LAST_DUP; 187 | @JniField(flags = {CONSTANT}) 188 | static public int MDB_NEXT; 189 | @JniField(flags = {CONSTANT}) 190 | static public int MDB_NEXT_DUP; 191 | @JniField(flags = {CONSTANT}) 192 | static public int MDB_NEXT_MULTIPLE; 193 | @JniField(flags = {CONSTANT}) 194 | static public int MDB_NEXT_NODUP; 195 | @JniField(flags = {CONSTANT}) 196 | static public int MDB_PREV; 197 | @JniField(flags = {CONSTANT}) 198 | static public int MDB_PREV_DUP; 199 | @JniField(flags = {CONSTANT}) 200 | static public int MDB_PREV_NODUP; 201 | @JniField(flags = {CONSTANT}) 202 | static public int MDB_SET; 203 | @JniField(flags = {CONSTANT}) 204 | static public int MDB_SET_KEY; 205 | @JniField(flags = {CONSTANT}) 206 | static public int MDB_SET_RANGE; 207 | 208 | //====================================================// 209 | // Return Codes 210 | //====================================================// 211 | @JniField(flags = {CONSTANT}) 212 | static public int MDB_SUCCESS; 213 | @JniField(flags = {CONSTANT}) 214 | static public int MDB_KEYEXIST; 215 | @JniField(flags = {CONSTANT}) 216 | static public int MDB_NOTFOUND; 217 | @JniField(flags = {CONSTANT}) 218 | static public int MDB_PAGE_NOTFOUND; 219 | @JniField(flags = {CONSTANT}) 220 | static public int MDB_CORRUPTED; 221 | @JniField(flags = {CONSTANT}) 222 | static public int MDB_PANIC; 223 | @JniField(flags = {CONSTANT}) 224 | static public int MDB_VERSION_MISMATCH; 225 | @JniField(flags = {CONSTANT}) 226 | static public int MDB_INVALID; 227 | @JniField(flags = {CONSTANT}) 228 | static public int MDB_MAP_FULL; 229 | @JniField(flags = {CONSTANT}) 230 | static public int MDB_DBS_FULL; 231 | @JniField(flags = {CONSTANT}) 232 | static public int MDB_READERS_FULL; 233 | @JniField(flags = {CONSTANT}) 234 | static public int MDB_TLS_FULL; 235 | @JniField(flags = {CONSTANT}) 236 | static public int MDB_TXN_FULL; 237 | @JniField(flags = {CONSTANT}) 238 | static public int MDB_CURSOR_FULL; 239 | @JniField(flags = {CONSTANT}) 240 | static public int MDB_PAGE_FULL; 241 | @JniField(flags = {CONSTANT}) 242 | static public int MDB_MAP_RESIZED; 243 | @JniField(flags = {CONSTANT}) 244 | static public int MDB_INCOMPATIBLE; 245 | @JniField(flags = {CONSTANT}) 246 | static public int MDB_BAD_RSLOT; 247 | @JniField(flags = {CONSTANT}) 248 | static public int MDB_LAST_ERRCODE; 249 | 250 | /** 251 | * details 252 | */ 253 | @JniClass(flags = {STRUCT, TYPEDEF}) 254 | static public class MDB_envinfo { 255 | @JniField(cast = "void *") 256 | public long me_mapaddr; 257 | @JniField(cast = "size_t") 258 | public long me_mapsize; 259 | @JniField(cast = "size_t") 260 | public long me_last_pgno; 261 | @JniField(cast = "size_t") 262 | public long me_last_txnid; 263 | @JniField(cast = "unsigned int") 264 | public long me_maxreaders; 265 | @JniField(cast = "unsigned int") 266 | public long me_numreaders; 267 | 268 | @Override 269 | public String toString() { 270 | return "{" + 271 | "me_last_pgno=" + me_last_pgno + 272 | ", me_mapaddr=" + me_mapaddr + 273 | ", me_mapsize=" + me_mapsize + 274 | ", me_last_txnid=" + me_last_txnid + 275 | ", me_maxreaders=" + me_maxreaders + 276 | ", me_numreaders=" + me_numreaders + 277 | '}'; 278 | } 279 | } 280 | 281 | /** 282 | * details 283 | */ 284 | @JniClass(flags = {STRUCT, TYPEDEF}) 285 | public static class MDB_stat { 286 | @JniField(cast = "unsigned int") 287 | public long ms_psize; 288 | @JniField(cast = "unsigned int") 289 | public long ms_depth; 290 | @JniField(cast = "size_t") 291 | public long ms_branch_pages; 292 | @JniField(cast = "size_t") 293 | public long ms_leaf_pages; 294 | @JniField(cast = "size_t") 295 | public long ms_overflow_pages; 296 | @JniField(cast = "size_t") 297 | public long ms_entries; 298 | 299 | @Override 300 | public String toString() { 301 | return "{" + 302 | "ms_branch_pages=" + ms_branch_pages + 303 | ", ms_psize=" + ms_psize + 304 | ", ms_depth=" + ms_depth + 305 | ", ms_leaf_pages=" + ms_leaf_pages + 306 | ", ms_overflow_pages=" + ms_overflow_pages + 307 | ", ms_entries=" + ms_entries + 308 | '}'; 309 | } 310 | } 311 | 312 | /** 313 | * details 314 | */ 315 | @JniClass(flags = {STRUCT, TYPEDEF}) 316 | public static class MDB_val { 317 | @JniField(cast = "size_t") 318 | public long mv_size; 319 | @JniField(cast = "void *") 320 | public long mv_data; 321 | } 322 | 323 | /** 324 | * details 325 | */ 326 | @JniMethod(cast="char *") 327 | public static final native long mdb_strerror(int err); 328 | 329 | /** 330 | * details 331 | */ 332 | @JniMethod 333 | public static final native int mdb_env_create( 334 | @JniArg(cast = "MDB_env **", flags={NO_IN}) long[] env); 335 | 336 | /** 337 | * details 338 | */ 339 | @JniMethod 340 | public static final native int mdb_env_open( 341 | @JniArg(cast = "MDB_env *") long env, 342 | @JniArg(cast = "const char *") String path, 343 | @JniArg(cast = "unsigned int") int flags, 344 | @JniArg(cast = "mdb_mode_t") int mode 345 | ); 346 | 347 | /** 348 | * details 349 | */ 350 | @JniMethod 351 | public static final native int mdb_env_copy( 352 | @JniArg(cast = "MDB_env *") long env, 353 | @JniArg(cast = "const char *") String path); 354 | 355 | /** 356 | * details 357 | */ 358 | @JniMethod 359 | public static final native int mdb_env_stat( 360 | @JniArg(cast = "MDB_env *") long env, 361 | @JniArg(cast = "MDB_stat *", flags = {NO_IN}) MDB_stat stat); 362 | 363 | /** 364 | * details 365 | */ 366 | @JniMethod 367 | public static final native int mdb_env_info( 368 | @JniArg(cast = "MDB_env *") long env, 369 | @JniArg(cast = " MDB_envinfo *", flags = {NO_IN}) MDB_envinfo stat); 370 | 371 | /** 372 | * details 373 | */ 374 | @JniMethod 375 | public static final native int mdb_env_sync( 376 | @JniArg(cast = "MDB_env *") long env, 377 | @JniArg(cast = "int") int force); 378 | 379 | 380 | /** 381 | * details 382 | */ 383 | @JniMethod 384 | public static final native void mdb_env_close( 385 | @JniArg(cast = "MDB_env *") long env); 386 | 387 | /** 388 | * details 389 | */ 390 | @JniMethod 391 | public static final native int mdb_env_set_flags( 392 | @JniArg(cast = "MDB_env *") long env, 393 | @JniArg(cast = "unsigned int") int flags, 394 | @JniArg(cast = "int") int onoff); 395 | 396 | /** 397 | * details 398 | */ 399 | @JniMethod 400 | public static final native int mdb_env_get_flags( 401 | @JniArg(cast = "MDB_env *") long env, 402 | @JniArg(cast = "unsigned int *") long[] flags); 403 | 404 | /** 405 | * details 406 | */ 407 | @JniMethod 408 | public static final native int mdb_env_get_path( 409 | @JniArg(cast = "MDB_env *") long env, 410 | @JniArg(cast = "const char **", flags={NO_IN}) long[] path); 411 | 412 | /** 413 | * details 414 | */ 415 | @JniMethod 416 | public static final native int mdb_env_set_mapsize( 417 | @JniArg(cast = "MDB_env *") long env, 418 | @JniArg(cast = "size_t") long size); 419 | 420 | /** 421 | * details 422 | */ 423 | @JniMethod 424 | public static final native int mdb_env_set_maxreaders( 425 | @JniArg(cast = "MDB_env *") long env, 426 | @JniArg(cast = "unsigned int") long readers); 427 | 428 | /** 429 | * details 430 | */ 431 | @JniMethod 432 | public static final native int mdb_env_get_maxreaders( 433 | @JniArg(cast = "MDB_env *") long env, 434 | @JniArg(cast = "unsigned int *") long[] readers); 435 | 436 | /** 437 | * details 438 | */ 439 | @JniMethod 440 | public static final native int mdb_env_set_maxdbs( 441 | @JniArg(cast = "MDB_env *") long env, 442 | @JniArg(cast = "unsigned int") long dbs); 443 | 444 | /** 445 | * details 446 | */ 447 | @JniMethod 448 | public static final native int mdb_txn_begin( 449 | @JniArg(cast = "MDB_env *") long env, 450 | @JniArg(cast = "MDB_txn *") long parent, 451 | @JniArg(cast = "unsigned int") long flags, 452 | @JniArg(cast = "MDB_txn **", flags={NO_IN}) long[] txn); 453 | 454 | /** 455 | * details 456 | */ 457 | @JniMethod 458 | public static final native int mdb_txn_commit( 459 | @JniArg(cast = "MDB_txn *") long txn); 460 | 461 | /** 462 | * details 463 | */ 464 | @JniMethod 465 | public static final native void mdb_txn_abort( 466 | @JniArg(cast = "MDB_txn *") long txn); 467 | 468 | /** 469 | * details 470 | */ 471 | @JniMethod 472 | public static final native void mdb_txn_reset( 473 | @JniArg(cast = "MDB_txn *") long txn); 474 | 475 | /** 476 | * details 477 | */ 478 | @JniMethod 479 | public static final native int mdb_txn_renew( 480 | @JniArg(cast = "MDB_txn *") long txn); 481 | 482 | /** 483 | * details 484 | */ 485 | @JniMethod 486 | public static final native int mdb_dbi_open( 487 | @JniArg(cast = "MDB_txn *") long txn, 488 | @JniArg(cast = "const char *") String name, 489 | @JniArg(cast = "unsigned int") long flags, 490 | @JniArg(cast = "unsigned int *") long[] dbi); 491 | 492 | /** 493 | * details 494 | */ 495 | @JniMethod 496 | public static final native int mdb_stat( 497 | @JniArg(cast = "MDB_txn *") long txn, 498 | @JniArg(cast = "unsigned int ") long dbi, 499 | @JniArg(cast = "MDB_stat *", flags = {NO_IN}) MDB_stat stat); 500 | 501 | /** 502 | * details 503 | */ 504 | @JniMethod 505 | public static final native void mdb_dbi_close( 506 | @JniArg(cast = "MDB_env *") long env, 507 | @JniArg(cast = "unsigned int ") long dbi); 508 | 509 | /** 510 | * details 511 | */ 512 | @JniMethod 513 | public static final native int mdb_drop( 514 | @JniArg(cast = "MDB_txn *") long txn, 515 | @JniArg(cast = "unsigned int ") long dbi, 516 | int del); 517 | 518 | /** 519 | * details 520 | */ 521 | @JniMethod 522 | public static final native int mdb_set_compare( 523 | @JniArg(cast = "MDB_txn *") long txn, 524 | @JniArg(cast = "unsigned int ") long dbi, 525 | @JniArg(cast = "MDB_cmp_func *") long cmp); 526 | 527 | /** 528 | * details 529 | */ 530 | @JniMethod 531 | public static final native int mdb_set_dupsort( 532 | @JniArg(cast = "MDB_txn *") long txn, 533 | @JniArg(cast = "unsigned int ") long dbi, 534 | @JniArg(cast = "MDB_cmp_func *") long cmp); 535 | 536 | 537 | /** 538 | * details 539 | */ 540 | @JniMethod 541 | public static final native int mdb_get( 542 | @JniArg(cast = "MDB_txn *") long txn, 543 | @JniArg(cast = "unsigned int ") long dbi, 544 | @JniArg(cast = "MDB_val *", flags={NO_OUT}) MDB_val key, 545 | @JniArg(cast = "MDB_val *", flags={NO_IN}) MDB_val data); 546 | 547 | /** 548 | * details 549 | */ 550 | @JniMethod 551 | public static final native int mdb_put( 552 | @JniArg(cast = "MDB_txn *") long txn, 553 | @JniArg(cast = "unsigned int ") long dbi, 554 | @JniArg(cast = "MDB_val *", flags={NO_OUT}) MDB_val key, 555 | @JniArg(cast = "MDB_val *") MDB_val data, 556 | @JniArg(cast = "unsigned int") int flags); 557 | 558 | /** 559 | * details 560 | */ 561 | @JniMethod 562 | public static final native int mdb_del( 563 | @JniArg(cast = "MDB_txn *") long txn, 564 | @JniArg(cast = "unsigned int ") long dbi, 565 | @JniArg(cast = "MDB_val *", flags={NO_OUT}) MDB_val key, 566 | @JniArg(cast = "MDB_val *", flags={NO_OUT}) MDB_val data); 567 | 568 | /** 569 | * details 570 | */ 571 | @JniMethod 572 | public static final native int mdb_cursor_open( 573 | @JniArg(cast = "MDB_txn *") long txn, 574 | @JniArg(cast = "unsigned int") long dbi, 575 | @JniArg(cast = "MDB_cursor **", flags={NO_IN}) long[] cursor); 576 | 577 | /** 578 | * details 579 | */ 580 | @JniMethod 581 | public static final native void mdb_cursor_close( 582 | @JniArg(cast = "MDB_cursor *") long cursor); 583 | 584 | /** 585 | * details 586 | */ 587 | @JniMethod 588 | public static final native int mdb_cursor_renew( 589 | @JniArg(cast = "MDB_txn *") long txn, 590 | @JniArg(cast = "MDB_cursor *") long cursor); 591 | 592 | /** 593 | * details 594 | */ 595 | @JniMethod(cast = "MDB_txn *") 596 | public static final native long mdb_cursor_txn( 597 | @JniArg(cast = "MDB_cursor *") long cursor); 598 | 599 | /** 600 | * details 601 | */ 602 | @JniMethod(cast = "unsigned int") 603 | public static final native long mdb_cursor_dbi( 604 | @JniArg(cast = "MDB_cursor *") long cursor); 605 | 606 | /** 607 | * details 608 | */ 609 | @JniMethod 610 | public static final native int mdb_cursor_get( 611 | @JniArg(cast = "MDB_cursor *") long cursor, 612 | @JniArg(cast = "MDB_val *") MDB_val key, 613 | @JniArg(cast = "MDB_val *") MDB_val data, 614 | @JniArg(cast = "MDB_cursor_op") int op); 615 | 616 | /** 617 | * details 618 | */ 619 | @JniMethod 620 | public static final native int mdb_cursor_put( 621 | @JniArg(cast = "MDB_cursor *") long cursor, 622 | @JniArg(cast = "MDB_val *", flags = {NO_OUT}) MDB_val key, 623 | @JniArg(cast = "MDB_val *", flags = {NO_OUT}) MDB_val data, 624 | @JniArg(cast = "unsigned int ") int flags); 625 | 626 | /** 627 | * details 628 | */ 629 | @JniMethod 630 | public static final native int mdb_cursor_del( 631 | @JniArg(cast = "MDB_cursor *") long cursor, 632 | @JniArg(cast = "unsigned int ") int flags); 633 | 634 | /** 635 | * details 636 | */ 637 | @JniMethod 638 | public static final native int mdb_cursor_count( 639 | @JniArg(cast = "MDB_cursor *") long cursor, 640 | @JniArg(cast = "size_t *") long[] countp); 641 | 642 | /** 643 | * details 644 | */ 645 | @JniMethod 646 | public static final native int mdb_cmp( 647 | @JniArg(cast = "MDB_txn *") long txn, 648 | @JniArg(cast = "unsigned int") long dbi, 649 | @JniArg(cast = "MDB_val *", flags = {NO_OUT}) MDB_val a, 650 | @JniArg(cast = "MDB_val *", flags = {NO_OUT}) MDB_val b); 651 | 652 | /** 653 | * details 654 | */ 655 | @JniMethod 656 | public static final native int mdb_dcmp( 657 | @JniArg(cast = "MDB_txn *") long txn, 658 | @JniArg(cast = "unsigned int") long dbi, 659 | @JniArg(cast = "MDB_val *", flags = {NO_OUT}) MDB_val a, 660 | @JniArg(cast = "MDB_val *", flags = {NO_OUT}) MDB_val b); 661 | 662 | 663 | } 664 | --------------------------------------------------------------------------------