Discrete Values & Bucketizing

13 views
Skip to first unread message

Steven Harding

unread,
Feb 17, 2020, 12:10:38 AM2/17/20
to Warp 10 users
Another quick one - I'm historising a number of values, some of which are continuous (floating point values that can comfortably interpolated according to time) and some of which are discrete (integer values that should not be interpolated according to time).

When I'm producing a bucketized history for reporting purposes, I'd like an AVERAGE of my continuous points, but averages for the discrete points don't make sense - ie. if 0 is red and 1 is green, what on earth does 0.5 mean? As such, it's best to take either a MEDIAN or a MAX of discrete points.

I've now added a 'type' level to my channels, so I can mark them as continuous or discrete - I can then in theory call FETCH twice on the two different labels, using AVG on the continuous and MEDIAN on the discrete. But I was curious if there was any other trick to bucketizing that can handle this sort of logic automatically for me and treat floating point numbers differently to integers, without having to make two distinct queries? 

Pierre

unread,
Feb 17, 2020, 5:04:51 AM2/17/20
to Warp 10 users
- You can write your own bucketizer with MACROBUCKETIZER, but it will be painfull, and less performant than native ones, because you will have to test data type for each data in each bucket.
- If you have a big database, and enough RAM, do not FETCH twice (it will take more time). FETCH once, then filter data to keep only one type, and bucketize the result differently as you already do.
eg : 
[ xx ] FETCH 'all' STORE    
$all <% VALUES 0 GET TYPEOF "DOUBLE" == %> FILTERBY 'continuousGTS' STORE

Reply all
Reply to author
Forward
0 new messages