Skip to content

Commit

Permalink
Add Xodus key/value database.
Browse files Browse the repository at this point in the history
  • Loading branch information
archiecobbs committed Apr 16, 2018
1 parent b59f296 commit 3093ecb
Show file tree
Hide file tree
Showing 14 changed files with 1,210 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -2,6 +2,7 @@ Version 4.1.0

- Added console support for configuring a required password
- Updated a bunch of dependencies
- Added Xodus key/value database

Version 4.0.3 Released January 20, 2018

Expand Down
8 changes: 8 additions & 0 deletions permazen-demo/pom.xml
Expand Up @@ -60,6 +60,10 @@
<groupId>${project.groupId}</groupId>
<artifactId>${project.parent.artifactId}-kv-leveldb</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${project.parent.artifactId}-kv-mssql</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${project.parent.artifactId}-kv-mysql</artifactId>
Expand All @@ -84,6 +88,10 @@
<groupId>${project.groupId}</groupId>
<artifactId>${project.parent.artifactId}-kv-sqlite</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${project.parent.artifactId}-kv-xodus</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${project.parent.artifactId}-util</artifactId>
Expand Down
57 changes: 57 additions & 0 deletions permazen-kv-xodus/pom.xml
@@ -0,0 +1,57 @@
<?xml version="1.0"?>

<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.permazen</groupId>
<artifactId>permazen</artifactId>
<version>4.1.0-SNAPSHOT</version>
</parent>
<artifactId>permazen-kv-xodus</artifactId>
<name>Permazen Xodus Key/Value Store</name>
<description>Permazen key/value store implementation based on Xodus.</description>
<distributionManagement>
<site>
<id>${project.artifactId}-site</id>
<url>file://${project.basedir}/../site/${project.artifactId}/</url>
</site>
</distributionManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${project.parent.artifactId}-kv</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${project.parent.artifactId}-kv-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${project.parent.artifactId}-util</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.xodus</groupId>
<artifactId>xodus-environment</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.xodus</groupId>
<artifactId>xodus-openAPI</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,64 @@

/*
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
*/

package io.permazen.kv.xodus;

import com.google.common.base.Preconditions;

import java.util.function.Function;

import jetbrains.exodus.env.Environment;
import jetbrains.exodus.env.Transaction;

/**
* Xodus transaction types.
*/
public enum TransactionType implements Function<Environment, Transaction> {

/**
* Read-only transaction.
*
* @see Environment#beginReadonlyTransaction
*/
READ_ONLY(true, false, Environment::beginReadonlyTransaction),

/**
* Normal read-write transaction.
*
* @see Environment#beginTransaction
*/
READ_WRITE(false, false, Environment::beginTransaction),

/**
* Exclusive read-write transaction.
*
* @see Environment#beginExclusiveTransaction
*/
READ_WRITE_EXCLUSIVE(false, true, Environment::beginExclusiveTransaction);

private final boolean readOnly;
private final boolean exclusive;
private final Function<Environment, Transaction> creator;

TransactionType(boolean readOnly, boolean exclusive, Function<Environment, Transaction> creator) {
this.readOnly = readOnly;
this.exclusive = exclusive;
this.creator = creator;
}

public boolean isReadOnly() {
return this.readOnly;
}

public boolean isExclusive() {
return this.exclusive;
}

@Override
public Transaction apply(Environment env) {
Preconditions.checkArgument(env != null, "null env");
return this.creator.apply(env);
}
}

0 comments on commit 3093ecb

Please sign in to comment.