diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 000000000..96fa2db9b
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1 @@
+github: jankotek
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 000000000..5c9fb507e
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,27 @@
+---
+name: Java CI
+
+on: [push]
+
+jobs:
+ test:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [ubuntu-18.04, macOS-latest, windows-2016]
+ java: [8, 11]
+ fail-fast: false
+ max-parallel: 4
+ name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up JDK
+ uses: actions/setup-java@v1
+ with:
+ java-version: ${{ matrix.java }}
+ - name: Grant execute permission for gradlew
+ run: chmod +x gradlew
+ - name: Test with Gradle
+ run: ./gradlew test
+...
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 56a24e63a..d669ddbd7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,9 +3,17 @@
.settings
.idea
target
+build
bin
out
helper
*.iml
*.ipr
-*.iws
\ No newline at end of file
+*.iws
+.directory
+*.log
+.gradle
+*.log
+
+
+srcGen/*
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 546a954c0..76f870814 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,13 +1,28 @@
language: java
-cache:
- directories:
- - $HOME/.m2
jdk:
- - oraclejdk7
- - openjdk7
- - openjdk6
+ - openjdk8
+ - openjdk11
+# - oraclejdk10
+
+sudo: false
+
+before_cache:
+ - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
+ - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
+
+#before_install:
+# - sudo apt-get purge gradle
+# - sudo add-apt-repository ppa:cwchien/gradle -y
+# - sudo apt-get update -q
+# - sudo apt-get install gradle -y
+
+cache:
+ directories:
+ - $HOME/.gradle/caches/
+ - $HOME/.gradle/wrapper/
+ - $HOME/.m2/repository/
-install: true
+install: /bin/true
-script: mvn test
+script: ./gradlew test
diff --git a/license.txt b/LICENSE.txt
similarity index 100%
rename from license.txt
rename to LICENSE.txt
diff --git a/README.md b/README.md
index 5b4189ba5..972b13432 100644
--- a/README.md
+++ b/README.md
@@ -1,21 +1,64 @@
-MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap memory.
-MapDB is free as speech and free as beer under
-[Apache License 2.0](https://github.com/jankotek/MapDB/blob/master/doc/license.txt).
+
-Find out more at:
- * [Home page - www.mapdb.org](http://www.mapdb.org)
- * [Introduction](http://www.mapdb.org/02-getting-started.html)
- * [Examples](https://github.com/jankotek/MapDB/tree/master/src/test/java/examples)
- * [Javadoc](http://www.mapdb.org/apidocs/index.html)
+MapDB: database engine
+=======================
+[](https://travis-ci.org/jankotek/mapdb)
+[](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.mapdb%22%20AND%20a%3Amapdb)
+[](https://gitter.im/jankotek/mapdb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-15 minutes overview
+MapDB combines embedded database engine and Java collections.
+It is free under Apache 2 license. MapDB is flexible and can be used in many roles:
+
+* Drop-in replacement for Maps, Lists, Queues and other collections.
+* Off-heap collections not affected by Garbage Collector
+* Multilevel cache with expiration and disk overflow.
+* RDBMs replacement with transactions, MVCC, incremental backups etc…
+* Local data processing and filtering. MapDB has utilities to process huge quantities of data in reasonable time.
+
+Hello world
+-------------------
+
+Maven snippet, VERSION is [](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.mapdb%22%20AND%20a%3Amapdb)
+
+```xml
+
+ org.mapdb
+ mapdb
+ VERSION
+
+```
+
+Hello world:
+
+```java
+//import org.mapdb.*
+DB db = DBMaker.memoryDB().make();
+ConcurrentMap map = db.hashMap("map").make();
+map.put("something", "here");
+```
+
+You can continue with [quick start](https://jankotek.gitbooks.io/mapdb/content/quick-start/) or refer to the [documentation](https://jankotek.gitbooks.io/mapdb/).
+
+Support
------------
-
+More [details](http://www.mapdb.org/support/).
+
+Development
+--------------------
+MapDB is written in Kotlin, you will need IntelliJ Idea.
+You can use Gradle to build MapDB.
+MapDB is extensively unit-tested.
+By default, only tiny fraction of all tests are executed, so build finishes under 10 minutes.
+Full test suite has over million test cases and runs for several hours/days.
+To run full test suite, set `-Dmdbtest=1` VM option.
+Longer unit tests might require more memory. Use this to increase heap memory assigned to unit tests: `-DtestArgLine="-Xmx3G"`
+By default unit tests are executed in 3 threads. Thread count is controlled by `-DtestThreadCount=3` property
+On machine with limited memory you can change fork mode so unit test consume less RAM, but run longer: `-DtestReuseForks=false`
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 000000000..583a520da
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,67 @@
+buildscript {
+
+ ext.kotlin_version = '1.4.10'
+ ext.junit_version = '5.7.0'
+ ext.ec_version = '10.4.0'
+ ext.guava_version = '28.2-jre'
+
+ repositories {
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ }
+}
+apply plugin: "kotlin"
+
+compileKotlin {
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
+}
+
+
+sourceSets {
+ //combine Kotlin and Java source into same dirs
+ main.kotlin.srcDirs += 'src/main/java'
+ main.java.srcDirs += 'src/main/java'
+ test.kotlin.srcDirs += 'src/test/java'
+ test.java.srcDirs += 'src/test/java'
+
+ //include generated code into build
+ main.kotlin.srcDirs += 'srcGen/main/java'
+ main.java.srcDirs += 'srcGen/main/java'
+ test.kotlin.srcDirs += 'srcGen/test/java'
+ test.java.srcDirs += 'srcGen/test/java'
+
+}
+
+repositories {
+ mavenCentral()
+}
+
+
+test{
+ maxParallelForks = 5
+ maxHeapSize = '2G'
+}
+
+dependencies {
+ compile "org.eclipse.collections:eclipse-collections-api:$ec_version"
+ compile "org.eclipse.collections:eclipse-collections:$ec_version"
+
+ compile "com.google.guava:guava:$guava_version"
+
+ compile group: 'org.jetbrains', name: 'annotations', version: '20.1.0'
+
+ compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
+ compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
+
+ compile 'org.lz4:lz4-java:1.7.1'
+
+ testCompile("io.kotlintest:kotlintest-runner-junit5:3.4.2")
+ testCompile("org.junit.vintage:junit-vintage-engine:$junit_version")
+ testCompile("org.junit.jupiter:junit-jupiter-api:$junit_version")
+ testCompile("org.junit.jupiter:junit-jupiter-engine:$junit_version")
+}
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
new file mode 100644
index 000000000..3232f5537
--- /dev/null
+++ b/buildSrc/build.gradle
@@ -0,0 +1,54 @@
+buildscript {
+ ext.kotlin_version = '1.2.50'
+
+ repositories {
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ }
+}
+
+apply plugin: "kotlin"
+
+compileKotlin {
+ kotlinOptions {
+// freeCompilerArgs = ['-Xenable-jvm-default']
+ jvmTarget = '1.8'
+ }
+}
+
+
+sourceSets {
+ main.kotlin.srcDirs += 'src/main/java'
+ main.java.srcDirs += 'src/main/java'
+ test.kotlin.srcDirs += 'src/test/java'
+ test.java.srcDirs += 'src/test/java'
+
+
+}
+
+repositories {
+ mavenCentral()
+}
+
+
+dependencies {
+ compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
+}
+
+
+task codegenClean(type: Delete) {
+ delete "../srcGen"
+}
+
+task codegen(type:JavaExec) {
+
+ dependsOn(codegenClean)
+ main = "MDBCodeGen"
+ classpath = sourceSets.main.runtimeClasspath
+}
+
+
+build.dependsOn(codegen)
\ No newline at end of file
diff --git a/buildSrc/src/main/java/GenMarkers.kt b/buildSrc/src/main/java/GenMarkers.kt
new file mode 100644
index 000000000..e37233380
--- /dev/null
+++ b/buildSrc/src/main/java/GenMarkers.kt
@@ -0,0 +1,42 @@
+import java.io.File
+
+object GenMarkers{
+
+ val markers:Map = linkedMapOf(
+ Pair("//-WLOCK", """lock.writeLock().lock(); try{"""),
+ Pair("//-WUNLOCK", """}finally{lock.writeLock().unlock();}"""),
+ Pair("//-newRWLOCK", """java.util.concurrent.locks.ReadWriteLock lock = new java.util.concurrent.locks.ReentrantReadWriteLock();""")
+ )
+
+ fun recurJavaFiles(dir:File, f: (File) -> Unit){
+ val allFiles = dir.listFiles();
+ allFiles.filter { it.extension.equals("java") }.forEach(f)
+ allFiles.filter{it.isDirectory}.forEach{recurJavaFiles(it,f)}
+ }
+
+
+ // process //*-WLOCk markers
+ fun wlock(srcDir: File, genDir:File) {
+ recurJavaFiles(srcDir) { f:File->
+ var content = f.readText()
+
+ if(markers.keys.none{content.contains(it)}) {
+ return@recurJavaFiles
+ }
+ for ((marker, repl) in markers) {
+ content = content.replace(marker, repl)
+ }
+
+ val oldClassName = f.nameWithoutExtension
+ content = content.replace("class "+oldClassName, "class ${oldClassName}RWLock")
+ content = content.replace(" "+oldClassName+"(", " ${oldClassName}RWLock(")
+
+ val newFile = File(genDir.path + "/"+ f.relativeTo(srcDir).parent +"/"+ oldClassName + "RWLock.java")
+
+ newFile.parentFile.mkdirs()
+ newFile.writeText(content)
+
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/buildSrc/src/main/java/GenRecords.kt b/buildSrc/src/main/java/GenRecords.kt
new file mode 100644
index 000000000..3e4ad392e
--- /dev/null
+++ b/buildSrc/src/main/java/GenRecords.kt
@@ -0,0 +1,154 @@
+import org.gradle.internal.impldep.org.apache.commons.io.FileUtils
+import java.io.File
+
+object GenRecords {
+
+ fun makeRecordMakers(dir: File){
+ data class R(val type:String, val initVal:String, val ser:String){
+
+ val gen = if(type!="Var") "" else ""
+
+ val isVar = type=="Var"
+ val isNum = type=="Int" || type=="Long"
+
+ val extends = if(isNum)" extends Number" else ""
+
+ fun recName() = type+"Record"
+ fun valType() =
+ if(isNum || type=="Boolean") type.toLowerCase()
+ else if(!isVar) type
+ else "E"
+
+
+ fun constParams() = if(!isVar) "" else "private final Serializer ser;"
+ fun newParams() = if(!isVar) "" else ", Serializer ser";
+ fun newParams2() = if(!isVar) "" else ", ser"
+ fun constBody() = if(!isVar) "" else "this.ser=ser;"
+ fun newGen() = if(!isVar) "" else ""
+
+
+
+ }
+
+ val types = listOf(
+ R("String", "\"\"", "Serializers.STRING"),
+ R("Long", "0L", "Serializers.LONG"),
+ R("Int", "0", "Serializers.INTEGER"),
+ R("Boolean","false", "Serializers.BOOLEAN"),
+ R("Var", "null","ser")
+ )
+
+ for(t in types){
+ val cont = """
+ package org.mapdb.record;
+
+ import org.mapdb.db.DB;
+ import org.mapdb.store.Store;
+ import org.mapdb.ser.Serializer;
+ import org.mapdb.ser.Serializers;
+
+ public class ${t.recName()}${t.gen} ${t.extends}{
+
+ public static class Maker${t.gen}{
+
+ private final DB db;
+ private final String name;
+
+ private ${t.valType()} initVal = ${t.initVal};
+
+ ${t.constParams()}
+ public Maker(DB db, String name ${t.newParams()}){
+ this.db = db;
+ this.name = name;
+ ${t.constBody()}
+ }
+
+
+ public Maker init(${t.valType()} initialValue){
+ initVal = initialValue;
+ return this;
+ }
+
+ public ${t.recName()} make(){
+ Store store = db.getStore();
+ long recid = store.put(initVal, ${if(t.isVar) "ser" else t.ser});
+ return new ${t.recName()}(store, recid ${t.newParams2()});
+ }
+
+ }
+
+
+
+ private final Store store;
+ private final long recid;
+ ${t.constParams()}
+
+ public ${t.recName()}(Store store, long recid ${t.newParams()}){
+ this.store = store;
+ this.recid = recid;
+ ${t.constBody()}
+ }
+
+ ${if(t.isNum)"""
+ public ${t.valType()} addAndGet(${t.valType()} i){
+ return store.updateAndGet(recid, ${t.ser}, (v)-> v+i);
+ }
+
+ public ${t.valType()} getAndAdd(${t.valType()} i){
+ return store.getAndUpdateAtomic(recid, ${t.ser}, (v)-> v+i);
+ }
+
+ public ${t.valType()} getAndDecrement(){return getAndAdd(-1);}
+
+ public ${t.valType()} getAndIncrement(){return getAndAdd(+1);}
+
+ public ${t.valType()} decrementAndGet(){return addAndGet(-1);}
+
+ public ${t.valType()} incrementAndGet(){return addAndGet(+1);}
+
+ @Override public double doubleValue(){ return (double) get();}
+ @Override public float floatValue(){ return (float) get();}
+ @Override public long longValue(){ return (long) get();}
+ @Override public int intValue(){ return (int) get();}
+// @Override public char charValue(){ return (char) get();}
+ @Override public short shortValue(){ return (short) get();}
+ @Override public byte byteValue(){ return (byte) get();}
+
+ """ else ""}
+
+ //TODO hash code
+
+ public ${t.valType()} get(){
+ return store.get(recid, ${t.ser});
+ }
+
+ public void set(${t.valType()} value){
+ store.update(recid, ${t.ser}, value);
+ }
+
+ public ${t.valType()} getAndSet(${t.valType()} value){
+ return store.getAndUpdate(recid, ${t.ser}, value);
+ }
+
+ public boolean compareAndSet(${t.valType()} expectedValue, ${t.valType()} newValue){
+ return store.compareAndUpdate(recid, ${t.ser}, expectedValue, newValue);
+ }
+
+ @Override
+ public String toString(){
+ return ""+get();
+ }
+
+ }
+
+ """.trimIndent()
+ FileUtils.write(File(dir, t.type+"Record.java"), cont);
+ }
+
+
+
+
+
+ }
+
+}
\ No newline at end of file
diff --git a/buildSrc/src/main/java/MDBCodeGen.kt b/buildSrc/src/main/java/MDBCodeGen.kt
new file mode 100644
index 000000000..3e5bffc3f
--- /dev/null
+++ b/buildSrc/src/main/java/MDBCodeGen.kt
@@ -0,0 +1,30 @@
+import org.gradle.internal.impldep.org.apache.commons.io.FileUtils
+import java.io.File
+
+class MDBCodeGen{
+ companion object {
+ @JvmStatic
+ fun main(args: Array) {
+
+ val srcGenDir = File("../srcGen/main/java")
+ val srcDir = File("../src/main/java")
+
+ val testGenDir = File("../srcGen/test/java")
+
+
+ FileUtils.write(File(srcGenDir, "AACodeGen.java"), """
+public class AACodeGen{
+}
+ """)
+
+ val srcDirRecords = File(srcGenDir, "org/mapdb/record/")
+ srcDirRecords.mkdirs()
+ GenRecords.makeRecordMakers(srcDirRecords)
+
+ GenMarkers.wlock(srcDir, srcGenDir);
+
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 000000000..5c2d1cf01
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 000000000..5028f28f8
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 000000000..b0d6d0ab5
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,188 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 000000000..9991c5032
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,100 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/logger.properties b/logger.properties
index ba279588e..fe1016720 100644
--- a/logger.properties
+++ b/logger.properties
@@ -21,7 +21,9 @@ handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler
# Here, the level for each package is specified.
# The global level is used by default, so levels
# specified here simply act as an override.
-myapp.ui.level=ALL
+org.mapdb.level=ALL
+
+#some other filtering options
myapp.business.level=CONFIG
myapp.data.level=SEVERE
diff --git a/notice.txt b/notice.txt
deleted file mode 100644
index a97c1fd79..000000000
--- a/notice.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-MapDB
-Copyright 2012-2014 Jan Kotek
-
-This product includes software developed by Thomas Mueller and H2 group
-Relicensed under Apache License 2 with Thomas permission.
-(CompressLZF.java and EncryptionXTEA.java)
-Copyright (c) 2004-2011 H2 Group
-
-
-This product includes software developed by Doug Lea and JSR 166 group:
-(LongConcurrentMap.java, Atomic.java)
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
-
-
-This product includes software developed for Apache Solr
-(LongConcurrentLRUMap.java)
-Copyright 2006-2014 The Apache Software Foundation
-
-This product includes software developed for Apache Harmony
-(LongHashMap.java)
-Copyright 2008-2012 The Apache Software Foundation
-
-
-This product includes software developed by Nathen Sweet for Kryo
-Relicensed under Apache License 2 (or later) with Nathans permission.
-(DataInput2.packInt/Long and DataOutput.unpackInt/Long methods)
-Copyright (c) 2012 Nathan Sweet
-
-This product includes software developed for Android project
-(SerializerPojo, a few lines to invoke constructor, see comments)
-//Copyright (C) 2012 The Android Open Source Project, licenced under Apache 2 license
-
-
-This product includes software developed by Heinz Kabutz for javaspecialists.eu
-(SerializerPojo, a few lines to invoke constructor, see comments)
-2010-2014 Heinz Kabutz
-
-
-Some Map unit tests are from Google Collections.
-Credit goes to Jared Levy, George van den Driessche and other Google Collections developers.
-Copyright (C) 2007 Google Inc.
-
-Luc Peuvrier wrote some unit tests for ConcurrerentNavigableMap interface.
-
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 75cbd2c4a..000000000
--- a/pom.xml
+++ /dev/null
@@ -1,187 +0,0 @@
-
-
- 4.0.0
-
- org.mapdb
- mapdb
- 2.0.0-SNAPSHOT
- mapdb
- MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap memory. It is a fast, scalable and easy to use embedded Java database.
- http://www.mapdb.org
-
- bundle
-
-
-
- The Apache Software License, Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0.txt
- repo
-
-
-
-
-
- Jan Kotek
- jan
-
-
-
-
- scm:git:git@github.com:jankotek/MapDB.git
- scm:git:git@github.com:jankotek/MapDB.git
- git@github.com:jankotek/MapDB.git
-
-
-
- UTF-8
-
-
-
-
- junit
- junit
- 4.11
- jar
- test
- false
-
-
-
-
-
-
- org.apache.felix
- maven-bundle-plugin
- 2.3.7
- true
-
-
- ${project.groupId}.${project.artifactId}
- ${project.name}
- ${project.version}
- *
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.0
-
- 1.6
- 1.6
- ${project.build.sourceEncoding}
-
-
-
- org.apache.maven.plugins
- maven-resources-plugin
- 2.5
-
- ${project.build.sourceEncoding}
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
- 2.1.2
-
-
- attach-sources
- package
-
- jar
- test-jar
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.16
-
-
-
- 3
-
-
- **/*
-
-
-
- AAAAAAAAAA
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- reports
-
-
-
- org.jacoco
- jacoco-maven-plugin
- 0.6.3.201306030806
-
-
-
- prepare-agent
- report
-
-
-
-
-
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-project-info-reports-plugin
- 2.7
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 2.9
-
-
- html
-
- javadoc
-
-
-
-
-
-
-
-
-
-
-
-
- org.sonatype.oss
- oss-parent
- 7
-
-
-
diff --git a/src/assembly/bin-component.xml b/src/assembly/bin-component.xml
new file mode 100644
index 000000000..f51ed3371
--- /dev/null
+++ b/src/assembly/bin-component.xml
@@ -0,0 +1,20 @@
+
+
+
+ lib
+ false
+ runtime
+
+
+
+
+
diff --git a/src/assembly/bin.xml b/src/assembly/bin.xml
new file mode 100644
index 000000000..869fc852c
--- /dev/null
+++ b/src/assembly/bin.xml
@@ -0,0 +1,22 @@
+
+ bin
+
+ zip
+
+
+ src/assembly/bin-component.xml
+
+
+
diff --git a/src/main/java/org/mapdb/AsyncWriteEngine.java b/src/main/java/org/mapdb/AsyncWriteEngine.java
deleted file mode 100644
index a11180e78..000000000
--- a/src/main/java/org/mapdb/AsyncWriteEngine.java
+++ /dev/null
@@ -1,576 +0,0 @@
-/*
- * Copyright (c) 2012 Jan Kotek
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.mapdb;
-
-import java.lang.ref.WeakReference;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Executor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.locks.LockSupport;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Level;
-
-/**
- * {@link Engine} wrapper which provides asynchronous serialization and asynchronous write.
- * This class takes an object instance, passes it to background writer thread (using Write Queue)
- * where it is serialized and written to disk. Async write does not affect commit durability,
- * Write Queue is flushed into disk on each commit. Modified records are held in small instance cache,
- * until they are written into disk.
- *
- * This feature is disabled by default and can be enabled by calling {@link DBMaker#asyncWriteEnable()}.
- * Write Cache is flushed in regular intervals or when it becomes full. Flush interval is 100 ms by default and
- * can be controlled by {@link DBMaker#asyncWriteFlushDelay(int)}. Increasing this interval may improve performance
- * in scenarios where frequently modified items should be cached, typically {@link BTreeMap} import where keys
- * are presorted.
- *
- * Asynchronous write does not affect commit durability. Write Queue is flushed during each commit, rollback and close call.
- * Those method also block until all records are written.
- * You may flush Write Queue manually by using {@link org.mapdb.AsyncWriteEngine#clearCache()} method.
- * There is global lock which prevents record being updated while commit is in progress.
- *
- * This wrapper starts one threads named {@code MapDB writer #N} (where N is static counter).
- * Async Writer takes modified records from Write Queue and writes them into store.
- * It also preallocates new recids, as finding empty {@code recids} takes time so small stash is pre-allocated.
- * It runs as {@code daemon}, so it does not prevent JVM to exit.
- *
- * Asynchronous Writes have several advantages (especially for single threaded user). But there are two things
- * user should be aware of:
- *
- * * Because data are serialized on back-ground thread, they need to be thread safe or better immutable.
- * When you insert record into MapDB and modify it latter, this modification may happen before item
- * was serialized and you may not be sure what version was persisted
- *
- * * Inter-thread communication has some overhead.
- * There is also only single Writer Thread, which may create single bottle-neck.
- * This usually not issue for
- * single or two threads, but in multi-threaded environment it may decrease performance.
- * So in truly concurrent environments with many updates (network servers, parallel computing )
- * you should keep Asynchronous Writes disabled.
- *
- *
- * @see Engine
- * @see EngineWrapper
- *
- * @author Jan Kotek
- *
- *
- *
- */
-public class AsyncWriteEngine extends EngineWrapper implements Engine {
-
- /** ensures thread name is followed by number */
- protected static final AtomicLong threadCounter = new AtomicLong();
-
-
- /** used to signal that object was deleted*/
- protected static final Object TOMBSTONE = new Object();
-
-
- protected final int maxSize;
-
- protected final AtomicInteger size = new AtomicInteger();
-
-// protected final long[] newRecids = new long[CC.ASYNC_RECID_PREALLOC_QUEUE_SIZE];
-// protected int newRecidsPos = 0;
-// protected final ReentrantLock newRecidsLock = new ReentrantLock(CC.FAIR_LOCKS);
-
-
- /** Associates {@code recid} from Write Queue with record data and serializer. */
- protected final LongConcurrentHashMap> writeCache
- = new LongConcurrentHashMap>();
-
- /** Each insert to Write Queue must hold read lock.
- * Commit, rollback and close operations must hold write lock
- */
- protected final ReentrantReadWriteLock commitLock = new ReentrantReadWriteLock(CC.FAIR_LOCKS);
-
- /** number of active threads running, used to await thread termination on close */
- protected final CountDownLatch activeThreadsCount = new CountDownLatch(1);
-
- /** If background thread fails with exception, it is stored here, and rethrown to all callers.*/
- protected volatile Throwable threadFailedException = null;
-
- /** indicates that {@code close()} was called and background threads are being terminated*/
- protected volatile boolean closeInProgress = false;
-
- /** flush Write Queue every N milliseconds */
- protected final int asyncFlushDelay;
-
- protected final AtomicReference action = new AtomicReference(null);
-
-
-
- /**
- * Construct new class and starts background threads.
- * User may provide executor in which background tasks will be executed,
- * otherwise MapDB starts two daemon threads.
- *
- * @param engine which stores data.
- * @param _asyncFlushDelay flush Write Queue every N milliseconds
- * @param executor optional executor to run tasks. If null daemon threads will be created
- */
- public AsyncWriteEngine(Engine engine, int _asyncFlushDelay, int queueSize, Executor executor) {
- super(engine);
- this.asyncFlushDelay = _asyncFlushDelay;
- this.maxSize = queueSize;
- startThreads(executor);
- }
-
- public AsyncWriteEngine(Engine engine) {
- this(engine, CC.ASYNC_WRITE_FLUSH_DELAY, CC.ASYNC_WRITE_QUEUE_SIZE, null);
- }
-
-
- protected static final class WriterRunnable implements Runnable{
-
- protected final WeakReference engineRef;
- protected final long asyncFlushDelay;
- protected final AtomicInteger size;
- protected final int maxParkSize;
- private final ReentrantReadWriteLock commitLock;
-
-
- public WriterRunnable(AsyncWriteEngine engine) {
- this.engineRef = new WeakReference(engine);
- this.asyncFlushDelay = engine.asyncFlushDelay;
- this.commitLock = engine.commitLock;
- this.size = engine.size;
- this.maxParkSize = engine.maxSize/4;
- }
-
- @Override public void run() {
- try{
- //run in loop
- for(;;){
-
- //$DELAY$
- //if conditions are right, slow down writes a bit
- if(asyncFlushDelay!=0 && !commitLock.isWriteLocked() && size.get()> iter = writeCache.longMapIterator();
- while(iter.moveToNext()){
- //$DELAY$
- //usual write
- final long recid = iter.key();
- Fun.Pair