ScoreFunction operates on data from a Kiji row and optional side data to produce a new value for that row. This operation will run according to a
KijiFreshnessPolicy and its outputs will be committed to the Kiji table in which the row resides and returned to the requesting client by the
Methods of a
ScoreFunction are divided into three categories based on when and where they are called.
Attachment time methods are called during Freshener registration in a
ScoreFunctionto save its state into into the Freshener record so that it can be rebuilt in a fresh reader.
Setup and cleanup methods are called when a Freshener is loaded or unloaded from a
ScoreFunctionto describe the
setup(FreshenerSetupContext)configures the internal state of the
cleanup(FreshenerSetupContext)cleans up resources used by the
Request time methods are called while a Freshener is live in a
FreshKijiTableReader in response to every read request which includes the column to which the Freshener is attached. These methods are only called if the associated
KijiFreshnessPolicy indicated that data was stale.
getDataRequest(FreshenerContext)specifies data to be passed to
score(KijiRowData, FreshenerContext)produces a fresh score from the row’s data. The
scoremethod returns a special object called a
TimestampedValuewhich allows the user to specify what timestamp the value should be written to.
TimestampedValueis a generic parameterized type which allows the user to safely return any type of value and the Kiji framework will handle it correctly.