Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/greendelta/olca-h2

Implementation of the openLCA IDatabase interface with an H2 in-memory database
https://github.com/greendelta/olca-h2

Last synced: 7 days ago
JSON representation

Implementation of the openLCA IDatabase interface with an H2 in-memory database

Awesome Lists containing this project

README

        

# olca-h2
`olca-h2` provides an implementation of the openLCA `IDatabase` interface using
an in-memory instance of an [H2](http://www.h2database.com) database. The import
into `olca-h2` is ~twice as fast compared to an import into a file based Derby
database in openLCA (on a modern SSD drive). Additionally, you can dump such
an `olca-h2` database to a file and reload it into memory later (see below).

## Usage
Install the [openLCA core modules](https://github.com/GreenDelta/olca-modules)
and this project via [Maven](https://maven.apache.org/) (you may have to check
the version of the dependencies):

```bash
git clone
cd olca-h2 # check the version in the pom.xml
mvn install
```

After this you can use `olca-h2` e.g. as plain Maven dependency:

```xml
...

1.7.0

...


org.openlca
olca-core
${olca.version}



org.apache.derby
derby




org.openlca
olca-h2
${olca.version}

```

#### Create an empty database

```java
import org.openlca.core.database.IDatabase;
import org.openlca.h2.DB;

IDatabase db = DB.empty();
// use it like a standard openLCA database
```

#### Dump a database and reload it

```java
import org.openlca.h2.DB;

DB db = DB.empty();
// import data ...
db.dump("dump.gz");
DB db2 = DB.fromDump("dump.gz");
```

## Updating
`olca-h2` has its own `schema.sql` and `persistence.xml` files. So if there
are database schema or model updates in openLCA these files need to be checked.
The persistence unit is configured to directly take a
[HikariCP](https://github.com/brettwooldridge/HikariCP) connection pool (
`transaction-type="JTA"`)