Class SchemaBundle
Database
as seen by a particular Transaction
.
This includes any Schema
s that may have been added or deleted during the transaction.
This class also captures the current storage ID and schema index tables.
Instances are immutable and thread safe.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
-
Constructor Summary
ConstructorDescriptionSchemaBundle
(SchemaBundle.Encoded encoded) Partial constructor for debugging and tooling purposes.SchemaBundle
(SchemaBundle.Encoded encoded, EncodingRegistry encodingRegistry) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the encoded form of this instance.Get theEncodingRegistry
associated with this instance.getObjectTypeName
(int storageId) Get the object type name corresponding to the given storage ID.getSchema
(int schemaIndex) Get theSchema
in this bundle with the given schema index.Get theSchema
in this bundle having the given schema ID.Get all of the storage ID's in this bundle with their correspondingSchemaId
's.Get all of the schemas in this bundle keyed bySchemaId
.Get all of the schemas in this bundle keyed by schema index.int
getStorageId
(SchemaId schemaId) Get the storage ID corresponding to the given schema ID.withSchemaAdded
(int schemaIndex, SchemaModel schemaModel) Build anSchemaBundle.Encoded
instance with the specified schema added.withSchemaRemoved
(SchemaId schemaId) Build anSchemaBundle.Encoded
instance with the specified schema removed.
-
Constructor Details
-
SchemaBundle
Partial constructor for debugging and tooling purposes.This constructor does not create a functional instance (no
EncodingRegistry
provided). However, it does perform enough initialization to allow schema-related meta-data to be discovered.- Parameters:
encoded
- encoded schema and storage ID tables- Throws:
InconsistentDatabaseException
- if the encoded data is invalidIllegalArgumentException
- ifencoded
is null
-
SchemaBundle
Constructor.- Parameters:
encoded
- encoded schema and storage ID tablesencodingRegistry
- registry for simple field encodings- Throws:
InconsistentDatabaseException
- if the encoded data is invalidIllegalArgumentException
- if either parameter is null
-
-
Method Details
-
getEncoded
Get the encoded form of this instance.- Returns:
- encoded schema bundle
-
getEncodingRegistry
Get theEncodingRegistry
associated with this instance.- Returns:
- encoding registry
-
getSchemasBySchemaIndex
Get all of the schemas in this bundle keyed by schema index.- Returns:
- unmodifiable map of
Schema
s indexed by schema index
-
getSchemasBySchemaId
Get all of the schemas in this bundle keyed bySchemaId
.- Returns:
- unmodifiable map of
Schema
s indexed by schema ID
-
getSchema
Get theSchema
in this bundle with the given schema index.- Parameters:
schemaIndex
- schema index- Returns:
- corresponding schema
- Throws:
IllegalArgumentException
- ifschemaIndex
is invalid or unknown
-
getSchema
Get theSchema
in this bundle having the given schema ID.- Parameters:
schemaId
- schema structure ID- Returns:
- schema with ID
schemaId
- Throws:
IllegalArgumentException
- ifschemaId
is not known
-
getSchemaIdsByStorageId
Get all of the storage ID's in this bundle with their correspondingSchemaId
's.- Returns:
- unmodifiable map from storage ID to
SchemaId
-
getStorageId
Get the storage ID corresponding to the given schema ID.- Parameters:
schemaId
- schema structure ID- Returns:
- associated storage ID
- Throws:
IllegalArgumentException
- ifschemaId
is not known
-
getObjectTypeName
Get the object type name corresponding to the given storage ID.- Parameters:
storageId
- object type storage ID- Returns:
- associated object type name
- Throws:
IllegalArgumentException
- ifstorageId
is invalid or unknown
-
withSchemaAdded
Build anSchemaBundle.Encoded
instance with the specified schema added.The schema may already be registered in this bundle. If so, null is returned, reflecting that no change is needed. Otherwise, an encoding of this instance with
schemaModel
is returned.In either case, any explicit storage ID assignments in
schemaModel
are checked for conflicts with the schemas already registered in this bundle, and any unassigned storage ID's inschemaModel
are automatically assigned.- Parameters:
schemaIndex
- schema table index at which to add the schema or zero for next availableschemaModel
- the new schema to add- Returns:
- an encoding of this instance with
schemaModel
added, or null ifschemaModel
is already registered - Throws:
SchemaMismatchException
- ifschemaModel
has one or more explicit storage ID assignments and one of them conflicts with a storage ID assignment already registered in this bundleSchemaMismatchException
- ifschemaIndex
is non-zero and some schema already exists at that indexIllegalArgumentException
- ifschemaModel
is not locked downIllegalArgumentException
- ifschemaModel
does not validateIllegalArgumentException
- ifschemaModel
is nullIllegalArgumentException
- ifschemaIndex
is negative
-
withSchemaRemoved
Build anSchemaBundle.Encoded
instance with the specified schema removed.Any obsolete storage ID assignments will be removed automatically.
- Parameters:
schemaId
- ID of the schema to remove- Throws:
IllegalArgumentException
- ifschemaId
is nullIllegalArgumentException
- if the schema does not exist
-