Class SchemaIndexManagement
java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.SchemaIndexManagement
Creates the indexes the service's lookups rely on, idempotently: bootstrap creates them on a new
database, the migration on an existing one. Schema changes, so run outside any transaction, with
the admin users.
OrientDB only indexes declared properties, so each field is declared first when it is not. An index on a class covers the records of its subclasses too.
- Author:
- Luca Frosini (ISTI - CNR)
-
Constructor Summary
ConstructorsConstructorDescriptionSchemaIndexManagement(com.orientechnologies.orient.core.db.document.ODatabaseDocument db) Creates a new instance over the given session. -
Method Summary
Modifier and TypeMethodDescriptionvoidDrops the index of the UUID namespace shared by vertices and edges, the one onORestricted: the creation of a class below it cannot extend that index while it exists on a database being restored, so a System Restore drops it before creating the Types of the archive andensureIdentifierIndexes()creates it again once they exist.voidIndexes the fields a Context is resolved by, its currentpathand itspreviousPaths, not unique: a deleted Context stays in the same class, and a new Context may reuse its path.voidIndexes the UUID of every entity and of every relation, unique:idonEntityElementand onRelationElement, which every vertex and edge the service manages descends from, and onORestricted, the superclass of record-level security the service gives to bothVandE: one UUID namespace across vertices and edges, so that two concurrent creations of a vertex and an edge with the sameidcannot both commit.voidIndexes thenameof every Query Template, unique: the registry holds at most one Query Template for each exact, case-sensitive name, under concurrent requests too.findDuplicateIdentifiers(String className) Returns the UUIDs held by more than one record of the class, subclasses included.
-
Constructor Details
-
SchemaIndexManagement
public SchemaIndexManagement(com.orientechnologies.orient.core.db.document.ODatabaseDocument db) Creates a new instance over the given session.- Parameters:
db- an admin session, outside any transaction
-
-
Method Details
-
ensureContextPathIndexes
public void ensureContextPathIndexes()Indexes the fields a Context is resolved by, its currentpathand itspreviousPaths, not unique: a deleted Context stays in the same class, and a new Context may reuse its path. ThenContextManagement.OWNED_PATHS, the paths of a live Context, unique: no other live Context may hold any of them, under concurrent requests too.- Throws:
IllegalStateException- if theContextclass does not exist, or some path is already owned by more than one live Context, listed in the message
-
ensureIdentifierIndexes
public void ensureIdentifierIndexes()Indexes the UUID of every entity and of every relation, unique:idonEntityElementand onRelationElement, which every vertex and edge the service manages descends from, and onORestricted, the superclass of record-level security the service gives to bothVandE: one UUID namespace across vertices and edges, so that two concurrent creations of a vertex and an edge with the sameidcannot both commit. Records with noidare not indexed.- Throws:
IllegalStateException- if a class does not exist, or some UUID is already held by more than one record, listed in the message
-
ensureQueryTemplateNameIndex
public void ensureQueryTemplateNameIndex()Indexes thenameof every Query Template, unique: the registry holds at most one Query Template for each exact, case-sensitive name, under concurrent requests too.- Throws:
IllegalStateException- if theQueryTemplateclass does not exist, or some name is already held by more than one Query Template, listed in the message
-
findDuplicateIdentifiers
Returns the UUIDs held by more than one record of the class, subclasses included.- Parameters:
className- the class to check- Returns:
- how many records hold each duplicated UUID
-