Overload technologies
Overloading object spaces means overloading instances and extending or overloading local and global collections, i.e. two different strategies depending on property definitions and option settings apply on collections:
- Extending collections
- Overloading collections
When extending collections, instances from collections in all involved object spaces are merged without duplicates (distinct union). Instances from top object space have highest priority. Overloading collections is based on unique keys, i.e. the collection must have at least one unique key (not necessarily a unique order), which is not an __IDENTITY (LOID) key.
Collections with a limited number of instances (typically singular collections) are extended up to the maximum number of instances allowed for the collection. For singular collections, this is the same as overloading the collection.
Overloading collections means that the collection of a located instance completely replaces collections in overloaded object spaces. This also includes empty collections. Unidentified collections are always overloaded.
Whether collections are extended or overloaded depends on schema definition for the database. Extending collections is used for public extents, references and relationships. All other collections are overloaded.
In order to overload object spaces explicitly, ObjectSpace::overloadObjectSpace() has to be called, which allows overloading any object space (database) with the object space passed as parameter. The object space passed to the function becomes the object space on top of the list, i.e. the object space with highest priority and which is checked first.
Using data sources for opening a database (DataSource::openDatabase()) automatically overloads databases (root object spaces) when passing more than one database path separated by ; as database location. This not only allows overloading resource databases but any kind of database used in an application.
In case of overloading databases in a data source, only the top database is opened with required access mode. All subordinated databases are opened read-only.
; concatenating databases in a data source definition
DATABASE=MyResources.dev;%ODABA_ROOT%/ode.dev
When an object space hierarchy has been defined in a database, an object space may overload all its parent object spaces implicitly by calling ObjectSpace::overload(true). In this case, collections are merged from bottom to top in the object space hierarchy, i.e. the object space marked as overload object space has got highest priority.
The overload priority is reverse to the object space hierarchy, i.e. subordinated object spaces in the object space hierarchy get higher priority in an overload hierarchy than parent object spaces.
In order to disable object space overloading, ObjectSpace::overload(false) has to be called for an implicitly or explicitly overloaded object space. For explicitly overloaded object spaces this will not disconnect object spaces, but disable the overload feature, only.
In general, property handles opened with an overloaded object space are still acting as merged collections. For accessing not overloaded collections, property handles have to be re-opened.
In order to re-enable the overload feature for an object space, ObjectSpace::overload(true) may be called (also for explicitly overloaded object spaces).