Class LookupStrategy
java.lang.Object
cern.nxcals.api.custom.service.extraction.LookupStrategy
- All Implemented Interfaces:
cern.nxcals.common.utils.TriFunction<Function<TimeWindow,org.apache.spark.sql.Dataset<org.apache.spark.sql.Row>>, String, ExtractionProperties, org.apache.spark.sql.Dataset<org.apache.spark.sql.Row>>
public final class LookupStrategy
extends Object
implements cern.nxcals.common.utils.TriFunction<Function<TimeWindow,org.apache.spark.sql.Dataset<org.apache.spark.sql.Row>>,String,ExtractionProperties,org.apache.spark.sql.Dataset<org.apache.spark.sql.Row>>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LookupStrategyPerform data lookup to extract the last available datapoint (if any) prior the actual data that belong to a given time window.static final LookupStrategyPerform data lookup to extract the last available datapoint (if any) prior the given time window, only if the actual data do not exist.static final LookupStrategyPerform data lookup to extract the first available datapoint (if any) prior the given time window.static final LookupStrategyPerform data lookup to extract the first available datapoint (if any) after the given time window. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.spark.sql.Dataset<org.apache.spark.sql.Row> apply(Function<TimeWindow, org.apache.spark.sql.Dataset<org.apache.spark.sql.Row>> dataProvider, String timestampField, ExtractionProperties properties) This method retrieves the dataset containing the datapoint accordingly to the lookup strategy.boolean@NonNull Duration@NonNull cern.nxcals.api.custom.service.extraction.LookupStrategy.HandlerinthashCode()toString()withLookupDuration(long amount, @NonNull TemporalUnit unit)
-
Field Details
-
LAST_BEFORE_START
Perform data lookup to extract the last available datapoint (if any) prior the actual data that belong to a given time window. If such datapoint exists, we query the dataset with the timestamp of that datapoint as the startTime to get the dataset of the time window plus that datapoint. -
LAST_BEFORE_START_IF_EMPTY
Perform data lookup to extract the last available datapoint (if any) prior the given time window, only if the actual data do not exist. In that case a single row dataset would be returned, containing that last datapoint. Otherwise, if data exist for the given time window, this strategy will not perform any data lookup action, thus, only data points matching the query time window would be included on the result. -
NEXT_AFTER_START_ONLY
Perform data lookup to extract the first available datapoint (if any) after the given time window. A single row dataset would be returned, containing that first datapoint. -
LAST_BEFORE_START_ONLY
Perform data lookup to extract the first available datapoint (if any) prior the given time window. A single row dataset would be returned, containing that first datapoint.
-
-
Method Details
-
withLookupDuration
-
apply
public org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> apply(Function<TimeWindow, org.apache.spark.sql.Dataset<org.apache.spark.sql.Row>> dataProvider, String timestampField, ExtractionProperties properties) This method retrieves the dataset containing the datapoint accordingly to the lookup strategy. All three parameters are needed because when the strategy is LAST_BEFORE_START_IF_EMPTY we cannot know beforehand what the startTime will be.- Specified by:
applyin interfacecern.nxcals.common.utils.TriFunction<Function<TimeWindow,org.apache.spark.sql.Dataset<org.apache.spark.sql.Row>>, String, ExtractionProperties, org.apache.spark.sql.Dataset<org.apache.spark.sql.Row>> - Parameters:
dataProvider- This is used to extract the dataproperties- This is used to retrieve the end time of time window we are querying on- Returns:
- Dataset<Row> The dataset
-
getHandler
@NonNull public @NonNull cern.nxcals.api.custom.service.extraction.LookupStrategy.Handler getHandler() -
getDuration
-
toString
-
equals
-
hashCode
public int hashCode()
-