Skip to content

Commit

Permalink
fixed #211 & 3.4.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
anidotnet committed Mar 24, 2020
1 parent a3582fd commit 7860325
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ deploy:

env:
global:
- NITRITE_VERSION=3.4.0-SNAPSHOT
- NITRITE_VERSION=3.4.0
- PGP_KEY_FILE=~/secring.gpg
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
org.gradle.jvmargs=-Xmx1024m

# artifact version
nitriteVersion=3.4.0-SNAPSHOT
nitriteVersion=3.4.0

# nitrite dependency
asciidoctorVersion=1.5.6
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion nitrite/src/docs/asciidoc/features.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
* Embedded key-value/document and object store
* In-memory off-heap store
* In-memory (on/off)-heap store
* Single file store
* Very fast and lightweight MongoDB like API
* Indexing
Expand Down
4 changes: 2 additions & 2 deletions nitrite/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= Nitrite
Anindya Chatterjee <anindya@dizitart.com>
v3.3.0, {docdate} {doctime}
v3.4.0, {docdate} {doctime}
:description: Nitrite database is an open source Nosql embedded persistent document store written in Java. It has MongoDB like API. It supports both in-memory and single file based persistent store powered by MVStore engine of h2 database. Nitrite can be used in desktop as well as mobile applications like android.
:keywords: nitrite, nosql, embedded, embedded document store, android, android nosql database, java, key value store, document store, object store, persistent store, index, indexing, fulltext search, embedded mongo,
:page-layout: docs
Expand All @@ -12,7 +12,7 @@ v3.3.0, {docdate} {doctime}
:toclevels: 4
:title-logo-image: image:images/nitrite-logo.svg[pdfwidth=4.25in,align=center]
:homepage: http://nitrite.dizitart.org
:version: 3.3.0
:version: 3.4.0
:source-highlighter: pygments
:pygments-style: tango
:linkattrs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@ based database. If the file exists, builder will try to open the existing databa
NOTE: If the existing database file is corrupted, while opening, nitrite will try to recover
from it by restoring the last known good version.

.Create an in-memory database
[source,java]
--
Nitrite db = Nitrite.builder()
.openOrCreate();
--

.Create an in-memory database with off-heap storage
[source,java]
--
Nitrite db = Nitrite.builder()
.enableOffHeapStorage()
.openOrCreate();
--

Expand Down
15 changes: 13 additions & 2 deletions nitrite/src/main/java/org/dizitart/no2/NitriteBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public class NitriteBuilder {
private boolean autoCommit = true;
private boolean autoCompact = true;
private boolean shutdownHook = true;
private boolean offHeapStorage = false;
private TextIndexingService textIndexingService;
private TextTokenizer textTokenizer;
private NitriteMapper nitriteMapper;
Expand Down Expand Up @@ -332,6 +333,17 @@ public NitriteBuilder registerModule(Module module) {
return this;
}


/**
* Enables off-heap storage for in-memory database.
*
* @return the {@link NitriteBuilder} instance.
* */
public NitriteBuilder enableOffHeapStorage() {
this.offHeapStorage = true;
return this;
}

/**
* Opens or creates a new database. If it is an in-memory store, then it
* will create a new one. If it is a file based store, and if the file does not
Expand Down Expand Up @@ -429,8 +441,7 @@ private Nitrite openOrCreateInternal(String userId, String password) {
builder = builder.autoCommitDisabled();
}

if (isNullOrEmpty(filePath)) {
// for in memory store use off heap storage
if (isNullOrEmpty(filePath) && offHeapStorage) {
builder = builder.fileStore(new OffHeapStore());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void testConfig() throws IOException {
builder.filePath(filePath);
builder.textIndexingService(textIndexingService);
builder.textTokenizer(textTokenizer);
builder.enableOffHeapStorage();

Nitrite db = builder.openOrCreate();
NitriteContext context = db.getContext();
Expand Down

0 comments on commit 7860325

Please sign in to comment.