Packages

  • package root

    Documentation/API for the Molecule library - a meta DSL for the Datomic database.

    Manual | scalamolecule.org | Github | Forum

    Definition Classes
    root
  • package molecule

    Molecule library - a Scala meta-DSL for the Datomic database.

    Molecule library - a Scala meta-DSL for the Datomic database.

    See api package for various api imports to start using Molecule.

    Sub-packages

    api Molecule API.
    ast Internal Molecule ASTs.
    boilerplate Internal interfaces for auto-generated DSL boilerplate code.
    composition    Builder methods to compose molecules.
    exceptions Exceptions thrown by Molecule.
    expression Attribute expressions and operations.
    facade Molecule facades to Datomic.
    factory Implicit macro methods `m` to instantiate molecules from custom DSL molecule constructs.
    input Input molecules awaiting input.
    macros Internal macros generating molecule code from custom DSL molecule constructs.
    generic Interfaces to generic information about datoms and Datomic database.
    ops Internal operational helpers for transforming DSL to molecule.
    schema Schema definition DSL.
    transform Internal transformers from DSL to Model/Query/Transaction.
    util Internal Java database functions for Datomic.

    Definition Classes
    root
  • package api
    Definition Classes
    molecule
  • package exception
    Definition Classes
    api
  • package get

    Synchronous getter methods to retrieve data from Datomic.

    Synchronous getter methods to retrieve data from Datomic.

    The Datomic On-Prem(ises) server model provides a Peer that returns data synchronously. The Peer which lives in application memory caches data aggressively and for data fitting in memory latency can be extremely low and queries return very fast. And even when access to disk is needed, clever branching is used. Memcached is also an option.

    The Datomic Cloud model data returns data asynchronously. If Datomic creates a Java API for the Cloud model, Molecule could relatively easy adapt to this model too. In the meanwhile, Future-wrapped methods in this package can be used.

    Molecule has 5 groups of synchronous getters, each returning data in various formats:

    • GetArray - fastest retrieved typed data set. Can be traversed with a fast while loop
    • GetIterable - for lazily traversing row by row
    • GetJson - data formatted as Json string
    • GetList - default getter returning Lists of tuples. Convenient typed data, suitable for smaller data sets
    • GetRaw - fastest retrieved raw un-typed data from Datomic

    Getters in each of the 5 groups come with 5 time-dependent variations:

    • get [current data]
    • getAsOf
    • getSince
    • getWith
    • getHistory

    Each time variation has various overloads taking different parameters (see each group for more info).

    Definition Classes
    api
    See also

    equivalent asynchronous getters in the getAsync package.

  • package getAsync

    Asynchronous getter methods to retrieve data from Datomic.

    Asynchronous getter methods to retrieve data from Datomic.

    For convenience, all synchronous getter methods from the get package are here wrapped in Futures.

    The Datomic On-Prem(ises) server model provides a Peer that returns data synchronously. The Peer which lives in application memory caches data aggressively and for data fitting in memory latency can be extremely low and queries return very fast. And even when access to disk is needed, clever branching is used. Memcached is also an option.

    The Datomic Cloud model data returns data asynchronously. If Datomic creates a Java API for the Cloud model, Molecule could relatively easy adapt to this model too. In the meanwhile, Future-wrapped methods in this package can be used.

    Molecule has 5 groups of asynchronous getters, each returning Futures of data in various formats:

    • GetAsyncArray - fastest retrieved typed data set. Can be traversed with a fast while loop
    • GetAsyncIterable - for lazily traversing row by row
    • GetAsyncJson - data formatted as Json string
    • GetAsyncList - default getter returning Lists of tuples. Convenient typed data, suitable for smaller data sets
    • GetAsyncRaw - fastest retrieved raw un-typed data from Datomic

    Getters in each of the 5 groups come with 5 time-dependent variations:

    • getAsync [current data]
    • getAsyncAsOf
    • getAsyncSince
    • getAsyncWith
    • getAsyncHistory

    Each time variation has various overloads taking different parameters (see each group for more info).

    Definition Classes
    api
    See also

    equivalent synchronous getters in the get package.

  • GetAsyncArray
  • GetAsyncIterable
  • GetAsyncJson
  • GetAsyncList
  • GetAsyncRaw
p

molecule.api

getAsync

package getAsync

Asynchronous getter methods to retrieve data from Datomic.

For convenience, all synchronous getter methods from the get package are here wrapped in Futures.

The Datomic On-Prem(ises) server model provides a Peer that returns data synchronously. The Peer which lives in application memory caches data aggressively and for data fitting in memory latency can be extremely low and queries return very fast. And even when access to disk is needed, clever branching is used. Memcached is also an option.

The Datomic Cloud model data returns data asynchronously. If Datomic creates a Java API for the Cloud model, Molecule could relatively easy adapt to this model too. In the meanwhile, Future-wrapped methods in this package can be used.

Molecule has 5 groups of asynchronous getters, each returning Futures of data in various formats:

  • GetAsyncArray - fastest retrieved typed data set. Can be traversed with a fast while loop
  • GetAsyncIterable - for lazily traversing row by row
  • GetAsyncJson - data formatted as Json string
  • GetAsyncList - default getter returning Lists of tuples. Convenient typed data, suitable for smaller data sets
  • GetAsyncRaw - fastest retrieved raw un-typed data from Datomic

Getters in each of the 5 groups come with 5 time-dependent variations:

  • getAsync [current data]
  • getAsyncAsOf
  • getAsyncSince
  • getAsyncWith
  • getAsyncHistory

Each time variation has various overloads taking different parameters (see each group for more info).

Source
getAsync.scala
See also

equivalent synchronous getters in the get package.

Linear Supertypes
AnyRef, Any

Type Members

  1. trait GetAsyncArray[Tpl] extends AnyRef

    Asynchronous data getter methods on molecules returning Future[Array[Tpl]].

    Asynchronous data getter methods on molecules returning Future[Array[Tpl]].

    The fastest way of getting a large typed data set since data is applied to a super fast pre-allocated Array. The Array can then be traversed with a fast while loop.

    // Map over the Future
    Ns.int.getAsyncArray.map { result =>
      result === Array(1, 2, 3)
    
      // Fast while loop
      var i = 0
      val length = result.length
      while(i < length) {
        println(result(i)) // Do stuff with row...
        i += 1
      }
    }

    Each asynchronous getter in this package simply wraps the result of its equivalent synchronous getter (in the get package) in a Future. getAsyncArrayAsOf thus wraps the result of getArrayAsOf in a Future and so on.

  2. trait GetAsyncIterable[Tpl] extends AnyRef

    Asynchronous data getter methods on molecules returning Future[Iterable[Tpl]].

    Asynchronous data getter methods on molecules returning Future[Iterable[Tpl]].

    Suitable for data sets that are lazily consumed.

    val iterableFuture: Future[Iterable[(String, Int)]] = Person.name.age.getAsyncIterable
    for {
      iterable <- iterableFuture
    } yield {
      iterable.iterator.next === ("Ben" 42)
    }

    Each asynchronous getter in this package simply wraps the result of its equivalent synchronous getter (in the get package) in a Future. getAsyncIterableAsOf thus wraps the result of getIterableAsOf in a Future and so on.

  3. trait GetAsyncJson extends AnyRef

    Asynchronous data getter methods on molecules returning Future-wrapped Json String.

    Asynchronous data getter methods on molecules returning Future-wrapped Json String.

    Molecule builds a Json String directly from the untyped raw Datomic data.

    Attributes names are used as Json field names. In order to distinguish fields from each other, all attribute names are prepended with the namespace name (in lowercase). For a namespace Person with an attribute name we get:

    • "person.name"

    To distinguis fields of multiple relationships to the same namespace like friends and enemies pointing to other Person's require us to add a relationship name prefix too:

    • "friends.person.name"
    • "enemies.person.name"

    Furthermore, if the attribute is part of a transaction meta-data molecule, we prefix that with tx too:

    • "tx.person.name"
    • "tx.friends.person.name"

    Example:

    val jsonFuture: Future[String] = Person.name.age.getAsyncJson
    for {
      json <- jsonFuture
    } yield {
      json ===
       """[
         |{"person.name": "Ben", "person.age": 42},
         |{"person.name": "Liz", "person.age": 37}
         |]""".stripMargin
    }

    Each asynchronous getter in this package simply wraps the result of its equivalent synchronous getter (in the get package) in a Future. getAsyncIterableAsOf thus wraps the result of getIterableAsOf in a Future and so on.

    See also

    Json tests

  4. trait GetAsyncList[Tpl] extends AnyRef

    Default asynchronous data getter methods on molecules returning Future[List[Tpl]].

    Default asynchronous data getter methods on molecules returning Future[List[Tpl]].

    For expected smaller result sets it's convenient to return Lists of tuples of data. Considered as the default getter, no postfix has been added (getAsync instead of getAsyncList).

    val futureList: Future[List[(String, Int)]] = Person.name.age.getAsync
    for {
      list <- futureList
    } yield {
      list === List(
        ("Ben", 42),
        ("Liz", 37)
      )
    }

    Each asynchronous getter in this package simply wraps the result of its equivalent synchronous getter (in the get package) in a Future. getAsyncAsOf thus wraps the result of getAsOf in a Future and so on.

  5. trait GetAsyncRaw extends AnyRef

    Asynchronous data getter methods on molecules returning raw untyped Datomic data.

    Asynchronous data getter methods on molecules returning raw untyped Datomic data.

    Returns a Future with raw untyped java.util.Collection[java.util.List[Object]] directly from Datomic and is therefore the fastest (but untyped) way of retrieving data. Can be useful where typed data is not needed.

    val rawDataFuture: Future[java.util.Colleciton[java.util.List[Object]] = Person.name.age.getAsyncRaw
    for {
      rawData <- rawDataFuture
    } yield {
      rawData.toString === """[["Ben" 42]["Liz" 37]]"""
    }

    Each asynchronous getter in this package simply wraps the result of its equivalent synchronous getter (in the get package) in a Future. getAsyncRawAsOf thus wraps the result of getRawAsOf in a Future and so on.

Inherited from AnyRef

Inherited from Any

Ungrouped