· Mar 15, 2020

Able to create expression in Globals ?


   I  like to validate some use cases and have the following question. I am relatively new to IRIS. Perhaps someone can help:

   1. I have a global m[x,y,z,f] distributed across multiple sharded instances
   2. I know that i can set assign computed SQL expressions to class variables using Objectscript 
   3. Is there a possibility in Globals API to do the same ? Set f = x + y as a computed expression in the global  m[x,y,z,f]  ?

       a.  We would want to use the global API to change f programmatically using code

       b.  the change in the expression would be distributed across all sharded instances 

       c. f changes whenever x or  y changes

   I didn't find anything in the documentation.

   Thank you

Discussion (5)0
Log in or sign up to continue


Can you elaborate on your high-level use case:

  1. What data are you storing?
  2. What do you want to calculate?

Any particular reason you  decided to use globals instead of tables/classes? Article on how globals/tables/classes interact.

In general your task can be solved in two mainstream and one additional way:

  1. Store f. Every time a data point is inserted/updated we calculate and store f(datapoint). Advantage: fast querying and savings on CPU cycles as the calculation work is only performed once. Disadvantage: changing f requires recalculation and time, storage.
  2. Calculate f. Every time data point is accessed we calculate f. Advantage: zero costs to change f, we immediately get new results. No storage required. Disadvantage: potentially CPU intensive load.

Additionally if you need to just check a condition (i.e. that f>0) you may not need an f value as by applying functional analysis, you can solve the issue analytically if f is a continuous function.