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 TypeMethodDescriptionintstatic HistoryQueryExecutorcreate(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 HistoryQueryExecutorcurrent()voidIf 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.intIn this context, returns the minimum of the sub-loaders rates.booleanhasMore()Returns TRUE if there is more data available to be written on call to processData()voidInitializes the query, performing any actions necessary to get the information required to run the query.longnextTime()The timestamp of the next value.longPuts the next value(s) into the appropriate column, returning the latest timestamp loaded, or -1 if no data was loaded.protected voidsort()This ensures the the next loader to read from is in the head spot.voidBegins reading data.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:HistoryQueryExecutorReturns 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 returnDelegatingResultNodes, which get filled in later.- Specified by:
getColumnNodesin interfaceHistoryQueryExecutor
-
getEffectiveWindowSizeMS
public int getEffectiveWindowSizeMS()In this context, returns the minimum of the sub-loaders rates.- Specified by:
getEffectiveWindowSizeMSin interfaceHistoryQueryExecutor
-
initialize
Description copied from interface:HistoryQueryExecutorInitializes the query, performing any actions necessary to get the information required to run the query.- Specified by:
initializein interfaceHistoryQueryExecutor- Throws:
Exception
-
startReading
Description copied from interface:HistoryQueryExecutorBegins reading data. IMPORTANT: endReading should always be called at some point after calling startReading.- Specified by:
startReadingin interfaceHistoryQueryExecutor- Throws:
Exception
-
endReading
public void endReading()Description copied from interface:HistoryQueryExecutorIf startReading was called, this function must be called (that is, it should be in a finally block).- Specified by:
endReadingin interfaceHistoryQueryExecutor
-
hasMore
public boolean hasMore()Description copied from interface:HistoryQueryExecutorReturns TRUE if there is more data available to be written on call to processData()- Specified by:
hasMorein interfaceHistoryQueryExecutor
-
processData
Description copied from interface:HistoryQueryExecutorPuts the next value(s) into the appropriate column, returning the latest timestamp loaded, or -1 if no data was loaded.- Specified by:
processDatain interfaceHistoryQueryExecutor- Throws:
Exception
-
nextTime
public long nextTime()Description copied from interface:HistoryQueryExecutorThe timestamp of the next value. -1 if no value is available.- Specified by:
nextTimein 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:
comparein interfaceComparator<HistoryQueryExecutor>
-