Class BasicQueryResult
- java.lang.Object
-
- com.inductiveautomation.gateway.tsdb.impl.BasicQueryResult
-
- All Implemented Interfaces:
QueryResult,ResultPublisher,java.util.Iterator<ResultDataPoint>
- Direct Known Subclasses:
BasicSyncQueryResults,FixedDailyDataHistorian.DataPump,SQLiteHistorian.Query
public class BasicQueryResult extends java.lang.Object implements QueryResult, ResultPublisher
A basic implementation of QueryResult that can be used to publish data. To use this class, simply call publish() until data is complete and while hasNext==true, and then call publishDone(). If the query is cancelled, it will be reflected in hasMore being false before publishDone is called. Therefore care should be taken to not block forever, but to regularly check for this condition while waiting for data.
-
-
Constructor Summary
Constructors Constructor Description BasicQueryResult()If this constructor is used, setPathInfo must be called later.BasicQueryResult(java.util.List<PathInfo> pathInfos)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()Cancels the query.voidfinish()protected voidfinishInternal(java.lang.Exception ex)voidfinishWithError(java.lang.Exception e)java.lang.ExceptiongetError()java.util.List<PathInfo>getPathInfo()Information about the paths queried.booleanhasNext()booleanisCanceled()booleanisErrored()ResultDataPointnext()voidonData(java.util.function.Consumer<DataPoint> consumer, java.util.function.BiConsumer<java.lang.Boolean,java.lang.Throwable> onComplete)voidpublish(ResultDataPoint point)protected voidsetPathInfo(java.util.List<PathInfo> pathInfo)Sets the path info and releases the lock on getPathInfos.
-
-
-
Constructor Detail
-
BasicQueryResult
public BasicQueryResult()
If this constructor is used, setPathInfo must be called later. No results will be processed until path info is set.
-
BasicQueryResult
public BasicQueryResult(java.util.List<PathInfo> pathInfos)
-
-
Method Detail
-
isErrored
public boolean isErrored()
- Specified by:
isErroredin interfaceQueryResult
-
getError
public java.lang.Exception getError()
- Specified by:
getErrorin interfaceQueryResult
-
getPathInfo
public java.util.List<PathInfo> getPathInfo()
Description copied from interface:QueryResultInformation about the paths queried. Corresponds 1-to-1 with the paths passed in when the query was executed.- Specified by:
getPathInfoin interfaceQueryResult
-
setPathInfo
protected void setPathInfo(java.util.List<PathInfo> pathInfo)
Sets the path info and releases the lock on getPathInfos.
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<ResultDataPoint>
-
isCanceled
public boolean isCanceled()
- Specified by:
isCanceledin interfaceResultPublisher
-
next
public ResultDataPoint next()
- Specified by:
nextin interfacejava.util.Iterator<ResultDataPoint>
-
onData
public void onData(java.util.function.Consumer<DataPoint> consumer, java.util.function.BiConsumer<java.lang.Boolean,java.lang.Throwable> onComplete)
- Specified by:
onDatain interfaceQueryResult
-
cancel
public void cancel()
Description copied from interface:QueryResultCancels the query. Will call onComplete immediately, and will no longer process values. If takeNext() is blocked, it will throw an interrupted exception.- Specified by:
cancelin interfaceQueryResult
-
publish
public void publish(ResultDataPoint point)
- Specified by:
publishin interfaceResultPublisher
-
finishInternal
protected void finishInternal(java.lang.Exception ex)
-
finish
public void finish()
- Specified by:
finishin interfaceResultPublisher
-
finishWithError
public void finishWithError(java.lang.Exception e)
- Specified by:
finishWithErrorin interfaceResultPublisher
-
-