peekAppend

Syntax

peekAppend(engine, data)

Details

Peeks at the immediate calculation result of adding the specified data to the engine's current state without updating the stream engine state or writing results to the outputTable. Currently only supports partial operators of TimeSeriesEngine and ReactiveStateEngine, as follows:

TimeSeriesEngine: keyColumn is set and useSystemTime, acceptedDelay and forceTriggerTime are not set.

ReactiveStateEngine: cumavg, cumsum, cumstd, cumstdp, cumvar, cumvarp, cumprod, cumcount, mcount, msum, mavg, mstd, mstdp, mvar, mvarp, as well as stateless operators (expressions, stateless functions, etc.).

Parameters

engine A stream engine.

data A table or tuple representing the data to be written to the stream engine.

Returns

A table displaying the calculation result of adding data to the engine's current state. The engine state will not be updated, and no results will be output to the outputTable.

Examples

For ReactiveStateEngine:

share streamTable(100:0, `sym`time`price, [STRING,DATETIME,DOUBLE]) as tickStream
share streamTable(1000:0, `sym`time`factor1, [STRING,DATETIME,DOUBLE]) as result
rse = createReactiveStateEngine(name="reactiveDemo", metrics =[<time>, <cumsum(price)>], dummyTable=tickStream, outputTable=result, keyColumn="sym")
data = table(take(["000001.SH","000002.SH","000003.SH"], 3) as sym, take(2021.02.08T09:31:00 + 1..3, 3) as time, take(100.0, 3) as price)
res = rse.peekAppend(data)
rse.append!(data)
share streamTable(100:0, `sym`time`price, [STRING,DATETIME,DOUBLE]) as tickStream
share streamTable(1000:0, `sym`time`factor1, [STRING,DATETIME,DOUBLE]) as result
rse = createReactiveStateEngine(name="reactiveDemo", metrics =[<time>, <cumsum(price)>], dummyTable=tickStream, outputTable=result, keyColumn="sym")

data = table(take(["000001.SH"], 3) as sym, take(2021.02.08T09:31:00 + 1..3, 3) as time, 100 200 300 as price)
res2 = rse.peekAppend(data)

For TimeSeriesEngine:

share streamTable(1000:0, `sym`time`volume, [STRING,DATETIME,INT]) as tickStream
share streamTable(1000:0, `time`sym`sumVolume, [DATETIME,STRING,INT]) as result
tse = createTimeSeriesEngine(name="tse", windowSize=60, step=60, metrics=<[sum(volume)]>, dummyTable=tickStream, outputTable=result, timeColumn="time", useSystemTime=false, keyColumn="sym")

insert into tse values([`"000001.SH", 2021.02.08T09:30:00, 100])
data = table(take(["000001.SH"], 3) as sym, take(2021.02.08T09:30:00 + 1..3, 3) as time, 100 200 300 as price)
res = tse.peekAppend(data)