Keywords

molecule.boilerplate.api.Keywords
See theKeywords companion trait
object Keywords extends KeywordsStable

Attributes

Companion
trait
Source
Keywords.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Keywords.type

Members list

Grouped members

aggrNumber

trait avg extends AggrCoalesce

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

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait AggrCoalesce
trait AggrKw
trait Kw
class Object
trait Matchable
class Any
Show all
Known subtypes
object avg
trait median extends AggrCoalesce

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

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait AggrCoalesce
trait AggrKw
trait Kw
class Object
trait Matchable
class Any
Show all
Known subtypes
object median
trait stddev extends AggrCoalesce

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

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait AggrCoalesce
trait AggrKw
trait Kw
class Object
trait Matchable
class Any
Show all
Known subtypes
object stddev
trait sum extends AggrCoalesce

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

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait AggrCoalesce
trait AggrKw
trait Kw
class Object
trait Matchable
class Any
Show all
Known subtypes
object sum
trait variance extends AggrCoalesce

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

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait AggrCoalesce
trait AggrKw
trait Kw
class Object
trait Matchable
class Any
Show all
Known subtypes
object variance

aggregates

trait count extends AggrCoalesce, AggrInt

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

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait AggrInt
trait AggrCoalesce
trait AggrKw
trait Kw
class Object
trait Matchable
class Any
Show all
Known subtypes
object count
trait countDistinct extends AggrCoalesce

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

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait AggrCoalesce
trait AggrKw
trait Kw
class Object
trait Matchable
class Any
Show all
Known subtypes
object countDistinct
trait distinct extends AggrKw

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]

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait AggrKw
trait Kw
class Object
trait Matchable
class Any
Known subtypes
object distinct
trait max extends AggrKw

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.

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait AggrKw
trait Kw
class Object
trait Matchable
class Any
Known subtypes
object max
trait min extends AggrKw

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.

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait AggrKw
trait Kw
class Object
trait Matchable
class Any
Known subtypes
object min
trait sample extends AggrKw

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..

Attributes

Note

Can at most return the number of values that match.

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait AggrKw
trait Kw
class Object
trait Matchable
class Any
Known subtypes
object sample

Type members

Inherited classlikes

trait AggrCoalesce extends AggrKw

Attributes

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait AggrKw
trait Kw
class Object
trait Matchable
class Any
Known subtypes
trait avg
object avg
trait count
object count
object countDistinct
trait median
object median
trait stddev
object stddev
trait sum
object sum
trait variance
object variance
Show all
trait AggrInt extends AggrKw

Attributes

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait AggrKw
trait Kw
class Object
trait Matchable
class Any
Known subtypes
trait count
object count
trait AggrKw extends Kw

Attributes

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait Kw
class Object
trait Matchable
class Any
Known subtypes
trait AggrCoalesce
trait avg
object avg
trait count
object count
object countDistinct
trait median
object median
trait stddev
object stddev
trait sum
object sum
trait variance
object variance
trait AggrInt
trait distinct
object distinct
trait max
object max
trait min
object min
trait sample
object sample
Show all
trait Kw

Attributes

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait AggrKw
trait AggrCoalesce
trait avg
object avg
trait count
object count
object countDistinct
trait median
object median
trait stddev
object stddev
trait sum
object sum
trait variance
object variance
trait AggrInt
trait distinct
object distinct
trait max
object max
trait min
object min
trait sample
object sample
class maxs
class mins
class samples
Show all
case class maxs(n: Int) extends Kw

Attributes

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait Kw
class Object
trait Matchable
class Any
Show all
case class mins(n: Int) extends Kw

Attributes

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait Kw
class Object
trait Matchable
class Any
Show all
case class samples(n: Int) extends Kw

Attributes

Inherited from:
KeywordsStable
Source
Keywords.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait Kw
class Object
trait Matchable
class Any
Show all