KeywordsStable
Keywords to mark aggregate expressions on and unifications of attributes.
// Aggregates on any attribute type
Person.age(count).get.map(_.head ==> 3) // count of asserted `age` attribute values
Person.age(countDistinct).get.map(_.head ==> 3) // count of asserted distinct `age` attribute values
Person.age(max).get.map(_.head ==> 38) // maximum `age` value (using `compare`)
Person.age(min).get.map(_.head ==> 5) // maximum `age` value (using `compare`)
Person.age(rand).get.map(_.head ==> 25) // single random `age` value
Person.age(sample).get.map(_.head ==> 27) // single sample `age` value (when single value, same as random)
// Aggregates on any attribute type, returning multiple values
Person.age(distinct).get.map(_.head ==> Vector(5, 7, 38)) // distinct `age` values
Person.age(max(2)).get.map(_.head ==> Vector(38, 7)) // 2 maximum `age` values
Person.age(min(2)).get.map(_.head ==> Vector(5, 7)) // 2 minimum `age` values
Person.age(rand(2)).get.map(_.head ==> Stream(5, ?)) // 2 random `age` values (values can re-occur)
Person.age(sample(2)).get.map(_.head ==> Vector(7, 38)) // 2 sample `age` values
// Aggregates on number attributes
Person.age(sum).get.map(_.head ==> 50) // sum of all `age` numbers
Person.age(avg).get.map(_.head ==> 16.66666667) // average of all `age` numbers
Person.age(median).get.map(_.head ==> 7) // median of all `age` numbers
Person.age(stddev).get.map(_.head ==> 15.107025591499) // standard deviation of all `age` numbers
Person.age(variance).get.map(_.head ==> 228.2222222222) // variance of all `age` numbers
Attributes
- Source
- Keywords.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object Keywords.type
Members list
Grouped members
Aggregate keywords
Keywords applied to attributes that return aggregated value(s).
Count of attribute values.
Apply count
keyword to attribute to return count of attribute values of entities matching the molecule.
Count of attribute values.
Apply count
keyword to attribute to return count of attribute values of entities matching the molecule.
for {
_ <- Person.firstName.lastName.age insert List(
("Ben", "Hayday", 42),
("Liz", "Taylor", 34),
("Liz", "Swifty", 34),
("Liz", "Mooray", 25)
)
_ <- Person.firstName.age(count).get.map(_ ==> List(
("Ben", 1),
("Liz", 3) // 34, 34, 25
))
} yield ()
Attributes
- Returns
-
Int
- Source
- Keywords.scala
- Supertypes
-
trait AggrInttrait AggrCoalescetrait AggrKwtrait Kwclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object count.type
Count of distinct attribute values.
Apply countDistinct
keyword to attribute to return count of distinct attribute values of entities matching the molecule.
Count of distinct attribute values.
Apply countDistinct
keyword to attribute to return count of distinct attribute values of entities matching the molecule.
for {
_ <- Person.firstName.lastName.age insert List(
("Ben", "Hayday", 42),
("Liz", "Taylor", 34),
("Liz", "Swifty", 34),
("Liz", "Mooray", 25)
)
_ <- Person.firstName.age(countDistinct).get.map(_ ==> List(
("Ben", 1),
("Liz", 2) // 34, 25
))
} yield ()
Attributes
- Returns
-
Int
- Source
- Keywords.scala
- Supertypes
- Known subtypes
-
object countDistinct.type
Distinct attribute values.
Apply distinct
keyword to attribute to return Vector of distinct attribute values of entities matching the molecule.
Distinct attribute values.
Apply distinct
keyword to attribute to return Vector of distinct attribute values of entities matching the molecule.
for {
_ <- Person.firstName.lastName.age insert List(
("Ben", "Hayday", 42),
("Liz", "Taylor", 34),
("Liz", "Swifty", 34),
("Liz", "Mooray", 25)
)
_ <- Person.firstName.age(distinct) insert List(
("Ben", 42),
("Liz", Vector(34, 25)) // only single 34 returned
)
} yield ()
Attributes
- Returns
-
List[attribute-type]
- Source
- Keywords.scala
- Supertypes
- Known subtypes
-
object distinct.type
Maximum attribute value(s).
Apply max
keyword to attribute to return the maximum attribute value of entities matching the molecule.
Maximum attribute value(s).
Apply max
keyword to attribute to return the maximum attribute value of entities matching the molecule.
for {
_ <- Person.age.insert(25, 34, 37, 42, 70)
_ <- Person.age(max).get.map(_.head ==> 70)
} yield ()
Apply max(n)
to return Vector of the n biggest values.
Person.age(max(3)).get.map(_.head ==> Vector(37, 42, 70))
Attributes
- Note
-
max
/max(n)
supports all value types (via comparators).max(n)
Can at most return the number of values that match. - Source
- Keywords.scala
- Supertypes
- Known subtypes
-
object max.type
Minimum attribute value(s).
Apply min
keyword to attribute to return the minimum attribute value of entities matching the molecule.
Minimum attribute value(s).
Apply min
keyword to attribute to return the minimum attribute value of entities matching the molecule.
for {
_ <- Person.age.insert(25, 34, 37, 42, 70)
_ <- Person.age(min).get.map(_.head ==> 25)
} yield ()
Apply min(n)
to return Vector of the n smallest values.
Person.age(min(3)).get.map(_.head ==> Vector(25, 34, 37))
Attributes
- Note
-
min
/min(n)
supports all value types (via comparators).min(n)
Can at most return the number of values that match. - Source
- Keywords.scala
- Supertypes
- Known subtypes
-
object min.type
Random attribute value(s).
Apply random
keyword to attribute to return a single random attribute of entities matching the molecule.
Random attribute value(s).
Apply random
keyword to attribute to return a single random attribute of entities matching the molecule.
for {
_ <- Person.age.insert(25, 34, 37, 42, 70)
_ <- Person.age(random).get.map(_.head ==> 34) // or other..
} yield ()
Apply random(n)
to return Vector of n random values. Observe though that duplicate random values can re-occur.
Person.age(random(3)).get.map(_.head ==> Vector(42, 25, 42)) // or other..
To get distinct values only, use the sample(n)
keyword instead.
Attributes
- Source
- Keywords.scala
- Supertypes
- Known subtypes
-
object rand.type
Sample attribute value(s).
Apply sample
keyword to attribute to return a single sample (random) attribute value of entities matching the molecule.
Sample attribute value(s).
Apply sample
keyword to attribute to return a single sample (random) attribute value of entities matching the molecule.
for {
_ <- Person.age.insert(25, 34, 37, 42, 70)
_ <- Person.age(sample).get.map(_.head ==> 42) // or other..
} yield ()
Apply sample(n)
to return Vector of up to n distinct sample values.
Person.age(sample(3)).get.map(_.head ==> Vector(70, 25, 37)) // or other..
If values don't need to be distinct, random(n)
can be used also.
Attributes
- Note
-
Can at most return the number of values that match.
- Source
- Keywords.scala
- Supertypes
- Known subtypes
-
object sample.type
Number aggregation keywords
Keywords applied to number attributes that return aggregated value(s).
Average of attribute values.
Apply avg
keyword to attribute to return average of attribute values of entities matching the molecule.
Average of attribute values.
Apply avg
keyword to attribute to return average of attribute values of entities matching the molecule.
for {
_ <- Match.sKeywords.insert(1, 2, 4)
_ <- Match.score(avg).get.map(_.head ==> 2.3333333333333335) // (1 + 2 + 4) / 3
} yield ()
Attributes
- Returns
-
Double
- Source
- Keywords.scala
- Supertypes
- Known subtypes
-
object avg.type
Median of attribute values.
Apply median
keyword to attribute to return median of attribute values of entities matching the molecule.
Median of attribute values.
Apply median
keyword to attribute to return median of attribute values of entities matching the molecule.
for {
_ <- Match.sKeywords.insert(1, 2, 4)
_ <- Match.score(median).get.map(_.head ==> 2)
} yield ()
OBS: When it comes to an even number of values, Datomic has a special implementation of median that is different from the one described on the Wiki entry on the median function.
Datomic calculates the median of even number of values as the average of the two middle numbers rounded down to nearest whole number
for {
_ <- Match.sKeywords.insert(1, 2, 3, 4)
_ <- Match.score(median).get.map(_.head ==> 2) // (2 + 3) / 2 = 2.5 rounded down to 2
} yield ()
With decimal numbers this can go wrong:
for {
_ <- Match.sKeywords.insert(1.0, 2.5, 2.5, 3.0)
_ <- Match.score(median).get.map(_.head ==> 2) // (2.5 + 2.5) / 2 = 2.5 rounded down to 2 (This is wrong and bug report has been filed)
} yield ()
Attributes
- Returns
-
Value of Attribute type
- Source
- Keywords.scala
- Supertypes
- Known subtypes
-
object median.type
Variance of attribute values.
Apply stddev
keyword to attribute to return variance of attribute values of entities matching the molecule.
Variance of attribute values.
Apply stddev
keyword to attribute to return variance of attribute values of entities matching the molecule.
for {
_ <- Match.sKeywords.insert(1, 2, 4)
_ <- Match.score(stddev).get.map(_.head ==> 1.247219128924647)
} yield ()
Attributes
- Returns
-
Double
- Source
- Keywords.scala
- Supertypes
- Known subtypes
-
object stddev.type
Sum of attribute values.
Apply sum
keyword to attribute to return sum of attribute values of entities matching the molecule.
Sum of attribute values.
Apply sum
keyword to attribute to return sum of attribute values of entities matching the molecule.
for {
_ <- Match.sKeywords.insert(1, 2, 4)
_ <- Match.score(sum).get.map(_.head ==> 7)
} yield ()
Attributes
- Returns
-
Value of Attribute type
- Source
- Keywords.scala
- Supertypes
- Known subtypes
-
object sum.type
Variance of attribute values.
Apply variance
keyword to attribute to return variance of attribute values of entities matching the molecule.
Variance of attribute values.
Apply variance
keyword to attribute to return variance of attribute values of entities matching the molecule.
for {
_ <- Match.sKeywords.insert(1, 2, 4)
_ <- Match.score(variance).get.map(_.head ==> 1.5555555555555556)
} yield ()
Attributes
- Returns
-
Double
- Source
- Keywords.scala
- Supertypes
- Known subtypes
-
object variance.type
attrMarker
Unify attribute value in self-join.
Apply unify
marker to attribute to unify its value with previous values of the same attribute in the molecule in a self-join.
Unify attribute value in self-join.
Apply unify
marker to attribute to unify its value with previous values of the same attribute in the molecule in a self-join.
for {
_ <- m(Person.age.name.Beverages * Beverage.name.rating) insert List(
(23, "Joe", List(("Coffee", 3), ("Cola", 2), ("Pepsi", 3))),
(25, "Ben", List(("Coffee", 2), ("Tea", 3))),
(23, "Liz", List(("Coffee", 1), ("Tea", 3), ("Pepsi", 1))))
// What beverages do pairs of 23- AND 25-year-olds like in common?
// Drink name is unified - Joe and Ben both drink coffee, etc..
_ <- Person.age_(23).name.Beverages.name._Ns.Self
.age_(25).name.Beverages.name_(unify).get.map(_.sorted ==> List(
("Joe", "Coffee", "Ben"),
("Liz", "Coffee", "Ben"),
("Liz", "Tea", "Ben")
))
} yield ()
Attributes
- Source
- Keywords.scala
- Supertypes
- Known subtypes
-
object unify.type
Type members
Classlikes
Attributes
- Source
- Keywords.scala
- Supertypes
- Known subtypes
Attributes
- Source
- Keywords.scala
- Supertypes
- Known subtypes
Attributes
- Source
- Keywords.scala
- Supertypes
- Known subtypes
-
trait AggrCoalescetrait avgobject avg.typetrait countobject count.typetrait countDistinctobject countDistinct.typetrait medianobject median.typetrait stddevobject stddev.typetrait sumobject sum.typetrait varianceobject variance.typetrait AggrInttrait distinctobject distinct.typetrait maxobject max.typetrait minobject min.typetrait randobject rand.typetrait sampleobject sample.typeShow all
Attributes
- Source
- Keywords.scala
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait AggrKwtrait AggrCoalescetrait avgobject avg.typetrait countobject count.typetrait countDistinctobject countDistinct.typetrait medianobject median.typetrait stddevobject stddev.typetrait sumobject sum.typetrait varianceobject variance.typetrait AggrInttrait distinctobject distinct.typetrait maxobject max.typetrait minobject min.typetrait randobject rand.typetrait sampleobject sample.typeclass maxsclass minsclass randsclass samplestrait unifyobject unify.typetrait v1object v1.typeShow all
Attributes
- Source
- Keywords.scala
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object bi.type
Attributes
- Source
- Keywords.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Kwclass Objecttrait Matchableclass AnyShow all
Attributes
- Source
- Keywords.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Kwclass Objecttrait Matchableclass AnyShow all
Attributes
- Source
- Keywords.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Kwclass Objecttrait Matchableclass AnyShow all
Attributes
- Source
- Keywords.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Kwclass Objecttrait Matchableclass AnyShow all
Attributes
- Source
- Keywords.scala
- Supertypes
- Known subtypes
-
object v1.type