Class AggregateHistoryQueryExecutor
java.lang.Object
com.inductiveautomation.historian.gateway.query.execution.AggregateHistoryQueryExecutor
- All Implemented Interfaces:
HistoryQueryExecutor
,Comparator<HistoryQueryExecutor>
public class AggregateHistoryQueryExecutor
extends Object
implements HistoryQueryExecutor, Comparator<HistoryQueryExecutor>
This class is an aggregate history query executor. It will take a list of history query executors, and execute them
in order. It will always execute the one with the lowest timestamp first. If two executors have the same timestamp,
the one that has more data will be executed first.
This class is useful for combining multiple history queries into one, and ensuring that the data is returned in the
correct order. This is used to combine the history queries for the different providers into one query.
-
Constructor Summary
ConstructorsConstructorDescriptionAggregateHistoryQueryExecutor
(Collection<? extends HistoryQueryExecutor> allLoaders, List<ResultNode> nodes) -
Method Summary
Modifier and TypeMethodDescriptionint
static HistoryQueryExecutor
create
(List<HistoryQueryExecutor> executors, List<ResultNode> nodes) Convenience function that will create an aggregate executor if necessary, or return the single passed in executor if the list size is 1.protected HistoryQueryExecutor
current()
void
If startReading was called, this function must be called (that is, it should be in a finally block).List<? extends ResultNode>
Returns the HistoryNodes of this executor.int
In this context, returns the minimum of the sub-loaders rates.boolean
hasMore()
Returns TRUE if there is more data available to be written on call to processData()void
Initializes the query, performing any actions necessary to get the information required to run the query.long
nextTime()
The timestamp of the next value.long
Puts the next value(s) into the appropriate column, returning the latest timestamp loaded, or -1 if no data was loaded.protected void
sort()
This ensures the the next loader to read from is in the head spot.void
Begins reading data.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
AggregateHistoryQueryExecutor
public AggregateHistoryQueryExecutor(Collection<? extends HistoryQueryExecutor> allLoaders, List<ResultNode> nodes)
-
-
Method Details
-
create
public static HistoryQueryExecutor create(List<HistoryQueryExecutor> executors, List<ResultNode> nodes) Convenience function that will create an aggregate executor if necessary, or return the single passed in executor if the list size is 1. Since we must maintain the order of the history nodes, the sorted list must be passed in as well. -
current
-
getColumnNodes
Description copied from interface:HistoryQueryExecutor
Returns the HistoryNodes of this executor. There MUST be one for every tag path, and they must be in the same order as the paths provided to the executor when it was created. Also, these values must be available as soon as the executor is created. However, they won't be consulted for their data type until after initialize is called, so the normal procedure is to create and returnDelegatingResultNode
s, which get filled in later.- Specified by:
getColumnNodes
in interfaceHistoryQueryExecutor
-
getEffectiveWindowSizeMS
public int getEffectiveWindowSizeMS()In this context, returns the minimum of the sub-loaders rates.- Specified by:
getEffectiveWindowSizeMS
in interfaceHistoryQueryExecutor
-
initialize
Description copied from interface:HistoryQueryExecutor
Initializes the query, performing any actions necessary to get the information required to run the query.- Specified by:
initialize
in interfaceHistoryQueryExecutor
- Throws:
Exception
-
startReading
Description copied from interface:HistoryQueryExecutor
Begins reading data. IMPORTANT: endReading should always be called at some point after calling startReading.- Specified by:
startReading
in interfaceHistoryQueryExecutor
- Throws:
Exception
-
endReading
public void endReading()Description copied from interface:HistoryQueryExecutor
If startReading was called, this function must be called (that is, it should be in a finally block).- Specified by:
endReading
in interfaceHistoryQueryExecutor
-
hasMore
public boolean hasMore()Description copied from interface:HistoryQueryExecutor
Returns TRUE if there is more data available to be written on call to processData()- Specified by:
hasMore
in interfaceHistoryQueryExecutor
-
processData
Description copied from interface:HistoryQueryExecutor
Puts the next value(s) into the appropriate column, returning the latest timestamp loaded, or -1 if no data was loaded.- Specified by:
processData
in interfaceHistoryQueryExecutor
- Throws:
Exception
-
nextTime
public long nextTime()Description copied from interface:HistoryQueryExecutor
The timestamp of the next value. -1 if no value is available.- Specified by:
nextTime
in interfaceHistoryQueryExecutor
-
sort
protected void sort()This ensures the the next loader to read from is in the head spot. It's also relatively inefficient right now. All we really need to do is push the head down until its ts > elem.timestamp -
compare
- Specified by:
compare
in interfaceComparator<HistoryQueryExecutor>
-