package getAsyncTpl
Asynchronous getter methods to retrieve tuples of data.
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 4 groups of asynchronous getters for tuples, each returning Futures of data in various formats:
- GetAsyncTplArray - fastest retrieved typed data set. Can be traversed with a fast
whileloop - GetAsyncTplIterable - for lazily traversing row by row
- GetAsyncTplList - 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 4 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
- getAsyncTpl.scala
- See also
equivalent synchronous getters in the getTpl package.
Type Members
-
trait
GetAsyncTplArray[Obj, 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 fastwhileloop.Ns.int.insert(1, 2, 3) // Map over 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
getpackage) in a Future.getAsyncArrayAsOfthus wraps the result ofgetArrayAsOfin a Future and so on. -
trait
GetAsyncTplIterable[Obj, 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
getpackage) in a Future.getAsyncIterableAsOfthus wraps the result ofgetIterableAsOfin a Future and so on. -
trait
GetAsyncTplList[Obj, 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 (getAsyncinstead ofgetAsyncList).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
getpackage) in a Future.getAsyncAsOfthus wraps the result ofgetAsOfin a Future and so on.

Documentation/API for the Molecule library - a meta DSL for the Datomic database.
scalamolecule.org | Github | Forum