Skip to content

aholyoke/traildb-java

Repository files navigation

TrailDB Java CircleCI

Java Bindings for TrailDB

Installation

mvn install -P Linux

or

mvn install -P Mac

Only Linux and OS X are supported for the time being. Windows is on the way.

Run

Compile and run the example by adding the jar to your classpath and setting java.library.path to the object file.

javac -cp native/linux/target/lib/traildbJava.jar examples/Example.java

java -Djava.library.path=`pwd`/native/linux/target/ -cp examples:native/linux/target/lib/traildbJava.jar Example

Architecture

├── java
│   ├── pom.xml (TrailDB Java Classes)
│   ├── src
│   │   └── main
│   │       └── java
│   │           └── traildb                       ───┐
│   │               ├── TrailDB.java                 │
│   │               ├── TrailDBConstructor.java      │
│   │               ├── TrailDBTrail.java            │
│   │               ├── TrailDBMultiTrail.java       │ 1
│   │               └── TrailDBEventFilter.java      │
│   └── target                                       │
│       └── classes                                  │
│           └── traildb                           <──┘
│               ├── TrailDB.class                 ─────┐
│               ├── TrailDBConstructor.class      ───┐ │
│               ├── TrailDBTrail.class               │ │
│               ├── TrailDBMultiTrail.class          │ │
│               └── TrailDBEventFilter.class         │ │
├── native                                           │ │
│   ├── linux                                      3 │ │ 2
│   │   ├── pom.xml (Linux Build)                    │ │
│   │   └── target                                   │ │
│   │       ├── custom-javah                         │ │
│   │       │   └── traildb-java.h                <──┘ │
│   │       ├── lib                                    │
│   │       │   └── traildbJava.jar               <────┘
│   │       ├── libTraildbJavaNative.so           <──┐
│   │       └── objs                              ───┘ 5
│   │           ├── TrailDB.o                     <──┐
│   │           ├── TrailDBConstructor.o             │
│   │           ├── TrailDBTrail.o                   │
│   │           ├── TrailDBMultiTrail.o              │ 4
│   │           └── TrailDBEventFilter.o             │
│   ├── pom.xml (Native Build)                       │
│   └── src                                          │
│       └── main                                     │
│           └── native                            ───┘
│               ├── TrailDB.c
│               ├── TrailDBConstructor.c
│               ├── TrailDBTrail.c
│               ├── TrailDBMultiTrail.c
│               └── TrailDBEventFilter.c
└── pom.xml (TrailDB)
  1. Java sources under java/src/main/java/traildb are compiled using javac to their .class files under java/target/classes/traildb

  2. Java classes are jarred together into native/<platform>/target/lib/traildbJava.jar

  3. javah is used on the .class files to automatically generate the header file native/<platform>/target/custom-javah/traildb-java.h

  4. The header file is included in every c source under native/src/main/native. Each c source is compiled with gcc to their .o object files under native/<platform>/target/objs.

  5. Each object file is linked into a shared object file native/<platform>/target/libTraildbJavaNative.so. The TrailDB library is linked at this stage.

Images

  • The base image is defined in Dockerfile. It is an ubuntu image with the jdk and traildb installed. It can be built using make build

  • The installed image is defined in Dockerfile.installed. It is the base image with traildb-java bindings installed. It can be built using make install

Development

  • Implement exception raising

  • Unit tests

  • Set up maven or gradle or something so people can install

  • Benchmark relative to other language bindings

  • Audit multithreaded support

  • Cache field and method lookups

  • Benchmark again to evaluate efficacy of field caching

  • Finish implementing everything else

  • Enable -Wall and -Werr and fix issues

Functions

TrailDBConstructor

  • Constructor

  • add

  • append

  • finalize

  • close

  • setOpt

  • getOpt

TrailDB

  • Constructor

  • dontNeed

  • willNeed

  • numTrails

  • numEvents

  • numFields

  • minTimestamp

  • maxTimestamp

  • version

  • setOpt

  • getOpt

  • setTrailOpt

  • getTrailOpt

  • lexiconSize

  • getField

  • getFieldName

  • close

  • getUUID

  • getTrailId

TrailDBTrail

  • getTrail

  • getTrailLength

  • setEventFilter

  • unsetEventFilter

  • next

  • peek

  • getItem

TrailDBMultiTrail

  • setEventFilter

  • unsetEventFilter

  • next

  • peek

  • getItem

TrailDBEventFilter

  • addTerm

  • addTimeRange

  • newClause

  • numClauses

  • numTerms

  • isNegative