java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.SchemaIndexManagement

public class SchemaIndexManagement extends Object
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

    Constructors
    Constructor
    Description
    SchemaIndexManagement(com.orientechnologies.orient.core.db.document.ODatabaseDocument db)
    Creates a new instance over the given session.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Drops the index of the UUID namespace shared by vertices and edges, the one on ORestricted: 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 and ensureIdentifierIndexes() creates it again once they exist.
    void
    Indexes the fields a Context is resolved by, its current path and its previousPaths, not unique: a deleted Context stays in the same class, and a new Context may reuse its path.
    void
    Indexes the UUID of every entity and of every relation, unique: id on EntityElement and on RelationElement, which every vertex and edge the service manages descends from, and on ORestricted, the superclass of record-level security the service gives to both V and E: one UUID namespace across vertices and edges, so that two concurrent creations of a vertex and an edge with the same id cannot both commit.
    void
    Indexes the name of every Query Template, unique: the registry holds at most one Query Template for each exact, case-sensitive name, under concurrent requests too.
    Returns the UUIDs held by more than one record of the class, subclasses included.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 current path and its previousPaths, not unique: a deleted Context stays in the same class, and a new Context may reuse its path. Then ContextManagement.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 the Context class 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: id on EntityElement and on RelationElement, which every vertex and edge the service manages descends from, and on ORestricted, the superclass of record-level security the service gives to both V and E: one UUID namespace across vertices and edges, so that two concurrent creations of a vertex and an edge with the same id cannot both commit. Records with no id are 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
    • dropSharedIdentifierIndex

      public void dropSharedIdentifierIndex()
      Drops the index of the UUID namespace shared by vertices and edges, the one on ORestricted: 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 and ensureIdentifierIndexes() creates it again once they exist.
    • ensureQueryTemplateNameIndex

      public void ensureQueryTemplateNameIndex()
      Indexes the name of 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 the QueryTemplate class does not exist, or some name is already held by more than one Query Template, listed in the message
    • findDuplicateIdentifiers

      public Map<String,Long> findDuplicateIdentifiers(String className)
      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