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 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.
      Throws:
      IllegalStateException - if the Context class does not exist
    • 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. 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 no id are 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
    • 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