Class AbstractQueryEngine
java.lang.Object
com.inductiveautomation.historian.gateway.api.query.AbstractQueryEngine
- All Implemented Interfaces:
QueryEngine
Abstract base class for building query engines that support various types of querying
(raw, aggregated, and complex) over historical data.
This class implements the
QueryEngine
interface and provides foundational behavior
for managing query operations, logging, error handling, and performance metrics.
Concrete subclasses should implement specific query behaviors by overriding the provided protected methods for handling raw data, aggregated data, and complex query types.
This class is initialized with a gateway context, historian name, logging utilities, a path adapter, and supported complex point types. It also relies on a metrics object for tracking performance during query execution.
Thread-safe methods are provided for browsing and querying using various input parameters and result processors, while enforcing validation rules and quality codes for unsupported or unavailable operations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final GatewayContext
protected final String
protected final LoggerEx
protected final QueryMetrics
protected final QualifiedPathAdapter
protected final Set<? extends ComplexPointType>
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractQueryEngine
(GatewayContext gatewayContext, String historianName, LoggerEx logger) protected
AbstractQueryEngine
(GatewayContext gatewayContext, String historianName, LoggerEx logger, QualifiedPathAdapter pathAdapter) protected
AbstractQueryEngine
(GatewayContext gatewayContext, String historianName, LoggerEx logger, QualifiedPathAdapter pathAdapter, Set<? extends ComplexPointType> supportedComplexTypes) -
Method Summary
Modifier and TypeMethodDescriptionfinal void
browse
(QualifiedPath root, BrowseFilter filter, BrowsePublisher results) Allows browsing of a tree structure starting at a given root path while applying a filter and passing the results to a specified publisher.protected abstract void
doBrowse
(QualifiedPath root, BrowseFilter filter, BrowsePublisher results) doQueryAggregated
(AggregatedQueryOptions options, AggregatedPointProcessor processor) doQueryAnnotations
(AnnotationQueryOptions options, AnnotationPointProcessor processor) protected final <P extends ComplexPoint<?>,
K extends ComplexQueryKey<?>>
Optional<Integer>doQueryComplex
(ComplexQueryOptions<K> options, ComplexPointProcessor<P, K> processor) doQueryMetadata
(MetadataQueryOptions options, MetadataPointProcessor processor) doQueryRaw
(RawQueryOptions options, RawPointProcessor processor) protected boolean
protected boolean
isComplexTypeSupported
(ComplexQueryOptions<?> options) protected abstract boolean
protected abstract Optional<? extends HistoricalNode>
lookupNode
(QualifiedPath source) protected <P extends TemporalPoint<?,
T>, K extends QueryKey<T>, T extends TemporalPointType & QueryablePointType<T>>
Map<K,? extends HistoricalNode> mapKeysToNodes
(QueryOptions<K, T> options, QueriedPointProcessor<P, K, T> processor, Function<K, QualifiedPath> sourceGetter) Maps query keys to historical nodes, querying for missing nodes as needed.protected QualifiedPath
normalizePath
(QualifiedPath path) final void
query
(AggregatedQueryOptions options, AggregatedPointProcessor processor) Executes an aggregated query based on the provided options and processes the results using the specified processor.final <P extends ComplexPoint<?>,
K extends ComplexQueryKey<?>>
voidquery
(ComplexQueryOptions<K> options, ComplexPointProcessor<P, K> processor) Executes a query on complex points based on the provided options and processes the results using the specified processor.final void
query
(RawQueryOptions options, RawPointProcessor processor) Executes a query to retrieve raw data points based on the provided options and processes the results using the specified processor.protected abstract Map<QualifiedPath,
? extends HistoricalNode> queryForHistoricalNodes
(Set<QualifiedPath> sources, @Nullable TimeRange timeRange) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.inductiveautomation.historian.gateway.api.query.QueryEngine
getNativeAggregates
-
Field Details
-
logger
-
gatewayContext
-
historianName
-
pathAdapter
-
supportedComplexTypes
-
metrics
-
-
Constructor Details
-
AbstractQueryEngine
-
AbstractQueryEngine
protected AbstractQueryEngine(GatewayContext gatewayContext, String historianName, LoggerEx logger, QualifiedPathAdapter pathAdapter) -
AbstractQueryEngine
protected AbstractQueryEngine(GatewayContext gatewayContext, String historianName, LoggerEx logger, QualifiedPathAdapter pathAdapter, Set<? extends ComplexPointType> supportedComplexTypes)
-
-
Method Details
-
browse
Description copied from interface:QueryEngine
Allows browsing of a tree structure starting at a given root path while applying a filter and passing the results to a specified publisher.- Specified by:
browse
in interfaceQueryEngine
- Parameters:
root
- the starting path for the browse operationfilter
- defines the criteria for filtering browse resultsresults
- publishes the results of the browse operation
-
query
Description copied from interface:QueryEngine
Executes a query to retrieve raw data points based on the provided options and processes the results using the specified processor.- Specified by:
query
in interfaceQueryEngine
- Parameters:
options
- the configuration for the raw data query, including parameters such as time range, paths, and other query-specific settingsprocessor
- the handler responsible for processing the retrieved raw data points
-
query
Description copied from interface:QueryEngine
Executes an aggregated query based on the provided options and processes the results using the specified processor. This method defaults to indicate that aggregated queries aren't supported.- Specified by:
query
in interfaceQueryEngine
- Parameters:
options
- the configuration for the aggregated query, including time window settings, paths, and other query parametersprocessor
- the handler responsible for processing the retrieved aggregated data points
-
query
public final <P extends ComplexPoint<?>,K extends ComplexQueryKey<?>> void query(ComplexQueryOptions<K> options, ComplexPointProcessor<P, K> processor) Description copied from interface:QueryEngine
Executes a query on complex points based on the provided options and processes the results using the specified processor. This default implementation indicates that complex queries aren't supported.- Specified by:
query
in interfaceQueryEngine
- Type Parameters:
P
- the type of complex point being processedK
- the type of complex query key- Parameters:
options
- the configuration for the complex query, including query-specific settingsprocessor
- the handler responsible for processing the complex query results
-
doQueryComplex
protected final <P extends ComplexPoint<?>,K extends ComplexQueryKey<?>> Optional<Integer> doQueryComplex(ComplexQueryOptions<K> options, ComplexPointProcessor<P, K> processor) -
doQueryAnnotations
protected Optional<Integer> doQueryAnnotations(AnnotationQueryOptions options, AnnotationPointProcessor processor) -
doQueryMetadata
protected Optional<Integer> doQueryMetadata(MetadataQueryOptions options, MetadataPointProcessor processor) -
doQueryAggregated
protected Optional<Integer> doQueryAggregated(AggregatedQueryOptions options, AggregatedPointProcessor processor) -
mapKeysToNodes
protected <P extends TemporalPoint<?,T>, Map<K,K extends QueryKey<T>, T extends TemporalPointType & QueryablePointType<T>> ? extends HistoricalNode> mapKeysToNodes(QueryOptions<K, T> options, QueriedPointProcessor<P, K, T> processor, Function<K, QualifiedPath> sourceGetter) Maps query keys to historical nodes, querying for missing nodes as needed.- Type Parameters:
P
- type of temporal pointK
- type of query keyT
- type of temporal point type- Parameters:
options
- the query options containing keys to mapprocessor
- the processor to handle failuressourceGetter
- function to extract source path from query key- Returns:
- map of query keys to their corresponding historical nodes
-
normalizePath
-
isAggregationTypeSupported
-
isComplexTypeSupported
-
lookupNode
-
queryForHistoricalNodes
protected abstract Map<QualifiedPath,? extends HistoricalNode> queryForHistoricalNodes(Set<QualifiedPath> sources, @Nullable @Nullable TimeRange timeRange) -
doQueryRaw
protected abstract Optional<Integer> doQueryRaw(RawQueryOptions options, RawPointProcessor processor) -
doBrowse
-