next up previous index
Next: Computing Variables Up: Datasets Previous: Initialization   Index


Loading Attributes

Primary attributes are read lazily, i.e. they are loaded from the input storage as they are needed, for example when they are required by a model or by a variable definition. The loading can be also explicitly invoked by the method load_dataset() which by default loads all attributes found on the data storage. An optional argument attributes can be passed which is a list of attributes to be loaded.

Alternatively, the method get_attribute(name) invokes the specified attribute to be loaded into memory if it has not been done before and returns an array of values for this attribute. Note that when using a slow storage, such as MySQL, loading several attributes at once using load_dataset() (as opposed to one by one using get_attribute()) might be more time efficient.

Loaded or computed dataset attributes can be flushed into a simulation cache to save memory (using method flush_attribute(name) for a specific attribute or flush_dataset() for the whole dataset). Opus uses an FLT storage for the simulation cache (see Section 7.3.4) which deals with reading and writing data in a very efficient way. Thus, when using a slow storage, it might be of an advantage to load the whole dataset at the beginning of the dataset usage and flush all attributes. Then any subsequent load will be performed on the fast cache.


next up previous index
Next: Computing Variables Up: Datasets Previous: Initialization   Index
info (at) urbansim.org