Skip to content
/ reggae Public

A Clojure wrapper for the Rasdaman Java Client Library

License

Notifications You must be signed in to change notification settings

clojusc/reggae

Repository files navigation

reggae

Build Status Dependencies Status Clojars Project Clojure version

A Clojure wrapper for the Rasdaman Java Client Library

NOTICE: This library is a work in progress and general experiment. Please don't expect anything to work! That being said, feel free to submit tickets for features you'd like to see, missing methods you'd like wrapped, etc.

Contents

Introduction

The Rasdaman site touts the database as the World's Leading Array Database, allowing users to store and query massive multi-dimensional ​arrays such as sensor, image, simulation, and statistics data appearing in domains like earth, space, and life science. During a review in Fall 2014, independent experts unanimously attested that, based on "proven evidence", rasdaman will "significantly transform the way scientists access and use data in a way that hitherto was not possible".

Rasdaman comes with client libraries written in C++ and Java. The Clojure reggae library is a thin wrapper around the Java library, allowing for idiomatic Clojure when working with Rasdaman.

Dependencies

  • A running instance of Rasdaman
  • PostgreSQL and postgis
  • The Rasdaman PostgreSQL backend configured to accept network connections
  • lein

Installation

Add the following to your project.clj file's :dependencies:

Clojars Project

Then, in the namespace where you want to use Reggae:

(ns your.gis.project
  (:require [reggae.core :as reggae]))

Usage

Startup

$ lein repl

888d888 .d88b.  .d88b.  .d88b.  8888b.  .d88b.
888P"  d8P  Y8bd88P"88bd88P"88b    "88bd8P  Y8b
888    88888888888  888888  888.d88888888888888
888    Y8b.    Y88b 888Y88b 888888  888Y8b.
888     "Y8888  "Y88888 "Y88888"Y888888 "Y8888
                    888     888
               Y8b d88PY8b d88P
                "Y88P"  "Y88P"


Loading Clojure code ...

nREPL server started on port 49450 on host 127.0.0.1 - nrepl://127.0.0.1:49450
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_91-b14
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

Connecting

reggae.dev=> (require '[reggae.core :as reggae])
nil
reggae.dev=> (def rashost "127.0.0.1")
#'reggae.dev/rashost
reggae.dev=> (def client (reggae/make-client :host rashost))
#'reggae.dev/client
reggae.dev=>

Querying

(require '[reggae.types :as types])
reggae.dev=> (def query-str "select sdom(m) from Multiband as m")
#'reggae.dev/query-str
reggae.dev=> (def result (reggae/query client query-str))
#'reggae.dev/result
reggae.dev=> (map types/interval->vector result)
([4657 4923] [4657 4923] [4657 4923] [4657 4923] [4657 4923]
 [4657 4923] [4657 4923] [4657 4923] [17 18])

Or, with no assignments:

reggae.dev=> (->> "select sdom(m) from Multiband as m"
                  (reggae/query client)
                  (map types/interval->vector))
([4657 4923] [4657 4923] [4657 4923] [4657 4923] [4657 4923]
 [4657 4923] [4657 4923] [4657 4923] [17 18])

In that example we used a convenience function from the types namespace. You still have access to all the Rasdaman objects (via idiomatic Clojure wrappers in reggae.rasj), should you wish to use those:

reggae.dev=> (require '[reggae.rasj.types.interval :as rinterval]
                      '[reggae.rasj.types.point :as rpoint])
nil

Work with an interval:

reggae.dev=> (def first-interval (first result))
#'reggae.dev/first-interval
reggae.dev=> first-interval
#object[rasj.RasMInterval 0x1c2d6398 "[0:4656,0:4922]"]

Work with a point:

reggae.dev=> (rinterval/get-extent first-interval)
#object[rasj.RasPoint 0x3125fd2d "[4657,4923]"]
reggae.dev=> (-> first-interval
                 (rinterval/get-extent)
                 (rpoint/->vector))
[4657 4923]

Resources

License

Copyright © 2015-2017 Duncan McGreggor

Distributed under the Eclipse Public License, the same as Clojure.