...
This means, it is possible to store or cache events without using the blocking window operator. First of all, this is useful for slowly changing events (like states in a smart home or in a factory), because in a window-operator you have to wait until the state changes a second time before the first change gets available. Therefore, the context store is a special concept to avoid such a blocking behavior. For each context event (each state), there is a context store needed. This means, for example, that there is one context store for each door in a smart home. After creating a context store, the system can use the store-operator to write into the store and can use the enrich-operator to read from the store. Furthermore, there is a RCP-view to show the actual content of the context sotrestore. All these parts works work as follows.
Context Store - create and drop
Creating and removing of context stores is done by a Continuous Query Language (CQL)-Statement. To create a new store, you may use the following statement (which is similar to the create stream statement):
...
To specify the enrich operator, you can use the simplest form in Procedural Query Language (PQL):
enriching = CONTEXTENRICH({store = 'door5'}, inputoperator)
...
Code Block | ||
---|---|---|
| ||
out = MAP({Expressions=["elementAt(ContextStore('door5'),0)","input.x"],input} |
Remark: The ContextStore functions delivers a tuple in this case and elementAt reads the attribute from the tuple. Else the whole tuple will be added.
View - show the context of stores
...