package traildb
Not available on OCaml 5.5Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=685ba1ba395bdf318402e7c24151bf10018099f1b20b1ae1f1d5144e29e59ba3
md5=d3de8da2e0b59880a3a1635753c8663b
Description
TrailDB is a file format for time-series.
Added to opam-repository:
README
OCaml bindings for TrailDB
Here are OCaml bindings for TrailDB, an efficient tool for storing and querying series of events.
Pre-requisites
To build from source.
- jbuilder OCaml build system.
Install
From source:
$ make # use jbuilder
$ make test
$ make install # use opamOr using directly jbuilder:
$ jbuilder build @install
$ jbuilder runtest
$ jbuilder installDocumentation
A TrailDB file is a read only collection of trails, i.e. keyed series of event records with a timestamp and sharing a common set of fields.
The API is documented in lib/trailDB.mli.
Usage
A TrailDB file is created after a series of event records with
- a trail identifier,
- a timestamp
- and a shared set of fields.
(* Start the creation of a new traildb file to record events
with two fields (measure kind and value) plus an implicit timestamp *)
let db = TrailDB.Cons.open_w "/tmp/foo" ["measure";"value"] in
(* Make some trail identifiers *)
let uuid_0 = Uuidm.(v5 ns_oid "trail_0") in
let uuid_1 = Uuidm.(v5 ns_oid "trail_1") in
(* Insert events with a string value for each field *)
TrailDB.Cons.add db uuid_0 123456L ["temperature";"22"];
TrailDB.Cons.add db uuid_1 123456L ["temperature";"12"];
TrailDB.Cons.add db uuid_1 123457L ["temperature";"13"];
TrailDB.Cons.add db uuid_0 123457L ["temperature";"23"];
TrailDB.Cons.add db uuid_0 123458L ["temperature";"24"];
TrailDB.Cons.add db uuid_1 123458L ["temperature";"14"];
TrailDB.Cons.add db uuid_1 123459L ["temperature";"13"];
(* Dump on disk the TrailDB file *)
TrailDB.Cons.finalize dbOnce build a TrailDB database is read only file.
(* Open a read only TrailDB file *)
let db = TrailDB.open_r "/tmp/foo.tdb" in
(* Get some meta data *)
assert (TrailDB.num_trails db = 2L);
assert (TrailDB.num_events db = 7L);
assert (TrailDB.num_fields db = 3L); (* timestamp, measure, value *)
(* Get the identifier of a trail given its UUIDs *)
let trail_uuid = Uuidm.(v5 ns_oid "trail_1") in
let (Some trail_id) = TrailDB.get_trail_id db trail_uuid in
(* Extract the events of a trail using a cursor *)
let cursor = TrailDB.Cursor.create db in
TrailDB.Cursor.get_trail cursor trail_id;
let rec loop () =
match TrailDB.Cursor.next cursor with
| None -> ()
| Some event ->
let [measure;value] =
event.TrailDB.values
|> List.map (TrailDB.get_item_value db)
in
Printf.printf "(%Ld,%s,%s)\n" event.TrailDB.timestamp measure value
|> loop
in
loop ()
Dev Dependencies (1)
-
ounit
with-test
Optional Dependencies
None
Used by
None
Conflicts
None
Build status
Results of building traildb with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 0.1 (this version) | good | good | n/a | n/a | n/a |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure