Skip to content
This repository was archived by the owner on Nov 3, 2020. It is now read-only.

Latest commit

 

History

History
executable file
·
311 lines (245 loc) · 11 KB

File metadata and controls

executable file
·
311 lines (245 loc) · 11 KB

thi.ng/trio

Contents

About the project

Overview

This project provides a simple, yet extensible and datatype agnostic triplestore API and powerful SPARQL-like query engine for Clojure/ClojureScript. This library is the result of extracting & refactoring non-RDF related functionality from the upcoming thi.ng/sema toolkit and so making the underlying graph tools more accessible to a wider audience. The library is developed in a literal programming format and contains many examples and extensive documentation for all parts. A test suite is being worked on too.

Triple stores are usually associated with Semantic Web & Linked Data applications, however encoding data as triples is natural & useful too for a large number of other use cases and this library is aiming to address some of these. Although currently only a couple of in-memory stores are available, the intention is to eventually offer a pluggable storage layer (a bit like Datomic). Some prototype implementations for Redis, CouchDB & Cassandra have been in development since last year (but currently stalled due to other priorities). The aim is to develop & bundle these in isolation as separate support libs for trio.

Status

ALPHA quality, subject to frequent changes until further notice.

Example usage

The query engine namespace and growing test suite is currently the best source of information and concrete usage examples. Please take a look!

Namespaces

Non-complete / in development

Tests

Project definition

Injected properties

0.2.0-SNAPSHOT

Dependencies

Runtime

[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "0.0-3308"]
[thi.ng/dstruct "0.1.0"]
[thi.ng/math "0.1.4"]
[thi.ng/strf "0.1.0"]
[thi.ng/validate "0.1.3"]
[thi.ng/xerror "0.1.0"]
[org.clojure/data.csv "0.1.2"]
[com.taoensso/timbre "3.3.1"]
[cljs-log "0.2.1"]

Development

[criterium "0.4.3"]
[com.cemerick/clojurescript.test "0.3.3"]
[lein-cljsbuild "1.0.6"]

Leiningen coordinates

[thi.ng/trio "0.2.0-SNAPSHOT"]

Building this project

This project is written in a literate programming format and requires Emacs & Org-mode to generate usable source code. Assuming both tools are installed, the easiest way to generate a working project is via command line (make sure emacs is on your path or else edit its path in tangle.sh):

git clone https://github.com/thi.ng/trio.git
cd trio
./tangle.sh src/*.org test/*.org

Tangling is the process of extracting & combining source blocks from .org files into an actual working project/source tree. Once tangling is complete, you can cd into the generated project directory (babel) and then use lein as usual.

Testing

The project.clj file defines an alias to trigger a complete build & tests for both CLJ & CLJS versions.

cd babel
lein cleantest

To build the Clojurescript version simply run lein cljsbuild test from the same directory. A small HTML harness for the resulting JS file is also located in that folder (babel/index.html), allowing for further experimentation in the browser.

Working with the REPL

Editing code blocks or files in Org-mode, then re-loading & testing changes is quite trivial. Simply launch a REPL (via lein or Emacs) as usual. Everytime you’ve made changes to an .org file, re-tangle it from Emacs (C-c C-v t) or tangle.sh, then reload the namespace in the REPL via (require 'thi.ng.trio... :reload) or similar.

Leiningen project file

(defproject thi.ng/trio "<<version>>"
  :description  "Generic triple store API & SPARQL-like query engine"
  :url          "<<project-url>>"
  :license      {:name "Apache Software License 2.0"
                 :url "http://www.apache.org/licenses/LICENSE-2.0"
                 :distribution :repo}
  :scm          {:name "git"
                 :url "git@github.com:thi-ng/trio.git"}

  :min-lein-vesion "2.4.0"

  :dependencies [<<dep-clj>>
                 <<dep-cljs>>
                 <<dep-xerror>>
                 <<dep-dstruct>>
                 <<dep-math>>
                 <<dep-strf>>
                 <<dep-validate>>
                 <<dep-csv>>
                 <<dep-timbre>>
                 <<dep-cljs-log>>]

  :profiles     {:dev {:dependencies [<<dep-criterium>>]
                       :plugins [<<dep-cljsbuild>>
                                 <<dep-cljs-test>>]
                       :global-vars {*warn-on-reflection* true}
                       :jvm-opts ^:replace []
                       :aliases {"cleantest" ["do" "clean," "test," "cljsbuild" "test"]}}}

  :cljsbuild    {:builds [{:id "simple"
                           :source-paths ["src" "test"]
                           :compiler {:output-to "<<cljs-artefact-path>>"
                                      :optimizations :whitespace
                                      :pretty-print true}}]
                 :test-commands {"unit-tests" ["phantomjs" :runner "<<cljs-artefact-path>>"]}}

  :pom-addition [:developers [:developer
                              [:name "Karsten Schmidt"]
                              [:url "http://postspectacular.com"]
                              [:timezone "0"]]])

ClojureScript HTML harness

<!DOCTYPE html>
<html lang="en">
  <head>
    <title><<lein-coords>> test</title>
  </head>
  <body>
    <script type="text/javascript" src="<<cljs-artefact-path>>"></script>
  </body>
</html>

Accessing library version during runtime

The autogenerated namespace thi.ng.trio.version contains a single symbol version holding the version string defined above:

(use '[thi.ng.trio.version])

(prn version)
; "<<version>>"

Version namespace

Release history

VersionReleasedDescriptionLein coordinatesTagged Github URL
0.2.0-SNAPSHOTn/aCLJ1.7.0 refactoring[thi.ng/trio "0.2.0-SNAPSHOT"]
0.1.02015-02-251st public release[thi.ng/trio "0.1.0"]0.1.0

Contributors

NameRoleWebsite
Karsten Schmidtinitiator & principal developerhttp://postspectacular.com

I’ve got a fairly detailed roadmap and task list to implement over the coming months, but am always happy to receive feedback & suggestions and have issues filed. Once the core engine is more refined I’ll be gladly welcoming other contributions. Thanks for understanding!

License

This project is open source and licensed under the Apache Software License 2.0.