User's Reference - GetGlobal

### GetGlobal

Category

Flow Control

Function

Retrieves an object from the cache. State is maintained between executions of any macros containing GetGlobal.

Syntax

`object, link` = GetGlobal(`object, reset`);

Inputs

Name | Type | Default | Description
--- | --- | --- | ---
`object` | object | none | object to be output if nothing has been set
`reset` | flag | 0 | 0: the object cached by SetGlobal (if there is one) is passed to output 1: `object` (not the cached object) is passed to output.

Outputs

Name | Type | Description
--- | --- | ---
`object` | object | retrieved object
`link` | string | link to corresponding SetGlobal module

Functional Details

GetGlobal works with SetGlobal to place objects in and retrieve them from the cache. GetGlobal is equivalent to (and replaces) Get in previous versions of Data Explorer. GetGlobal differs from GetLocal in that GetLocal and SetLocal are used when the state maintained by the Get/Set pair should be reset when a macro containing these modules is reexecuted. In contrast, GetGlobal and SetGlobal will maintain state when the macro is reexecuted. Note that for a single execution of a macro (for example, throughout the execution of an entire loop), state is of course maintained by both GetLocal and GetGlobal.

`object` | specifies the object to be output by GetGlobal if nothing has been placed in the cache (e.g., as on the first execution of a visual program) or if `reset` = 1.
`reset` | causes the module to output `object`. If this parameter is set to 0 (zero), GetGlobal retrieves the last object placed in the cache by SetGlobal (if there is one). Otherwise, the module passes `object` to the output.

The `link` output is to be connected to the `link` input of the corresponding SetGlobal module. GetGlobal must be used with SetGlobal, rather than with SetLocal. SetGlobal must be executed on the same machine as GetGlobal (i.e., it cannot be distributed to a different machine).

Notes:

1. The Reset interactor can be used to provide `reset`. However, if you are using GetGlobal and SetGlobal in a loop, you should not use the Reset interactor to provide this parameter, because the Reset interactor will output the reset value for one execution, which is an entire execution of the loop. In general, there are performance advantages to using GetLocal, rather than GetGlobal with the First module supplying the `reset` parameter. While the result will be the same, using GetLocal will ensure that all previous results of the macro will be cached and ready for reuse. If you use GetGlobal, only the last result of the macro is cached.

2. Whenever there is a GetGlobal inside a macro, all outputs of the macro will be stored in the cache with the cache attribute "cache last". In other words, whenever any input to the macro changes, the old results of the macro will be deleted from the cache and the new results will be stored in the cache. There is no way for the user to turn off caching for this macro. The results are also locked in the cache, and cannot be flushed. This is because GetGlobal maintains state for the macro that may not be reproduced given the inputs to the macro. Inconsistent behavior might result if results were not cached in this way.

3. Previously created visual programs which use Get and Set will be run using GetGlobal and SetGlobal. You can explicitly change your Gets and Sets to either GetGlobals and SetGlobals or GetLocals and SetLocals using the Edit menu (see Assign Get/Set Scope in IBM Visualization Data Explorer User's Guide). There are performance advantages to using GetLocal and SetLocal whenever you do not need to maintain state between executions of your macro which uses Gets and Sets. A rule of thumb is that if you are using the First module to supply the reset parameter of Get, you should use GetLocal instead of GetGlobal (and the use of First is then unnecessary).

A detailed description of the behavior and use of the GetLocal, GetGlobal, SetLocal, and SetGlobal modules can be found in 4.6 , "Preserving Explicit State" in IBM Visualization Data Explorer User's Guide.

Example Visual Programs

    SIMPLE/GetSet.net

See Also

Done, First, SetGlobal, GetLocal, SetLocal, Reset

Chapter 4. "Data Explorer Execution Model" in IBM Visualization Data Explorer User's Guide.

[ OpenDX Home at IBM | OpenDX.org ]