Class SchemaId
- All Implemented Interfaces:
Serializable
SchemaItem
component
or an entire SchemaModel
.
SchemaId
's are calculated by taking a secure hash over the structural components of some schema
item such as an object type, a field, or an index. They provide a simple way to determine whether two schema
items are structurally compatible. Two schema items are structurally compatibile if they are identified and encoded
in the same way and therefore can and should share the same storage ID assignment in the database. The String
form of a SchemaId
looks like SimpleField_12e983a72e72ed56741ddc45e47d3377
, where the prefix indicates
the schema item type.
SchemaId
's are also used to quickly determine whether two SchemaModel
s are identical except for
explicit storage ID assignments. If so, and assuming they don't have any conflicting explicit storage ID's,
then they can map to the same Schema
in the database. In other words, they can share the same schema index,
analogous to how two SchemaItem
s with the same SchemaId
can share the same storage ID.
Note that SchemaModel equality is a stronger condition that includes storage ID's.
For SchemaItem
s, a SchemaId
covers its "structure", where that is defined as:
- For each
SchemaObjectType
, its object type name. - For each
ComplexSchemaField
, it's field name, complex field type (list, set, or map), and the structures of its sub-field(s). - For counter fields, it's name and field type (i.e., counter).
- For simple fields, it's name, field type (i.e., simple), and encoding.
- For enum and enum array fields, also the enum's identifier list.
- For
SchemaCompositeIndex
s, the structure(s) of the indexed field(s).
SchemaId
calculations do not include storage ID's; instead, storage ID's are assigned when a SchemaModel
is recorded in a database.
- See Also:
-
Field Details
-
Constructor Details
-
SchemaId
Constructor.- Parameters:
id
- the schema structure ID in string form- Throws:
IllegalArgumentException
- ifid
is null or invalid
-
SchemaId
Constructor.- Parameters:
itemType
- schema item typehash
-NUM_HASH_BYTES
hash bytes- Throws:
IllegalArgumentException
- if either parameter is nullIllegalArgumentException
- ifbytes
has the wrong length
-
-
Method Details
-
getId
Get the schema ID in string form.- Returns:
- schema structure ID
-
getItemType
Get theItemType
of the schema item that originally generated this schema ID.- Returns:
- original schema item type
- See Also:
-
SchemaSupport.getItemType()
-
toString
-
hashCode
public int hashCode() -
equals
-