Buffered Access (buffer mode)
Buffered access provides fast access especially in client server mode. While reading 10 000 instances per second on a local machine is no problem, sending 10 000 packages via the network may take several minutes. Using buffered access will reduce the number of packages sent between client and server and thus, reduce the communication time extremely.
In order to activate buffered access, changeBuffer() needs to be called. In order to deactivate buffer mode, one may call releaseBuffer() or changeBuffer() with buffer size 0 or 1.
Buffered access can be used for reading collections with fixed data type, only. Trying to enable buffered access for untyped or weak-typed collections will fail without writing an error to the error log file.
When a filter has been defined for the property handle only those instances are read into buffer that fulfill the filter condition.
Usually the buffer is filled automatically when attempting to reading an instance that is not yet in buffer. The system tries to read as many instances as defined in buffer size from the current position. Subsequent get() request will read from the buffer as long as possible. In order to empty the current buffer cancelBuffer() can be called. cancel() will cancel the current selection in the property handle but not the instances in the buffer.
To position the buffer on a certain instance you can use the readBuffer() function. For resetting the buffer you can use the cancelBuffer() function.
You cannot use block mode for views containing references. In this case the function will ignore the request and buffer size remains 1. There are also problems in client/server mode when referring to sub property handles for references in instances that have been reading in block mode. Moreover, updating instances read in block mode is not allowed.
In many cases, only a subset of instances in a collection is displayed in the application. In such cases it is more efficient to read only the instances displayed. Reading them in block mode will not only reduce the access time but also reserve the instances for the client.
When reading instances in block mode all instances in a block are registered as being used by the property handle. Thus, the property handle will be notified when one of the instances in a buffer has been updated. In an ADL application, the application can react on this notification and, e.g. redisplay the line or list that has been updated
You can activate the block mode simply by setting a buffer size. The number of buffers allocated might be smaller than requested. For optimization reasons the maximum block size can be restricted in client/server mode on the server side by the server option "MAX_BUFFER_SIZE".
When terminating a function or process, which has enabled the buffer mode, it should reset the buffer mode by calling changeBuffer(1) .
... :: function ( Property &persons ) {
person.changeBuffer(50);
// processing ...
// reset buffer in order to re-read instances
person.cancelBuffer(1);
// processing ...
// reset buffered read
person.changeBuffer(1);
}
Block mode can be set for instances opened in read mode, only. For updating instances selected from a list a copy property can be used, which is opened in write mode.
When using block mode, read events for instances as well as for properties are generated when filling the buffer. When selecting an instance from the buffer into the handle, a read event for the property handle is generated once more. In order to check, whether the read event has already been executes the DateState can be checked in the read event handler (see DBO_Read event).