Skip to content

Commit 00a929f

Browse files
committed
Break out intervals to separate upd/timers
1 parent b8b5ebe commit 00a929f

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

code/common/datareplay.q

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ getBuckets:{[s;e;p](s+p*til(ceiling 1+e%p)-(ceiling s%p))}
66
// params[`t] is table data
77
// params[`tc] is time column to cut on
88
// params[`tn] is table name
9-
// params[`interval] is the time interval to bucket the messages into.
9+
// params[`timerinterval] is the timer time interval to bucket the messages into.
10+
// params[`datainterval] is the data time interval to bucket the messages into.
1011
tableDataToDataStream:{[params]
12+
.dbg.params:params;
1113
// Sort table by time column.
1214
params[`t]:params[`tc] xasc delete date from params[`t];
1315

1416
// get all times from table
1517
t_times:params[`t][params[`tc]];
1618

17-
$[not null params[`interval];
19+
$[not null params[`datainterval];
1820
[ // if there is an interval, bucket messages into this interval
19-
// make bukets of ten second intervals
20-
times:getBuckets[params[`sts];params[`ets];params[`interval]];
21+
// make buckets of ten second intervals
22+
times:getBuckets[params[`sts];params[`ets];params[`datainterval]];
2123

2224
// put start time in fornt of t_times
2325
t_times:params[`sts],t_times;
@@ -38,7 +40,7 @@ tableDataToDataStream:{[params]
3840
// Return table of times and message chunks
3941
-1_([]time:time;msg:{(`upd;x;y)}[params[`tn]] each msgs)
4042
];
41-
// if there is no intevral, cut by distinct time.
43+
// if there is no interval, cut by distinct time.
4244
([]
4345
time:distinct t_times;
4446
msg:{(`upd;x;$[1<count y;flip y;first y])}[params[`tn]] each
@@ -74,10 +76,10 @@ tableToDataStream:{[params]
7476

7577
// params[`sts] is start of time window to get
7678
// params[`ets] is end of time window to get
77-
// params[`tp] is the inrement between times
79+
// params[`tp] is the increment between times
7880
// params[`timerfunc] is the timer function to use
7981
getTimers:{[params]
80-
times:getBuckets[params[`sts];params[`ets];params[`interval]];
82+
times:getBuckets[params[`sts];params[`ets];params[`replayinterval]];
8183
([]time:times;msg:params[`timerfunc],'times)
8284
}
8385

@@ -86,24 +88,25 @@ getTimers:{[params]
8688
// params[`sts] is start of time window to get - Required
8789
// params[`ets] is end of time window to get - Required
8890
// params[`syms] is list of instruments to get - Default all syms
89-
// params[`where] is an additional where clause in functional form - Not Reuqired
91+
// params[`where] is an additional where clause in functional form - Not Required
9092
// params[`timer] is whether or not to retrieve timer - Default 0b
9193
// params[`h] is handle to hdb - Default 0 (self)
92-
// params[`interval] is the time interval to bucket the messages into. - Not Required
94+
// params[`timerinterval] is the time interval to bucket the timer messages into. - Not Required
95+
// params[`datainterval] is the time interval to bucket the upd messages into. - Not Required
9396
// prarms[`tc] is the time column of the tables specified - Defualt `time
9497
// params[`timerfunc] is the timer function to use in timer messages - Default `.z.ts
9598
tablesToDataStream:{[params]
96-
defaults:`timer`h`syms`interval`tc`timerfunc`where!(0b;0;`symbol$();`timespan$0n;`time;`.z.ts;());
99+
defaults:`timer`h`syms`datainterval`replayinterval`tc`timerfunc`where!(0b;0;`symbol$();`timespan$0n;`timespan$0n;`time;`.z.ts;());
97100
params:defaults,params;
98101

99102
// check for default parameters `tabs`sts`ets
100-
if[count missing:`tabs`sts`ets except key params;'"mising prameters: "," " sv string missing;];
103+
if[count missing:`tabs`sts`ets except key params;'"missing parameters: "," " sv string missing;];
101104
params[`tabs]:(),params[`tabs];
102105

103106
ds:raze {tableToDataStream x,(enlist `tn)!enlist y}[params] each params[`tabs];
104-
107+
105108
$[params[`timer];
106-
`time xasc ds,getTimers[params,enlist[`interval]! enlist $[null k:params[`interval];0D00:00:10.00;k]];
109+
`time xasc ds,getTimers[params,enlist[`timerinterval]! enlist $[null k:params[`timerinterval];0D00:00:10.00;k]];
107110
`time xasc ds]
108111
};
109112

0 commit comments

Comments
 (0)