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 void
cancel()
Cancels the query.void
finish()
protected void
finishInternal(java.lang.Exception ex)
void
finishWithError(java.lang.Exception e)
java.lang.Exception
getError()
java.util.List<PathInfo>
getPathInfo()
Information about the paths queried.boolean
hasNext()
boolean
isCanceled()
boolean
isErrored()
ResultDataPoint
next()
void
onData(java.util.function.Consumer<DataPoint> consumer, java.util.function.BiConsumer<java.lang.Boolean,java.lang.Throwable> onComplete)
void
publish(ResultDataPoint point)
protected void
setPathInfo(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:
isErrored
in interfaceQueryResult
-
getError
public java.lang.Exception getError()
- Specified by:
getError
in interfaceQueryResult
-
getPathInfo
public java.util.List<PathInfo> getPathInfo()
Description copied from interface:QueryResult
Information about the paths queried. Corresponds 1-to-1 with the paths passed in when the query was executed.- Specified by:
getPathInfo
in 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:
hasNext
in interfacejava.util.Iterator<ResultDataPoint>
-
isCanceled
public boolean isCanceled()
- Specified by:
isCanceled
in interfaceResultPublisher
-
next
public ResultDataPoint next()
- Specified by:
next
in 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:
onData
in interfaceQueryResult
-
cancel
public void cancel()
Description copied from interface:QueryResult
Cancels the query. Will call onComplete immediately, and will no longer process values. If takeNext() is blocked, it will throw an interrupted exception.- Specified by:
cancel
in interfaceQueryResult
-
publish
public void publish(ResultDataPoint point)
- Specified by:
publish
in interfaceResultPublisher
-
finishInternal
protected void finishInternal(java.lang.Exception ex)
-
finish
public void finish()
- Specified by:
finish
in interfaceResultPublisher
-
finishWithError
public void finishWithError(java.lang.Exception e)
- Specified by:
finishWithError
in interfaceResultPublisher
-
-