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 TypeMethodDescriptionvoidIndexes 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.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. A vertex and an edge are two families and two indexes: the UUID-reuse guard of the code covers the case across them. Records with noidare not indexed.- Throws:
IllegalStateException- if either 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
-