A semantics that can interpret complicated expressions by compiling the expressions.
A semantics object is responsible for parsing a variable accessor specification inside a dollar sign-curly brace expression (that may be embedded in a larger expression).
A semantics object is responsible for parsing a variable accessor specification inside a dollar sign-curly brace
expression (that may be embedded in a larger expression). For instance, in the variable accessor specification:
${a.b[0].c}
, the semantics is responsible for transforming the string a.b[0].c
into Scala code
for a function that pulls the data out of an object of type A. The output type of the function need not
be stated explicitly because Scala's type inference mechanism will be used at the time the generated function
is compiled.
the input type to a model
Companion class containing canonical class names for wrapper classes uses in compilation.
A semantics that can interpret complicated expressions by compiling the expressions. This semantics constructs actual working scala code (see the format below).
Notice from the code that is constructed that it calls a function in com.eharmony.aloha.semantics.func.GenFunc. The function that is called is based on the input arity. Aside from the f0 function, fi has i arguments in the first argument list and two arguments in the second argument list. The first argument list represents the definition of the accessor functions. These are the functions created to extract data from the domain object. com.eharmony.aloha.semantics.compiled.CompiledSemanticsPlugin objects are responsible for constructing the function bodies. For instance,
(_:Map[String, Long]).get("user.match.TaxBrackets")
in the first example. The CompiledSemantics class is responsible for wrapping this code appropriately, constructing the aggregation function and finally putting everything together and compiling it.Examples
E.g. 1: Two variables are both optional (not necessarily in the input type passed to the model): - user.match.TaxBrackets - cand.taxBracket
E.g. 2: Two variables (one required, one optional): - user.inboundComm (required) - user.pageViews (optional)
E.g. 3: Three required variables (one, two, three):
E.g. 4: Invariant function (not dependent on any input variables).
the input type to the functions that are to be generated. Said another way, this is domain type of the models that will be generated by the ModelFactory to which this com.eharmony.aloha.semantics.Semantics will be passed.
a compiler capable of compiling real scala code and generating real instances that work at full speed.
a plugin that can make sense of the variable specifications and generate code to extract data from them.
a list of imports.
whether we should provide com.eharmony.aloha.semantics.SemanticsUdfException instead of raw exceptions in the case that a feature produces an exception. The perceived benefit of this seems to drastically outweigh the performance hit, so this defaults to true (as this is suggested).
an execution context in which to run the Futures that are used in the cache.