%FOI.Schema
hidden persistent class %FOI.Schema extends %Library.Persistent [ Final ]
SQL Table Name: %FOI.Schema
Unified Schema
Overview
Unified Schema is a mechanism for defining schemas that are independent of any platform and that can be used to generate platform dependent implementations, keeping those generated implementations synchronized between the various platforms that interact with those schemas.
%FOI.Schema defines the Unified Schema and implements an interface to create, generate server implementations, and retrieve metadata.
Model
The unified schema model is inspired by AVRO but is not AVRO. A schema has a type and that type can be simple or complex, it can embed the definition
of other types or it can reference other types by name. A schema is identified by name. Name is qualified by namespace. A schema is a record type
in AVRO terminology. It contains fields, parameters, embedded named types, and indices. Each of these entities is described in more detail in the properties
and methods sections.
It is important to not confuse the term 'namespace' in the context of a Schema and 'namespace' in the context of Iris. In the context of %FOI.Schema,
a 'namespace' is a schema name qualifier.
Interface
%FOI.Schema is a persistent class and the persistent interface, while fully supported, should be considered to be internal. The primary interface
of Unified Schema is not implemented by this class but in the various supported platforms. Methods implemented by this class can still be invoked
by privileged users. Refer to individual methods of this class for more detai.
Public Methods
compileSchema | Compile a schema. |
compileSchemaList | Compile each schema named in the given %Library.List object. |
compileSchemas | Compile each schema named in the given %Library.DynamicArray. |
deleteSchema | Delete the schema definition. |
deleteSchemaExtent | Delete the persistent extent in the given namespace for the server implementation linked to the given schema. |
getNamespaces | Return a JSON serialized array containing the names of the namespaces available on this system. |
getClasses | Return a JSON serialized array of the classes in the given namespace. |
getSchemas | Return a JSON serialized array of schemas defined in the given namespace. |
getSchema | Return the unified schema for the given namespace and schema name. |
getRecordDefinition | Return the record definition for the given namespace and schema name. |
uncompileSchema | Uncompile a schema. |
Property Inventory
- class
- fields
- fullname
- generatedBy
- idField
- indices
- name
- namedTypes
- namespace
- parameters
- recordMetadata
- registryVersion
- schema
Method Inventory
- %FromJSON()
- %ToJSON()
- appendParsed()
- compileSchema()
- compileSchemaList()
- compileSchemas()
- deleteSchema()
- deleteSchemaExtent()
- fromJSON()
- generateSchema()
- getClasses()
- getNamespaces()
- getRecordDefinition()
- getSchema()
- getSchemaForClass()
- getSchemaImplementation()
- getSchemas()
- isRuntimeUpToDate()
- isSchemaUpToDate()
- normalizeClassname()
- parse()
- propertyToSRM()
- qualifyName()
- storageMapToSRM()
- uncompileSchema()
Parameters
If a persistent class uses %Storage.Persistent then the DEFAULTGLOBAL parameter is used as the default global root for the values of the storage keywords COUNTERLOCATION, DATALOCATION, IDLOCATION, INDEXLOCATION and STREAMLOCATION in the active storage definition. DEFAULTGLOBAL is only used to generate location keyword values that are not already defined. The location value is constructed by adding a location type to the end of DEFAULTGLOBAL. For example, if DEFAULTGLOBAL = "^GL.Account" the compiler will generate DATALOCATION = ^GL.AccountD.
If USEEXTENTSET is true, then DEFAULTGLOBAL is used as the default extent location.
The location types are:
Location | Type |
---|---|
COUNTERLOCATION | C |
DATALOCATION | D |
IDLOCATION | D |
INDEXLOCATION | I |
STREAMLOCATION | S |
If a persistent class uses %Storage.Persistent then the USEEXTENTSET parameter is used to specify the global naming strategy used by the default storage class (%Storage.Persistent). If TRUE, then global names are generated for each index that is not already allocated a LOCATION in the active storage definition.
If the storage definition specifies EXTENTLOCATION then that value is used as the base reference for all globals assigned to indices that do not have an explicit LOCATION assigned.
The global name generator for USEEXTENTSET = TRUE honors the package prefix defined in the Package Definition. If none is defined then the package prefix is generated using a based-62 encoded integer produced from CRC32 of the package name. The specific class identifier is generated from the unqualified class name using the same hash (class->crc32->base62) to form EXTENTLOCATION. Specific index suffixes are produced using a generated offset that is local to the first persistent class with an enumerated extent in which the index appears (either defined or inherited).
There are several factors that influence the generation of EXTENTLOCATION:
- If the EXTENTLOCATION keyword is defined then its value is used,
- If the DEFAULTGLOBAL class parameter is defined then its value is used,
- otherwise, the value is generated as two dot delimited segments. The first segment is either the defined package prefix retrieved from the package definition global or, if none is defined, a hash of the package name. The second segment is generated by a hash of the unqualified class name. The hash used is a base 62 encoded CRC32 of the value. For example, Sample.Person produces ^EW3K.wPC9 if no package prefix is defined.
EXTENTLOCATION is specific to each class. When a persistent class extends another persistent class, forming a subextent, then the subclass's EXTENTLOCATION is specific to that subclass. The index location for any inherited index is already defined specifically in the superclass so the subclass's EXTENTLOCATION will only be used as the base for any index that originates in the subclass. For example, Sample.Employee extends Sample.Person. The EXTENTLOCATION generated for Sample.Person is ^EW3K.wPC9 and the EXTENTLOCATION for Sample.Employee is ^EW3K.D1Ex. Since Sample.Employee inherits several indices from Sample.Person, the global name assigned to each of those indices is already defined and inherited by Sample.Employee. However, any index defined in Sample.Employee and not inherited from Sample.Person will be assigned a global name based on Sample.Employee's EXTENTLOCATION, not on Sample.Person's EXTENTLOCATION. In other words, the EXTENTLOCATION storage keyword is not inherited.
The following tables show the indices and locations for Sample.Person and Sample.Employee. Notice the last index in the Sample.Employee table:
Class = Sample.Person | ||||||||||||||
|
||||||||||||||
Class = Sample.Employee extends Sample.Person | ||||||||||||||
|
Any generated global index locations and EXTENTLOCATION are updated back into the active storage definition after the class is compiled.
If USEEXTENTSET is FALSE, then global names are generated using the package-hash.class-hashSuffix strategy. For example, ^Sample.PersonD and ^Sample.PersonI("SSNKey") are globals used by Sample.Person and specific index structures are all stored in ^Sample.PersonI with the index name used as the first subscript.
Properties
Methods
Import a schema or multiple schemas from JSON. The input value can be a string formatted as JSON, an instance of %Library.DynamicAbstractObject or a stream containing JSON. If the input JSON is an array then each element of the array is expected to be a schema and each will be imported.
The input is parsed and placed in instances of this class. The response is an instance of this class, in keeping with the %FromJSON() interface, or in the case where multiple schema are presented in an array, the response is an array (%Library.DynamicArray) of schema instances.
Schemas imported from JSON are automatically saved.
Compile the schema. Generate the server implementation if the schema originates from a client or link to an existing server implementation if the schema originates on the server. If no error is encountered then the server implementation is compiled. This method throws an exception if any errors are encountered.
schemaName | Name of the schema to compile |
namespace | The namespace of the schema. If namespace is null or empty then schemaName is expected to be a fully qualified name. |
Compile each schema contained in the %List object. This method just repackages the %List instance as a JSON array and dispatches to compileSchemas().
list | The %Library.List object containing the names of the schemas to compile. |
compileSchemas accepts an array of schema names and generates the server implementation for each schema. If no errors are encountered then all server implementations generated are compiled. This method does not return any useful value (null on success) but exceptions are thrown for any failures.
For an IRIS Server, the implementation of a schema is a class definition.
schemas | A JSON serialized array or a %Library.DynamicArray containing the names of the schemas to compile. |
Delete the schema definition from the specified namespace (defaults to the current namespace). If the schema originates from a client then the server implementation linked to the schema will also be deleted. This method throws an exception if any errors are encountered.
schemaName | Name of the schema to be deleted |
namespace | The namespace of the schema. If namespace is null or empty then schemaName is expected to be a fully qualified name. |
Delete the persistent extent in the given namespace for the server implementation linked to the given schema. This method throws an exception if any errors are encountered.
schemaName | Name of the schema |
namespace | The namespace of the schema. If namespace is null or empty then schemaName is expected to be a fully qualified name. |
className | Name of the class to generate a unified schema from. | |
return | Return value is a JSON formatted array containing the full names of all schemas generated. |
getClasses - return a JSON array of the names of classes defined in the current namespace.
return | Return value is a JSON formatted array of class names. |
This method returns a JSON serialized array containing namespaces accessible on this system. This class method can be invoked by SQL as a function or a procedure (%FOI.getNamespaces() or ? = call %FOI.getNamespaces()).
getRecordDefinition - returns a JSON formatted Record Definition for a Unified Schema. The record definition is close to an AVRO Record Definition.
schemaName | Name of the schema whose record definition is to be retrieved | |
namespace | The namespace of the schema. If namespace is null or empty then schemaName is expected to be a fully qualified name. | |
return | Return value is a JSON formatted record definition. |
getSchema - returns a JSON formatted Unified Schema Definition.
schemaName | Name of the schema to retrieve | |
namespace | The namespace of the schema. If namespace is null or empty then schemaName is expected to be a fully qualified name. | |
return | Return value is a JSON formatted schema definition. |
getSchemaImplementation - returns the name of the local implementation class if it exists
schemaName | Name of the schema whose record definition is to be retrieved | |
namespace | The namespace of the schema. If namespace is null or empty then schemaName is expected to be a fully qualified name. | |
return | Return value a string containing the name of the local implementation class |
getSchemas - return a JSON array the names of schemas defined in the current namespace.
return | Return value is a JSON formatted array of schema names. |
Uncompile the schema. If the schema originates from a client then the linked server implementation is deleted along with its extent. If the schema originates on the server then the linked server implementation is simply unlinked. This method throws an exception if any errors are encountered.
schemaName | Name of the schema to uncompile |
namespace | The namespace of the schema. If namespace is null or empty then schemaName is expected to be a fully qualified name. |
Indexes
Triggers
Inherited Members
Inherited Methods
- %%CLASSNAMELogicalToStorage()
- %%CLASSNAMEStorageToLogical()
- %AddToSaveSet()
- %AddToSyncSet()
- %BMEBuilt()
- %BuildIndicesAsync()
- %BuildIndicesAsyncResponse()
- %CheckConstraints()
- %CheckConstraintsForExtent()
- %ClassIsLatestVersion()
- %ClassName()
- %ComposeOid()
- %ConstructClone()
- %Delete()
- %DeleteExtent()
- %DeleteId()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchGetProperty()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %DispatchSetProperty()
- %Exists()
- %ExistsId()
- %Extends()
- %GUID()
- %GUIDSet()
- %GetLock()
- %GetParameter()
- %GetSwizzleObject()
- %Id()
- %InsertBatch()
- %IsA()
- %IsModified()
- %IsNull()
- %KillExtent()
- %KillExtentData()
- %LoadFromMemory()
- %LockExtent()
- %LockId()
- %New()
- %NormalizeObject()
- %ObjectIsNull()
- %ObjectModified()
- %Oid()
- %OnBeforeAddToSync()
- %OnDeleteFinally()
- %OnDetermineClass()
- %OnOpenFinally()
- %OnSaveFinally()
- %Open()
- %OpenId()
- %OriginalNamespace()
- %PackageName()
- %PhysicalAddress()
- %PurgeIndices()
- %Reload()
- %RemoveFromSaveSet()
- %ResolveConcurrencyConflict()
- %RollBack()
- %Save()
- %SaveDirect()
- %SaveIndices()
- %SerializeObject()
- %SetModified()
- %SortBegin()
- %SortEnd()
- %SyncObjectIn()
- %SyncTransport()
- %UnlockExtent()
- %UnlockId()
- %ValidateIndices()
- %ValidateObject()
- %ValidateTable()
Storage
Storage Model: Storage (%FOI.Schema)
^IRIS.FOI.MD.1(ID) |
= | name
namespace
|
Storage Model: Storage (%FOI.Schema)
^IRIS.FOI.MD.1(ID,"1") |
= | class
generatedBy
registryVersion
|
Storage Model: Storage (%FOI.Schema)
^IRIS.FOI.MD.1(ID,"fields") |
= | fields |
Storage Model: Storage (%FOI.Schema)
^IRIS.FOI.MD.1(ID,"idField") |
= | idField |
Storage Model: Storage (%FOI.Schema)
^IRIS.FOI.MD.1(ID,"indices") |
= | indices |
Storage Model: Storage (%FOI.Schema)
^IRIS.FOI.MD.1(ID,"namedTypes") |
= | namedTypes |
Storage Model: Storage (%FOI.Schema)
^IRIS.FOI.MD.1(ID,"parameters") |
= | parameters |
Storage Model: Storage (%FOI.Schema)
^IRIS.FOI.MD.1(ID,"recordMetadata") |
= | recordMetadata |
Storage Model: Storage (%FOI.Schema)
^IRIS.FOI.MD.1(ID,"schema") |
= | schema |