AsOf / Since

Tests…

getAsOf(t) and getSince are complementary functions that either get us a snapshop of the database at some point in time or a current snapshot filtered with only changes after a point in time. Like before/after scenarios.

AsOf

AsOf test…

Calling getAsOf(t) on a molecule gives us the data as of a certain point in time like t4:


As we saw in point in time, a t can be either a transaction entity id like txE4, a transaction number t4, the resulting transaction report tx4 from some transactional operation or a java.util.Date like date4. So we could get to the same data in 4 different ways:

Person.name.age.getAsOf(txE4) === ... // Persons as of transaction entity id `txE4` (inclusive)
 
Person.name.age.getAsOf(t4) === ... // Persons as of transaction value `t4` (inclusive) 

Person.name.age.getAsOf(tx4) === ... // Persons as of transaction report `tx4` (inclusive) 

Person.name.age.getAsOf(date4) === ... // Persons as of some Date `date4` (inclusive) 

Note that t is “inclusive” meaning that it is how the database looked right after transaction txE4/t4/tx4/date4.

AsOf APIs

Data AsOf some point in time t can be returned as

  • List for convenient access to smaller data sets
  • Array for fastest retrieval and traversing of large typed data sets
  • Iterable for lazy traversing with an Iterator
  • Json (String)
  • Raw (java.util.Collection[java.util.List[AnyRef]]) for fast access to untyped data

where t can be any of:

  • Transaction entity id (Long)
  • Transaction number (Long)
  • Transaction report (molecule.facade.TxReport)
  • Date (java.util.Date)

Combine the needed return type with some representation of t and optionally a row limit by calling one of the corresponding AsOf implementations. All return type/parameter combinations have a synchronous and asynchronous implementation:

  • getAsOf(t) (List)
  • getArrayAsOf(t)
  • getIterableAsOf(t)
  • getJsonAsOf(t)
  • getRawAsOf(t)
  • getAsOf(t, limit) (List)
  • getArrayAsOf(t, limit)
  • getJsonAsOf(t, limit)
  • getRawAsOf(t, limit)
  • getAsyncAsOf(t) (List)
  • getAsyncArrayAsOf(t)
  • getAsyncIterableAsOf(t)
  • getAsyncJsonAsOf(t)
  • getAsyncRawAsOf(t)
  • getAsyncAsOf(t, limit) (List)
  • getAsyncArrayAsOf(t, limit)
  • getAsyncJsonAsOf(t, limit)
  • getAsyncRawAsOf(t, limit)

getIterableAsOf(t, limit) and getAsyncIterableAsOf(t, limit) are not implemented since the data is lazily evaluated with calls to next on the Iterator.

Since

Since tests…

As a complementary function to getAsOf(t) we have getSince(t) that gives us a snapshot of the current database filtered with only changes added after/since t:


Contrary to the getAsOf(t) method, the t is not included in getSince(t).

t can be either a transaction entity id like txE4, a transaction number t4, the resulting transaction report tx4 from some transactional operation or a java.util.Date like date4. So we could get to the same data in 4 different ways:

Person.name.age.getSince(txE4) === ... // Persons added since/after transaction entity id `txE4` (exclusive)
 
Person.name.age.getSince(t4) === ... // Persons added since/after transaction value `t4` (exclusive) 

Person.name.age.getSince(tx4) === ... // Persons added since/after transaction report `tx4` (exclusive)

Person.name.age.getSince(date4) === ... // Persons added since/after some Date `date4` (exclusive) 

Since APIs

Data Since some point in time t can be returned as

  • List for convenient access to smaller data sets
  • Array for fastest retrieval and traversing of large typed data sets
  • Iterable for lazy traversing with an Iterator
  • Json (String)
  • Raw (java.util.Collection[java.util.List[AnyRef]]) for fast access to untyped data

where t can be any of:

  • Transaction entity id (Long)
  • Transaction number (Long)
  • Transaction report (molecule.facade.TxReport)
  • Date (java.util.Date)

Combine the needed return type with some representation of t and optionally a row limit by calling one of the corresponding Since implementations. All return type/parameter combinations have a synchronous and asynchronous implementation:

  • getSince(t) (List)
  • getArraySince(t)
  • getIterableSince(t)
  • getJsonSince(t)
  • getRawSince(t)
  • getSince(t, limit) (List)
  • getArraySince(t, limit)
  • getJsonSince(t, limit)
  • getRawSince(t, limit)
  • getAsyncSince(t) (List)
  • getAsyncArraySince(t)
  • getAsyncIterableSince(t)
  • getAsyncJsonSince(t)
  • getAsyncRawSince(t)
  • getAsyncSince(t, limit) (List)
  • getAsyncArraySince(t, limit)
  • getAsyncJsonSince(t, limit)
  • getAsyncRawSince(t, limit)

getIterableSince(t, limit) and getAsyncIterableSince(t, limit) are not implemented since the data is lazily evaluated with calls to next on the Iterator.

The asynchronous implementations simply wraps the synchronous result in a Future as any other database server would normally do internally. The difference is that the Peer (the “database server”) runs in the same process as our application code which makes it natural to do the Future-wrapping in Molecule as part of running our application.

Next

History…