Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
anidotnet committed Feb 19, 2024
2 parents 77c8d4c + 7813092 commit 9ec3307
Show file tree
Hide file tree
Showing 30 changed files with 390 additions and 79 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ jobs:
java: ['11', '17']
env:
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
MAVEN_USERNAME: ${{ secrets.OSSRH_USER }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
PGP_KEY_ID: ${{ secrets.PGP_KEY_ID }}
PGP_KEY_PASSWORD: ${{ secrets.PGP_KEY_PASSWORD }}

name: Build with Java ${{ matrix.java }} in Ubuntu
steps:
Expand All @@ -40,16 +36,13 @@ jobs:
java-package: jdk
architecture: x64
cache: 'maven'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD

- name: Build with Maven
run: mvn -B -ff -ntp clean install -Dgpg.skip=true -DskipTests
run: mvn -B -ff -ntp clean install -Dgpg.skip=true

- name: Publish Code Coverage
if: github.ref == 'refs/heads/main' && matrix.java == '11'
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
Expand All @@ -76,7 +69,7 @@ jobs:
cache: 'maven'

- name: Build with Maven
run: mvn -B -ff -ntp clean install -Dgpg.skip=true -DskipTests
run: mvn -B -ff -ntp clean install -Dgpg.skip=true

build_windows:
runs-on: windows-latest
Expand All @@ -99,4 +92,4 @@ jobs:
cache: 'maven'

- name: Build with Maven
run: mvn -B -ff -ntp clean install --% -Dgpg.skip=true -DskipTests
run: mvn -B -ff -ntp clean install --% -Dgpg.skip=true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build](https://github.com/nitrite/nitrite-java/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/nitrite/nitrite-java/actions/workflows/build.yml)
[![CodeQL](https://github.com/nitrite/nitrite-java/actions/workflows/codeql-analysis.yml/badge.svg?branch=main)](https://github.com/nitrite/nitrite-java/actions/workflows/codeql-analysis.yml)
[![codecov](https://codecov.io/gh/nitrite/nitrite-java/branch/main/graph/badge.svg)](https://codecov.io/gh/nitrite/nitrite-java)
![Javadocs](https://javadoc.io/badge/org.dizitart/nitrite.svg)
[![javadoc](https://javadoc.io/badge2/org.dizitart/nitrite/javadoc.svg)](https://javadoc.io/doc/org.dizitart/nitrite)
[![Discussion](https://img.shields.io/badge/chat-Discussion-blueviolet)](https://github.com/orgs/nitrite/discussions)

<p align="center">
Expand Down
2 changes: 1 addition & 1 deletion nitrite-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.dizitart</groupId>
<artifactId>nitrite-java</artifactId>
<version>4.2.0</version>
<version>4.2.1-SNAPSHOT</version>
</parent>

<artifactId>nitrite-bom</artifactId>
Expand Down
9 changes: 7 additions & 2 deletions nitrite-jackson-mapper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.dizitart</groupId>
<artifactId>nitrite-java</artifactId>
<version>4.2.0</version>
<version>4.2.1-SNAPSHOT</version>
</parent>

<artifactId>nitrite-jackson-mapper</artifactId>
Expand Down Expand Up @@ -70,7 +70,12 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<artifactId>log4j-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
6 changes: 3 additions & 3 deletions nitrite-jackson-mapper/src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
~ limitations under the License.
-->

<Configuration status="ERROR" name="nitrite" monitorInterval="5">
<Configuration status="OFF" name="nitrite" monitorInterval="5">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d %p %c{1.} [%t] %m%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="ERROR">
<Root level="OFF">
<AppenderRef ref="Console"/>
</Root>
<Logger name="org.dizitart" level="ERROR" additivity="false">
<Logger name="org.dizitart" level="OFF" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
</Loggers>
Expand Down
9 changes: 7 additions & 2 deletions nitrite-mvstore-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.dizitart</groupId>
<artifactId>nitrite-java</artifactId>
<version>4.2.0</version>
<version>4.2.1-SNAPSHOT</version>
</parent>

<artifactId>nitrite-mvstore-adapter</artifactId>
Expand Down Expand Up @@ -70,7 +70,12 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<artifactId>log4j-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,45 @@ public void run() {
db.close();
}

@Test
public void testReadOnlyMode() {
NitriteCollection nitriteCollection = db.getCollection("readonly-test");
nitriteCollection.insert(createDocument("a", "b"));
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.UNIQUE), "a");

ObjectRepository<Receipt> repository = db.getRepository(Receipt.class);
Receipt receipt = new Receipt();
receipt.clientRef = "111-11111";
receipt.status = Receipt.Status.PREPARING;
repository.insert(receipt);

db.close();

MVStoreModule storeModule = MVStoreModule.withConfig()
.filePath(fileName)
.readOnly(true)
.build();

db = Nitrite.builder()
.loadModule(storeModule)
.registerEntityConverter(new Receipt.Converter())
.openOrCreate("test-user", "test-password");

assertFalse(db.hasUnsavedChanges());

nitriteCollection = db.getCollection("readonly-test");
assertEquals(nitriteCollection.find().size(), 1);
assertTrue(nitriteCollection.hasIndex("a"));

repository = db.getRepository(Receipt.class);
assertEquals(repository.find().size(), 1);
assertTrue(repository.hasIndex("synced"));

assertFalse(db.hasUnsavedChanges());
db.close();
deleteDb(fileName);
}

@Data
@AllArgsConstructor
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import jakarta.xml.bind.annotation.XmlSchemaType;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.StopWatch;
import org.dizitart.no2.Nitrite;
import org.dizitart.no2.collection.Document;
import org.dizitart.no2.collection.DocumentCursor;
Expand All @@ -35,18 +36,18 @@
import org.dizitart.no2.repository.annotations.Id;
import org.dizitart.no2.repository.annotations.Index;
import org.dizitart.no2.repository.annotations.Indices;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.*;
import uk.co.jemos.podam.api.PodamFactory;
import uk.co.jemos.podam.api.PodamFactoryImpl;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;

import static org.dizitart.no2.collection.UpdateOptions.updateOptions;
import static org.dizitart.no2.filters.FluentFilter.where;
import static org.dizitart.no2.integration.TestUtil.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
Expand Down Expand Up @@ -109,6 +110,57 @@ public void stressTest() {
assertEquals(counter, size);
}

@Test
@Ignore
public void testIssue902() {
NitriteCollection nitriteCollection = db.getCollection("testIssue902");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "name");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "age");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "address");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "email");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "phone");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "dateOfBirth");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "company");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "balance");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "isActive");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.UNIQUE), "guid");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "index");

for (int i = 0; i < 10; i++) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
for (int j = 0; j < 30000; j++) {
Document document = Document.createDocument();
document.put("name", "name" + j);
document.put("age", j);
document.put("address", "address" + j);
document.put("email", "email" + j);
document.put("phone", "phone" + j);
document.put("dateOfBirth", "dateOfBirth" + j);
document.put("company", "company" + j);
document.put("balance", j);
document.put("isActive", true);
document.put("guid", UUID.randomUUID().toString());
document.put("index", j);
nitriteCollection.insert(document);
}
stopWatch.stop();
log.error("Time taken to insert 30000 records: " + stopWatch.getTime());
}

if (db.hasUnsavedChanges()) {
db.commit();
}

Document updatedDocument = Document.createDocument("unrelatedField", "unrelatedValue");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
nitriteCollection.update(where("balance").eq(200000), updatedDocument, updateOptions(false));
stopWatch.stop();

log.error("Time taken to update 1 record: " + stopWatch.getTime());
}

@Test
public void testIssue41() {
collection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "number");
Expand Down
6 changes: 3 additions & 3 deletions nitrite-mvstore-adapter/src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
~ limitations under the License.
-->

<Configuration status="ERROR" name="nitrite" monitorInterval="5">
<Configuration status="OFF" name="nitrite" monitorInterval="5">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d %p %c{1.} [%t] %m%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="ERROR">
<Root level="OFF">
<AppenderRef ref="Console"/>
</Root>
<Logger name="org.dizitart" level="ERROR" additivity="false">
<Logger name="org.dizitart" level="OFF" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
</Loggers>
Expand Down
9 changes: 7 additions & 2 deletions nitrite-rocksdb-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.dizitart</groupId>
<artifactId>nitrite-java</artifactId>
<version>4.2.0</version>
<version>4.2.1-SNAPSHOT</version>
</parent>

<artifactId>nitrite-rocksdb-adapter</artifactId>
Expand Down Expand Up @@ -74,7 +74,12 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<artifactId>log4j-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import jakarta.xml.bind.annotation.XmlSchemaType;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.StopWatch;
import org.dizitart.no2.Nitrite;
import org.dizitart.no2.collection.Document;
import org.dizitart.no2.collection.DocumentCursor;
Expand All @@ -35,18 +36,18 @@
import org.dizitart.no2.repository.annotations.Id;
import org.dizitart.no2.repository.annotations.Index;
import org.dizitart.no2.repository.annotations.Indices;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.*;
import uk.co.jemos.podam.api.PodamFactory;
import uk.co.jemos.podam.api.PodamFactoryImpl;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;

import static org.dizitart.no2.collection.UpdateOptions.updateOptions;
import static org.dizitart.no2.filters.FluentFilter.where;
import static org.dizitart.no2.integration.TestUtil.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
Expand Down Expand Up @@ -108,6 +109,57 @@ public void stressTest() {
assertEquals(counter, size);
}

@Test
@Ignore
public void testIssue902() {
NitriteCollection nitriteCollection = db.getCollection("testIssue902");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "name");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "age");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "address");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "email");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "phone");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "dateOfBirth");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "company");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "balance");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "isActive");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.UNIQUE), "guid");
nitriteCollection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "index");

for (int i = 0; i < 10; i++) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
for (int j = 0; j < 3000; j++) {
Document document = Document.createDocument();
document.put("name", "name" + j);
document.put("age", j);
document.put("address", "address" + j);
document.put("email", "email" + j);
document.put("phone", "phone" + j);
document.put("dateOfBirth", "dateOfBirth" + j);
document.put("company", "company" + j);
document.put("balance", j);
document.put("isActive", true);
document.put("guid", UUID.randomUUID().toString());
document.put("index", j);
nitriteCollection.insert(document);
}
stopWatch.stop();
log.error("Time taken to insert 30000 records: " + stopWatch.getTime());
}

if (db.hasUnsavedChanges()) {
db.commit();
}

Document updatedDocument = Document.createDocument("unrelatedField", "unrelatedValue");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
nitriteCollection.update(where("balance").eq(200000), updatedDocument, updateOptions(false));
stopWatch.stop();

log.error("Time taken to update 1 record: " + stopWatch.getTime());
}

@Test
public void testIssue41() {
collection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "number");
Expand Down
Loading

0 comments on commit 9ec3307

Please sign in to comment.