Class AggregateHistoryQueryExecutor
- java.lang.Object
-
- com.inductiveautomation.ignition.gateway.sqltags.history.query.AggregateHistoryQueryExecutor
-
- All Implemented Interfaces:
HistoryQueryExecutor
,java.util.Comparator<HistoryQueryExecutor>
public class AggregateHistoryQueryExecutor extends java.lang.Object implements HistoryQueryExecutor, java.util.Comparator<HistoryQueryExecutor>
-
-
Constructor Summary
Constructors Constructor Description AggregateHistoryQueryExecutor(java.util.Collection<? extends HistoryQueryExecutor> allLoaders, java.util.List<HistoryNode> nodes, java.lang.Runnable onFinish)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(HistoryQueryExecutor o1, HistoryQueryExecutor o2)
static HistoryQueryExecutor
create(java.util.List<HistoryQueryExecutor> executors, java.util.List<HistoryNode> nodes)
Convenience function that will create an aggregate executor if necessary, or return the single passed in executor if the list size is 1.static HistoryQueryExecutor
create(java.util.List<HistoryQueryExecutor> executors, java.util.List<HistoryNode> nodes, java.lang.Runnable onFinish)
protected HistoryQueryExecutor
current()
void
endReading()
If startReading was called, this function must be called (that is, it should be in a finally block).java.util.List<? extends HistoryNode>
getColumnNodes()
Returns the HistoryNodes of this executor.int
getEffectiveWindowSizeMS()
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
initialize()
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
processData()
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
startReading()
Begins reading data.
-
-
-
Constructor Detail
-
AggregateHistoryQueryExecutor
public AggregateHistoryQueryExecutor(java.util.Collection<? extends HistoryQueryExecutor> allLoaders, java.util.List<HistoryNode> nodes, java.lang.Runnable onFinish)
-
-
Method Detail
-
create
public static HistoryQueryExecutor create(java.util.List<HistoryQueryExecutor> executors, java.util.List<HistoryNode> 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.
-
create
public static HistoryQueryExecutor create(java.util.List<HistoryQueryExecutor> executors, java.util.List<HistoryNode> nodes, java.lang.Runnable onFinish)
-
current
protected HistoryQueryExecutor current()
-
getColumnNodes
public java.util.List<? extends HistoryNode> 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 returnDelegatingHistoryNode
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
public void initialize() throws java.lang.Exception
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:
java.lang.Exception
-
startReading
public void startReading() throws java.lang.Exception
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:
java.lang.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
public long processData() throws java.lang.Exception
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:
java.lang.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
public int compare(HistoryQueryExecutor o1, HistoryQueryExecutor o2)
- Specified by:
compare
in interfacejava.util.Comparator<HistoryQueryExecutor>
-
-