Class AbstractQueryEngine
java.lang.Object
com.inductiveautomation.historian.gateway.api.query.AbstractQueryEngine
- All Implemented Interfaces:
QueryEngine
Base class for query engines. Handles availability and validation checks, quality codes for
unsupported or unavailable operations, logging and metrics, and path normalization; subclasses
implement
doQueryRaw(RawQueryOptions, Set, RawPointProcessor), doBrowse(AdaptedQualifiedPath, BrowseFilter, BrowsePublisher) and queryForHistoricalNodes(Set, TimeRange), and
override doQueryAggregated, doQueryAnnotations and doQueryMetadata for
the query types they support.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final GatewayContextprotected Stringprotected final LoggerExprotected final QueryMetricsprotected final QualifiedPathAdapterprotected final Set<? extends ComplexPointType> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractQueryEngine(GatewayContext gatewayContext, String historianName, LoggerEx logger, QualifiedPathAdapter pathAdapter, Supplier<AvailabilityState> availability) protectedAbstractQueryEngine(GatewayContext gatewayContext, String historianName, LoggerEx logger, QualifiedPathAdapter pathAdapter, Set<? extends ComplexPointType> supportedComplexTypes, Supplier<AvailabilityState> availability) protectedAbstractQueryEngine(GatewayContext gatewayContext, String historianName, LoggerEx logger, Supplier<AvailabilityState> availability) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidbrowse(QualifiedPath root, BrowseFilter filter, BrowsePublisher results) Browses the tree underroot, applyingfilterand passing results topublisher.protected abstract voiddoBrowse(AdaptedQualifiedPath root, BrowseFilter filter, BrowsePublisher results) Runs a browse.doQueryAggregated(AggregatedQueryOptions options, Set<AdaptedQualifiedPath> normalizedPaths, AggregatedPointProcessor processor, NativeQueryContext context) Runs an aggregated query.doQueryAnnotations(AnnotationQueryOptions options, Set<AdaptedQualifiedPath> normalizedPaths, AnnotationPointProcessor processor) Runs an annotation query.protected final <P extends ComplexPoint<?>, K extends ComplexQueryKey<?>>
Optional<Integer> doQueryComplex(ComplexQueryOptions<K> options, ComplexPointProcessor<P, K> processor) doQueryMetadata(MetadataQueryOptions options, Set<AdaptedQualifiedPath> normalizedPaths, MetadataPointProcessor processor) Runs a metadata query.doQueryRaw(RawQueryOptions options, Set<AdaptedQualifiedPath> normalizedPaths, RawPointProcessor processor) Runs a raw query.protected Optional<PropertySet> protected booleanprotected booleanisComplexTypeSupported(ComplexQueryOptions<?> options) protected abstract Optional<? extends HistoricalNode> lookupNode(QualifiedPath source) Optional<? extends HistoricalNode> lookupNode(QualifiedPath source, @Nullable TimeRange range) Resolves a node by the in-memory tag tree first, then byqueryForHistoricalNodes(Set, TimeRange)for nodes deleted from the live tree but still in column metadata.Map<QualifiedPath, ? extends HistoricalNode> lookupNodes(Set<QualifiedPath> sources, @Nullable TimeRange range) Resolves several nodes with the same two-tier lookup aslookupNode(QualifiedPath, TimeRange), using onequeryForHistoricalNodes(Set, TimeRange)round trip for the misses.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 AdaptedQualifiedPathnormalizePath(QualifiedPath path) Normalizes a path to anAdaptedQualifiedPath; idempotent.protected voidonHistorianRename(String oldName, String newName) final voidquery(AggregatedQueryOptions options, AggregatedPointProcessor processor, NativeQueryContext context) Runs an aggregated query, passing the points toprocessor.final <P extends ComplexPoint<?>, K extends ComplexQueryKey<?>>
voidquery(ComplexQueryOptions<K> options, ComplexPointProcessor<P, K> processor) Runs a complex point query, passing the results toprocessor.final voidquery(RawQueryOptions options, RawPointProcessor processor) Runs a raw query, passing the points toprocessor.protected abstract Map<QualifiedPath, ? extends HistoricalNode> queryForHistoricalNodes(Set<QualifiedPath> sources, @Nullable TimeRange timeRange) Reads nodes from the engine's definition store, bypassing the in-memory cachelookupNode(QualifiedPath, TimeRange)uses.protected QualifiedPathreversePath(QualifiedPath path) protected voidMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface QueryEngine
aggregateLattice, boundsInline, capabilities, deliveredValueType, fillsWindowsNatively, nativeAggregates
-
Field Details
-
logger
-
gatewayContext
-
historianName
-
pathAdapter
-
supportedComplexTypes
-
metrics
-
-
Constructor Details
-
AbstractQueryEngine
protected AbstractQueryEngine(GatewayContext gatewayContext, String historianName, LoggerEx logger, Supplier<AvailabilityState> availability) -
AbstractQueryEngine
protected AbstractQueryEngine(GatewayContext gatewayContext, String historianName, LoggerEx logger, QualifiedPathAdapter pathAdapter, Supplier<AvailabilityState> availability) -
AbstractQueryEngine
protected AbstractQueryEngine(GatewayContext gatewayContext, String historianName, LoggerEx logger, QualifiedPathAdapter pathAdapter, Set<? extends ComplexPointType> supportedComplexTypes, Supplier<AvailabilityState> availability)
-
-
Method Details
-
browse
Description copied from interface:QueryEngineBrowses the tree underroot, applyingfilterand passing results topublisher.- Specified by:
browsein interfaceQueryEngine- Parameters:
root- the path to browse from.filter- the criteria for filtering results.results- receives the results.
-
query
Description copied from interface:QueryEngineRuns a raw query, passing the points toprocessor.- Specified by:
queryin interfaceQueryEngine- Parameters:
options- the paths, time range and other query settings.processor- receives the points.
-
query
public final void query(AggregatedQueryOptions options, AggregatedPointProcessor processor, NativeQueryContext context) Description copied from interface:QueryEngineRuns an aggregated query, passing the points toprocessor. Unsupported by default.Each native key arrives with its
EngineDirectiveincontext: gap policy, edges and shape, never the key's interpolation or fill word. For a keyQueryEngine.fillsWindowsNatively(AggregatedQueryKey, EngineDirective)accepts, the engine fills the windows, and the ones it leaves empty stay empty.- Specified by:
queryin interfaceQueryEngine- Parameters:
options- the time window, paths and other query settings.processor- receives the points.context- the pipeline's directives and live post bounds;NativeQueryContext.NONEfor a direct call.
-
query
public final <P extends ComplexPoint<?>, K extends ComplexQueryKey<?>> void query(ComplexQueryOptions<K> options, ComplexPointProcessor<P, K> processor) Description copied from interface:QueryEngineRuns a complex point query, passing the results toprocessor. Unsupported by default.- Specified by:
queryin interfaceQueryEngine- Type Parameters:
P- the complex point type.K- the complex query key type.- Parameters:
options- the query settings.processor- receives the results.
-
lookupNode
public Optional<? extends HistoricalNode> lookupNode(QualifiedPath source, @Nullable TimeRange range) Resolves a node by the in-memory tag tree first, then byqueryForHistoricalNodes(Set, TimeRange)for nodes deleted from the live tree but still in column metadata. The range is consulted only on the slow path; the fast path returns the version the tree holds. Engines with multiple versions per source, such as viaHistoricalNodeVersionList, may override to use the range.- Specified by:
lookupNodein interfaceQueryEngine- Parameters:
source- the source path; never null.range- the query's time range; may be null.- Returns:
- the node, or empty if the engine has no record of
source.
-
lookupNodes
public Map<QualifiedPath, ? extends HistoricalNode> lookupNodes(Set<QualifiedPath> sources, @Nullable TimeRange range) Resolves several nodes with the same two-tier lookup aslookupNode(QualifiedPath, TimeRange), using onequeryForHistoricalNodes(Set, TimeRange)round trip for the misses. The result is keyed by each caller's ownQualifiedPathinstance.- Specified by:
lookupNodesin interfaceQueryEngine- Parameters:
sources- the source paths to resolve; never null.range- the query's time range, to pick among node versions; may be null.- Returns:
- an unmodifiable map keyed by the caller's
QualifiedPathinstances; unmatched sources are absent, never mapped to null.
-
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, Set<AdaptedQualifiedPath> normalizedPaths, AnnotationPointProcessor processor) Runs an annotation query.- Parameters:
normalizedPaths- the annotation identifier paths, already normalized.
-
doQueryMetadata
protected Optional<Integer> doQueryMetadata(MetadataQueryOptions options, Set<AdaptedQualifiedPath> normalizedPaths, MetadataPointProcessor processor) Runs a metadata query.- Parameters:
normalizedPaths- the metadata identifier paths, already normalized.
-
doQueryAggregated
protected Optional<Integer> doQueryAggregated(AggregatedQueryOptions options, Set<AdaptedQualifiedPath> normalizedPaths, AggregatedPointProcessor processor, NativeQueryContext context) Runs an aggregated query.- Parameters:
normalizedPaths- the query source paths, already normalized.context- the pipeline's directives and live post bounds for the keys.
-
mapKeysToNodes
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.- Type Parameters:
P- the point type.K- the query key type.T- the point type kind.- Parameters:
options- the query options containing the keys.processor- handles failures.sourceGetter- extracts the source path from a key.- Returns:
- the nodes by query key.
-
getProcessorProperties
-
normalizePath
Normalizes a path to anAdaptedQualifiedPath; idempotent. -
reversePath
-
isAggregationTypeSupported
-
isComplexTypeSupported
-
onHistorianRename
-
shutdownQueryMetrics
protected void shutdownQueryMetrics() -
lookupNode
-
queryForHistoricalNodes
protected abstract Map<QualifiedPath, ? extends HistoricalNode> queryForHistoricalNodes(Set<QualifiedPath> sources, @Nullable TimeRange timeRange) Reads nodes from the engine's definition store, bypassing the in-memory cachelookupNode(QualifiedPath, TimeRange)uses.- Parameters:
sources- the source paths, already normalized bynormalizePath(QualifiedPath).timeRange- the range a node must have been active within, ornullfor the latest node of each source.- Returns:
- the nodes found, keyed by each node's stored source path, which may differ in case from the request; a source with no node is absent.
-
doQueryRaw
protected abstract Optional<Integer> doQueryRaw(RawQueryOptions options, Set<AdaptedQualifiedPath> normalizedPaths, RawPointProcessor processor) Runs a raw query.- Parameters:
normalizedPaths- the query source paths, already normalized.
-
doBrowse
protected abstract void doBrowse(AdaptedQualifiedPath root, BrowseFilter filter, BrowsePublisher results) Runs a browse.- Parameters:
root- the browse root, already normalized.
-