ScoreFunction
ScoreFunction.java
ScoreFunction
A 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 FreshKijiTableReader
implementation.
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 KijiFreshnessManager
.
serializeToParameters
allows aScoreFunction
to 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 FreshKijiTableReader
.
getRequiredStores(FreshenerGetStoresContext)
allows aScoreFunction
to describe theKeyValueStores
it requires.setup(FreshenerSetupContext)
configures the internal state of theScoreFunction
.cleanup(FreshenerSetupContext)
cleans up resources used by theScoreFunction
.
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 toscore
.score(KijiRowData, FreshenerContext)
produces a fresh score from the row’s data. Thescore
method returns a special object called aTimestampedValue
which allows the user to specify what timestamp the value should be written to.TimestampedValue
is a generic parameterized type which allows the user to safely return any type of value and the Kiji framework will handle it correctly.
KijiScoring User Guide
- What is Scoring
- KijiFreshnessPolicy
- ScoreFunction
- FreshenerContext
- Lifecycle of a Freshener
- FreshKijiTableReader
- Metadata Management