Skip to content

Commit

Permalink
Merge pull request #23 from dizitart/master
Browse files Browse the repository at this point in the history
Create release 2.0.0
  • Loading branch information
anidotnet authored Aug 13, 2017
2 parents 14eba9c + 8e75ed1 commit 3082c17
Show file tree
Hide file tree
Showing 55 changed files with 784 additions and 133 deletions.
4 changes: 2 additions & 2 deletions .ci/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

if [[ -z "${TRAVIS_TAG}" ]]; then
./gradlew build run asciidoc -Dscan -PnitriteVersion=$NITRITE_VERSION
./gradlew clean build run asciidoc -Dscan -PnitriteVersion=$NITRITE_VERSION --stacktrace --info
else
openssl aes-256-cbc -pass pass:$PGP_KEY_PASSWORD -in .ci/secring.gpg.enc -out ~/secring.gpg -d
./gradlew build run asciidoc -Prelease -PnitriteVersion=$NITRITE_VERSION -Psigning.keyId=$PGP_KEY_ID -Psigning.password=$PGP_KEY_PASSWORD -Psigning.secretKeyRingFile=$PGP_KEY_FILE uploadArchives closeAndReleaseRepository :nitrite-explorer:shadowJar -Dscan
./gradlew clean build run asciidoc -Prelease -PnitriteVersion=$NITRITE_VERSION -Psigning.keyId=$PGP_KEY_ID -Psigning.password=$PGP_KEY_PASSWORD -Psigning.secretKeyRingFile=$PGP_KEY_FILE uploadArchives closeAndReleaseRepository :nitrite-explorer:shadowJar -Dscan --stacktrace --info
fi
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ deploy:

env:
global:
- NITRITE_VERSION=1.0.1
- NITRITE_VERSION=2.0.0
- PGP_KEY_FILE=~/secring.gpg
8 changes: 8 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
= Nitrite Database

image:https://cdn.rawgit.com/gratipay/gratipay-badge/2.3.0/dist/gratipay.svg["Support via Gratipay", link="https://gratipay.com/Nitrite/"]
image:https://travis-ci.org/dizitart/nitrite-database.svg?branch=master["Build Status", link="https://travis-ci.org/dizitart/nitrite-database"]
image:https://codecov.io/gh/dizitart/nitrite-database/branch/master/graph/badge.svg["Coverage Status", link="https://codecov.io/gh/dizitart/nitrite-database"]
image:https://javadoc.io/badge/org.dizitart/nitrite.svg["Javadocs", link=https://javadoc.io/doc/org.dizitart/nitrite]
Expand Down Expand Up @@ -57,10 +58,17 @@ compile 'org.dizitart:nitrite:{version}'
*Initialize Database*
[source,java]
--
//java initialization
Nitrite db = Nitrite.builder()
.compressed()
.filePath("/tmp/test.db")
.openOrCreate("user", "password");

//android initialization
Nitrite db = Nitrite.builder()
.compressed()
.filePath(getFilesDir().getPath() + "/test.db")
.openOrCreate("user", "password");
--

*Create a Collection*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@

package org.dizitart.no2.sample.android;

import org.dizitart.no2.Document;
import org.dizitart.no2.mapper.Mappable;
import org.dizitart.no2.mapper.NitriteMapper;

/**
* @author Anindya Chatterjee.
*/
public class User {
public class User implements Mappable {
private String id;
private String username;
private String email;
Expand Down Expand Up @@ -56,4 +60,20 @@ public String getEmail() {
public void setEmail(String email) {
this.email = email;
}

@Override
public Document write(NitriteMapper mapper) {
Document document = new Document();
document.put("id", id);
document.put("username", username);
document.put("email", email);
return document;
}

@Override
public void read(NitriteMapper mapper, Document document) {
id = (String) document.get("id");
username = (String) document.get("username");
email = (String) document.get("email");
}
}
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
org.gradle.jvmargs=-Xmx1024m

# artifact version
nitriteVersion=1.0.1
nitriteVersion=2.0.0

# nitrite dependency
asciidoctorVersion=1.5.4
Expand All @@ -33,8 +33,8 @@ dockerClientVersion=3.5.12
dockerPluginVersion=1.2
errorProneVersion=2.0.17
errorPronePluginVersion=0.0.8
h2Version=1.4.193
jacksonVersion=2.8.5
h2Version=1.4.196
jacksonVersion=2.8.9
jasyptVersion=1.9.2
javafxPluginVersion=8.7.0
jodaTimeVersion=2.9.7
Expand All @@ -47,12 +47,12 @@ luceneVersion=4.9.0
meanbeanVersion=2.0.3
mongoDriverVersion=3.4.2
nexusStagingPlugin=0.8.0
objenesisVersion=2.4
objenesisVersion=2.6
okhttpVersion=3.6.0
orientdbVersion=2.2.10
propDepsPluginVersion=0.0.7
shadowPluginVersion=1.2.4
slf4jVersion=1.7.21
springBootVersion=1.5.1.RELEASE
springBootVersion=1.5.4.RELEASE
springBootAdminVersion=1.4.3
swaggerVersion=2.6.0
1 change: 1 addition & 0 deletions nitrite/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dependencies {
testCompile "joda-time:joda-time:$jodaTimeVersion"
testCompile "com.squareup.okhttp3:mockwebserver:$okhttpVersion"
testCompile "org.meanbean:meanbean:$meanbeanVersion"

}

gradle.buildFinished { BuildResult result ->
Expand Down
54 changes: 54 additions & 0 deletions nitrite/src/docs/asciidoc/collections/mappable.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
NitriteMapper relies on third-party serialization libraries for Document
serialization. Those libraries heavily depend on reflection, but
reflection has its toll. In environment like Android use of reflection
degrades the performance drastically. To bypass this overhead, Nitrite
provides a mechanism called Mappable
icon:file-code-o[link="http://static.javadoc.io/org.dizitart/nitrite/{version}/org/dizitart/no2/mapper/Mappable.html", window="_blank"]
interface.
If an object is `Mappable`, Nitrite will use the implementation
to convert the object to a Document and vice versa thus bypass the reflection
overhead.
[source,java]
.Example for Mappable
--
public class Employee implements Mappable {
private String empId;
private String name;
private Date joiningDate;
private Employee boss;
@Override
public Document write(NitriteMapper mapper) {
Document document = new Document();
document.put("empId", getEmpId());
document.put("name", getName());
document.put("joiningDate", getJoiningDate());
if (getBoss() != null) {
Document bossDoc = getBoss().write(mapper);
document.put("boss", bossDoc);
}
return document;
}
@Override
public void read(NitriteMapper mapper, Document document) {
if (document != null) {
setEmpId((String) document.get("empId"));
setName((String) document.get("name"));
setJoiningDate((Date) document.get("joiningDate"));
Document bossDoc = (Document) document.get("boss");
if (bossDoc != null) {
Employee bossEmp = new Employee();
bossEmp.read(mapper, bossDoc);
setBoss(bossEmp);
}
}
}
}
--
2 changes: 1 addition & 1 deletion nitrite/src/docs/asciidoc/collections/nitrite-mapper.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ The default NitriteMapper:
* does not allow circular reference (will throw ObjectMappingException)
* needs POJO classes to have a public parameter-less constructor
* ignores fields declared as `transient`
* honors fields declared as `transient`
29 changes: 0 additions & 29 deletions nitrite/src/docs/asciidoc/examples/nitrite.adoc

This file was deleted.

7 changes: 7 additions & 0 deletions nitrite/src/docs/asciidoc/getting-started/quick-example.adoc
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
[source,java]
.Initialize Database
--
// java initialization
Nitrite db = Nitrite.builder()
.compressed()
.filePath("/tmp/test.db")
.openOrCreate("user", "password");

// android initialization
Nitrite db = Nitrite.builder()
.compressed()
.filePath(getFilesDir().getPath() + "/test.db")
.openOrCreate("user", "password");
--

For more options on opening a database visit <<index.adoc#create-open-database,here>>.
Expand Down
12 changes: 10 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>
v1.0, {docdate} {doctime}
v2.0.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 @@ v1.0, {docdate} {doctime}
:toclevels: 4
:title-logo-image: image:images/nitrite-logo.svg[pdfwidth=4.25in,align=center]
:homepage: http://nitrite.dizitart.org
:version: 1.0
:version: 2.0.0
:source-highlighter: pygments
:pygments-style: tango
:linkattrs:
Expand Down Expand Up @@ -108,6 +108,10 @@ include::collections/annotations.adoc[]

include::collections/nitrite-mapper.adoc[]

==== Mappable

include::collections/mappable.adoc[]

=== Operations

include::collections/operations.adoc[]
Expand Down Expand Up @@ -172,6 +176,10 @@ include::filter-examples.adoc[]

include::replication.adoc[]

=== Security

include::replication/security.adoc[]

=== SyncHandle

include::replication/synchandle.adoc[]
Expand Down
16 changes: 16 additions & 0 deletions nitrite/src/docs/asciidoc/replication/security.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Replication is a secured operation. There are two sets of credentials needed to
successfully perform replication.

1. The client credential
2. The user credential
Client credential is required to create user credentials in the DataGate server.
The user credential is required to perform several operations during the replication
life cycle. Once a user credential is created it can be used for replication.

A client credential can be created using the DataGate portal. Once it is created,
an app can use that client credential to create further users. Those users will take
part in the replication.

NOTE: The user credential has *USER* authority and a client credential has *CLIENT*
authority.
7 changes: 4 additions & 3 deletions nitrite/src/main/java/org/dizitart/no2/NitriteBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import org.dizitart.no2.fulltext.EnglishTextTokenizer;
import org.dizitart.no2.fulltext.TextIndexingService;
import org.dizitart.no2.fulltext.TextTokenizer;
import org.dizitart.no2.internals.NitriteMapper;
import org.dizitart.no2.mapper.JacksonMapper;
import org.dizitart.no2.mapper.NitriteMapper;
import org.dizitart.no2.store.NitriteMVStore;
import org.dizitart.no2.store.NitriteStore;
import org.dizitart.no2.util.StringUtils;
Expand Down Expand Up @@ -271,12 +272,12 @@ public NitriteBuilder textTokenizer(TextTokenizer textTokenizer) {

/**
* Sets a custom {@link NitriteMapper} implementation. If not set, a default
* jackson based mapper {@link org.dizitart.no2.internals.JacksonMapper} will
* jackson based mapper {@link JacksonMapper} will
* be used.
*
* @param nitriteMapper a {@link NitriteMapper} implementation
* @return the {@link NitriteBuilder} instance.
* @see org.dizitart.no2.internals.JacksonMapper
* @see JacksonMapper
* */
public NitriteBuilder nitriteMapper(NitriteMapper nitriteMapper) {
this.nitriteMapper = nitriteMapper;
Expand Down
4 changes: 2 additions & 2 deletions nitrite/src/main/java/org/dizitart/no2/NitriteContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import lombok.Setter;
import org.dizitart.no2.fulltext.TextIndexingService;
import org.dizitart.no2.fulltext.TextTokenizer;
import org.dizitart.no2.internals.JacksonMapper;
import org.dizitart.no2.internals.NitriteMapper;
import org.dizitart.no2.mapper.JacksonMapper;
import org.dizitart.no2.mapper.NitriteMapper;
import org.dizitart.no2.util.ExecutorUtils;

import java.util.List;
Expand Down
26 changes: 11 additions & 15 deletions nitrite/src/main/java/org/dizitart/no2/exceptions/ErrorCodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,17 @@ public class ErrorCodes {
public static final int VE_OBJ_CREATE_INDEX_NULL_FIELD = 1069;
public static final int VE_OBJ_UPDATE_NULL_OBJECT = 1070;
public static final int VE_OBJ_UPDATE_NULL_UPDATE_OPTIONS = 1071;
public static final int VE_OBJ_FIND_WITH_OPTIONS_NULL_FILTER = 1072;
public static final int VE_FIND_NULL_FILTER = 1073;
public static final int VE_FIND_FILTERED_NULL_FILTER = 1074;
public static final int VE_OBJ_UPDATE_NULL_DOCUMENT = 1075;
public static final int VE_OBJ_FIND_NULL_FILTER = 1076;
public static final int VE_NC_REBUILD_INDEX_NULL_INDEX = 1077;
public static final int VE_OBJ_INVALID_EMBEDDED_FIELD = 1078;
public static final int VE_OBJ_INVALID_FIELD = 1079;
public static final int VE_BIG_DECIMAL_INVALID_FORMAT = 1080;
public static final int VE_INVALID_EMBEDDED_FIELD = 1081;
public static final int VE_NEGATIVE_LIST_INDEX_FIELD = 1082;
public static final int VE_INVALID_LIST_INDEX_FIELD = 1083;
public static final int VE_NEGATIVE_ARRAY_INDEX_FIELD = 1084;
public static final int VE_INVALID_ARRAY_INDEX_FIELD = 1085;
public static final int VE_INVALID_REMAINING_FIELD = 1086;
public static final int VE_OBJ_UPDATE_NULL_DOCUMENT = 1072;
public static final int VE_NC_REBUILD_INDEX_NULL_INDEX = 1073;
public static final int VE_OBJ_INVALID_EMBEDDED_FIELD = 1074;
public static final int VE_OBJ_INVALID_FIELD = 1075;
public static final int VE_BIG_DECIMAL_INVALID_FORMAT = 1076;
public static final int VE_INVALID_EMBEDDED_FIELD = 1077;
public static final int VE_NEGATIVE_LIST_INDEX_FIELD = 1078;
public static final int VE_INVALID_LIST_INDEX_FIELD = 1079;
public static final int VE_NEGATIVE_ARRAY_INDEX_FIELD = 1080;
public static final int VE_INVALID_ARRAY_INDEX_FIELD = 1081;
public static final int VE_INVALID_REMAINING_FIELD = 1082;

/* NitriteIOException Codes */
public static final int NIOE_DATABASE_OPENED = 2001;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import static org.dizitart.no2.exceptions.ErrorCodes.IE_TEXT_FILTER_FIELD_NOT_INDEXED;
import static org.dizitart.no2.exceptions.ErrorMessage.errorMessage;
import static org.dizitart.no2.util.StringUtils.isNullOrEmpty;

@ToString
class TextFilter extends StringFilter {
Expand All @@ -37,8 +36,7 @@ class TextFilter extends StringFilter {
@Override
public Set<NitriteId> apply(NitriteMap<NitriteId, Document> documentMap) {
if (nitriteService.hasIndex(field)
&& !nitriteService.isIndexing(field)
&& !isNullOrEmpty(value)) {
&& !nitriteService.isIndexing(field)) {
return nitriteService.findTextWithIndex(field, value);
} else {
throw new IndexingException(errorMessage(field + " is not indexed",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.dizitart.no2.*;
import org.dizitart.no2.event.*;
import org.dizitart.no2.exceptions.UniqueConstraintException;
import org.dizitart.no2.mapper.NitriteMapper;
import org.dizitart.no2.store.NitriteMap;

import java.util.ArrayList;
Expand Down
Loading

0 comments on commit 3082c17

Please sign in to comment.