trait GetIterable[Tpl] extends AnyRef
Data getter methods on molecules that return Iterable[Tpl].
Suitable for data sets that are lazily consumed.
- Self Type
- Molecule[Tpl]
- Source
- GetIterable.scala
- Grouped
- Alphabetic
- By Inheritance
- GetIterable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getIterable(implicit conn: Conn): Iterable[Tpl]
Get
Iterable
of all rows as tuples matching the molecule.Get
Iterable
of all rows as tuples matching the molecule.
Rows are lazily type-casted on each call to iterator.next().Person.name.age.getIterable.toList === List( ("Ben", 42), ("Liz", 37), )
- conn
Implicit Conn value in scope
- returns
Iterable[Tpl] where Tpl is a tuple of types matching the attributes of the molecule
- See also
Equivalent asynchronous getAsyncIterable method.
- def getIterableAsOf(date: Date)(implicit conn: Conn): Iterable[Tpl]
Get
Iterable
of all rows as tuples matching molecule as of date.Get
Iterable
of all rows as tuples matching molecule as of date.
Get data at a human point in time (a java.util.Date).val beforeInsert = new java.util.Date // Insert val tx1 = Person.name.age insert List( ("Ben", 42), ("Liz", 37) ) val List(ben, liz) = tx1.eids val afterInsert = new java.util.Date // Update val tx2 = Person(ben).age(43).update val afterUpdate = new java.util.Date // Retract val tx3 = ben.retract val afterRetract = new java.util.Date // Get Iterable of all rows as of beforeInsert val iterable0: Iterable[(String, Int)] = Person.name.age.getIterableAsOf(beforeInsert) val iterator0: Iterator[(String, Int)] = iterable0.iterator iterator0.hasNext === false // Nothing yet // Get Iterable of all rows as of afterInsert val iterable1: Iterable[(String, Int)] = Person.name.age.getIterableAsOf(afterInsert) val iterator1: Iterator[(String, Int)] = iterable1.iterator // Type casting lazily performed with each call to `next` iterator1.next === ("Ben", 42) iterator1.next === ("Liz", 37) // Get Iterable of all rows as of afterUpdate val iterable2: Iterable[(String, Int)] = Person.name.age.getIterableAsOf(afterUpdate) val iterator2: Iterator[(String, Int)] = iterable2.iterator // Type casting lazily performed with each call to `next` iterator2.next === ("Ben", 43) // Ben now 43 iterator2.next === ("Liz", 37) // Get Iterable of all rows as of afterRetract val iterable3: Iterable[(String, Int)] = Person.name.age.getIterableAsOf(afterRetract) val iterator3: Iterator[(String, Int)] = iterable3.iterator // Type casting lazily performed with each call to `next` iterator3.next === ("Liz", 37) iterator3.hasNext === false // Ben gone
- date
java.util.Date
- conn
Implicit Conn value in scope
- returns
Iterable[Tpl] where Tpl is tuple of data matching molecule
- See also
Manual on
asof
/since
Equivalent asynchronous getAsyncIterableAsOf method.
- def getIterableAsOf(tx: TxReport)(implicit conn: Conn): Iterable[Tpl]
Get
Iterable
of all rows as tuples matching molecule as of tx.Get
Iterable
of all rows as tuples matching molecule as of tx.
Datomic's internalasOf
method can take a transaction entity id as argument to retrieve a database value as of that transaction (including).
Instead of supplying the transaction entity id, in Molecule we supply a TxReport that contains the transaction entity id (which is used as argument to Datomic internally). This is more convenient when using Molecule since we getAsync a TxReport from transaction operations likeget
,update
,retract
etc.// Insert (tx report 1) val tx1 = Person.name.age insert List( ("Ben", 42), ("Liz", 37) ) val List(ben, liz) = tx1.eids // Update (tx report 2) val tx2 = Person(ben).age(43).update // Retract (tx report 3) val tx3 = ben.retract // Get Iterable of all rows as of tx1 (after insert) val iterable1: Iterable[(String, Int)] = Person.name.age.getIterableAsOf(tx1) val iterator1: Iterator[(String, Int)] = iterable1.iterator // Type casting lazily performed with each call to `next` iterator1.next === ("Ben", 42) iterator1.next === ("Liz", 37) // Get Iterable of all rows as of tx2 (after update) val iterable2: Iterable[(String, Int)] = Person.name.age.getIterableAsOf(tx2) val iterator2: Iterator[(String, Int)] = iterable2.iterator // Type casting lazily performed with each call to `next` iterator2.next === ("Ben", 43) // Ben now 43 iterator2.next === ("Liz", 37) // Get Iterable of all rows as of tx3 (after retract) val iterable3: Iterable[(String, Int)] = Person.name.age.getIterableAsOf(tx3) val iterator3: Iterator[(String, Int)] = iterable3.iterator // Type casting lazily performed with each call to `next` iterator3.next === ("Liz", 37) iterator3.hasNext === false // Ben gone
- tx
TxReport (returned from all molecule transaction operations)
- conn
Implicit Conn value in scope
- returns
Iterable[Tpl] where Tpl is tuple of data matching molecule
- See also
Manual on
asof
/since
Equivalent asynchronous getAsyncIterableAsOf method.
- def getIterableAsOf(t: Long)(implicit conn: Conn): Iterable[Tpl]
Get
Iterable
of all rows as tuples matching molecule as of transaction timet
.Get
Iterable
of all rows as tuples matching molecule as of transaction timet
.
Transaction timet
is an auto-incremented transaction number assigned internally by Datomic.
CallgetIterableAsOf
for large result sets to maximize runtime performance. Data is lazily type-casted on each call tonext
on the iterator.
t
can for instance be retrieved in a getHistory call for an attribute and then be used to get data as of that point in time (including that transaction):// Insert (t 1028) val List(ben, liz) = Person.name.age insert List( ("Ben", 42), ("Liz", 37) ) eids // Update (t 1031) Person(ben).age(43).update // Retract (t 1032) ben.retract // History of Ben Person(ben).age.t.op.getHistory.sortBy(r => (r._2, r._3)) === List( (42, 1028, true), // Insert: 42 asserted (42, 1031, false), // Update: 42 retracted (43, 1031, true), // 43 asserted (43, 1032, false) // Retract: 43 retracted ) // Get Iterable of all rows as of transaction t 1028 (after insert) val iterable1: Iterable[(String, Int)] = Person.name.age.getIterableAsOf(1028) val iterator1: Iterator[(String, Int)] = iterable1.iterator // Type casting lazily performed with each call to `next` iterator1.next === ("Liz", 37) iterator1.next === ("Ben", 42) // Get Iterable of all rows as of transaction t 1031 (after update) val iterable2: Iterable[(String, Int)] = Person.name.age.getIterableAsOf(1031) val iterator2: Iterator[(String, Int)] = iterable2.iterator // Type casting lazily performed with each call to `next` iterator2.next === ("Liz", 37) iterator2.next === ("Ben", 43) // Ben now 43 // Get Iterable of all rows as of transaction t 1032 (after retract) val iterable3: Iterable[(String, Int)] = Person.name.age.getIterableAsOf(1032) val iterator3: Iterator[(String, Int)] = iterable3.iterator // Type casting lazily performed with each call to `next` iterator3.next === ("Liz", 37) iterator3.hasNext === false // Ben gone
- t
Transaction time t
- conn
Implicit Conn value in scope
- returns
Iterable[Tpl] where Tpl is tuple of data matching molecule
- See also
Manual on
asof
/since
Equivalent asynchronous getAsyncIterableAsOf method.
- def getIterableSince(date: Date)(implicit conn: Conn): Iterable[Tpl]
Get
Iterable
of all rows as tuples matching molecule since date.Get
Iterable
of all rows as tuples matching molecule since date.
Get data added/retracted since a human point in time (a java.util.Date).// Transact 3 times (`inst` retrieves transaction time from tx report) val date1 = Person.name("Ann").save.inst val date2 = Person.name("Ben").save.inst val date3 = Person.name("Cay").save.inst // Current values Person.name.getIterable.iterator.toList === List("Ann", "Ben", "Cay") // Ben and Cay added since date1 Person.name.getIterableSince(date1).iterator.toList === List("Ben", "Cay") // Cay added since date2 Person.name.getIterableSince(date2).iterator.toList === List("Cay") // Nothing added since date3 Person.name.getIterableSince(date3).iterator.toList === Nil
- date
java.util.Date
- conn
Implicit Conn value in scope
- returns
Iterable[Tpl] where Tpl is tuple of data matching molecule
- See also
Manual on
asof
/since
Equivalent asynchronous getAsyncIterableSince method.
- def getIterableSince(tx: TxReport)(implicit conn: Conn): Iterable[Tpl]
Get
Iterable
of all rows as tuples matching molecule since tx.Get
Iterable
of all rows as tuples matching molecule since tx.
Datomic's internalsince
method can take a transaction entity id as argument to retrieve a database value since that transaction (excluding the transaction itself).
Instead of supplying the transaction entity id, in Molecule we supply a TxReport that contains the transaction entity id (which is used as argument to Datomic internally). This is more convenient when using Molecule since we getAsync a TxReport from transaction operations likeget
,update
,retract
etc.// Get tx reports for 3 transactions val tx1 = Person.name("Ann").save val tx2 = Person.name("Ben").save val tx3 = Person.name("Cay").save // Current values Person.name.getIterable.iterator.toList === List("Ann", "Ben", "Cay") // Ben and Cay added since tx1 Person.name.getIterableSince(tx1).iterator.toList === List("Ben", "Cay") // Cay added since tx2 Person.name.getIterableSince(tx2).iterator.toList === List("Cay") // Nothing added since tx3 Person.name.getIterableSince(tx3).iterator.toList === Nil
- tx
- conn
Implicit Conn value in scope
- returns
Iterable[Tpl] where Tpl is tuple of data matching molecule
- See also
Manual on
asof
/since
Equivalent asynchronous getAsyncIterableSince method.
- def getIterableSince(t: Long)(implicit conn: Conn): Iterable[Tpl]
Get
Iterable
of all rows as tuples matching molecule since transaction timet
.Get
Iterable
of all rows as tuples matching molecule since transaction timet
.
Transaction timet
is an auto-incremented transaction number assigned internally by Datomic.
CallgetIterableSince
for large result sets to maximize runtime performance. Data is lazily type-casted on each call tonext
on the iterator.
t
can for instance be retrieved callingt
on the tx report returned from transactional operations and then be used to get data since that point in time (excluding that transaction):// 3 transaction times `t` val t1 = Person.name("Ann").save.t val t2 = Person.name("Ben").save.t val t3 = Person.name("Cay").save.t // Current values as Iterable Person.name.getIterable.iterator.toList === List("Ann", "Ben", "Cay") // Ben and Cay added since transaction time t1 Person.name.getIterableSince(t1).iterator.toList === List("Ben", "Cay") // Cay added since transaction time t2 Person.name.getIterableSince(t2).iterator.toList === List("Cay") // Nothing added since transaction time t3 Person.name.getIterableSince(t3).iterator.toList === Nil
- t
Transaction time t
- conn
Implicit Conn value in scope
- returns
Iterable[Tpl] where Tpl is tuple of data matching molecule
- See also
Manual on
asof
/since
Equivalent asynchronous getAsyncIterableSince method.
- def getIterableWith(txData: List[_])(implicit conn: Conn): Iterable[Tpl]
Get
Iterable
of all rows as tuples matching molecule with applied raw transaction data.Get
Iterable
of all rows as tuples matching molecule with applied raw transaction data.
Apply raw transaction data to in-memory "branch" of db without affecting db to see how it would then look:// Live size of Person db Person.name.get.size === 150 // Read some transaction data from file val data_rdr2 = new FileReader("examples/resources/seattle/seattle-data1a.dtm") val newDataTx = Util.readAll(data_rdr2).get(0).asInstanceOf[java.util.List[Object]] // Imagine future db - 100 persons would be added, apparently Person.name.getIterableWith(newDataTx).size === 250
- txData
Raw transaction data as java.util.List[Object]
- conn
Implicit Conn value in scope
- returns
Iterable of molecule data
- See also
Manual on
with
Equivalent asynchronous getAsyncIterableWith method.
- def getIterableWith(txMolecules: Seq[Seq[Statement]]*)(implicit conn: Conn): Iterable[Tpl]
Get
Iterable
of all rows as tuples matching molecule with applied molecule transaction data.Get
Iterable
of all rows as tuples matching molecule with applied molecule transaction data.
Apply one or more molecule transactions to in-memory "branch" of db without affecting db to see how it would then look:// Current state val ben = Person.name("Ben").likes("pasta").save.eid // Base data Person.name.likes.getIterableWith( // apply imaginary transaction data Person(ben).likes("sushi").getUpdateTx ).iterator.toList === List( // Effect: Ben would like sushi if tx was applied ("Ben", "sushi") ) // Current state is still the same Person.name.likes.get === List( ("Ben", "pasta") )
Multiple transactions can be applied to test more complex what-if scenarios!
- txMolecules
Transaction statements from applied Molecules with test data
- conn
Implicit Conn value in scope
- returns
Iterable of molecule data
- See also
Manual on
with
Equivalent asynchronous getAsyncIterableWith method.
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
Documentation/API for the Molecule library - a meta DSL for the Datomic database.
Manual | scalamolecule.org | Github | Forum