java.lang.Object
org.apache.tinkerpop.gremlin.tinkergraph.structure.storage.IndexDefinitions

public final class IndexDefinitions extends Object
The set of property keys a persistent graph indexes, held in a small file beside the storage engine's own files.

Index definitions are deliberately kept out of the transactional log. An index is purely an optimization, so losing a definition to a crash costs a rebuild rather than any data: a crash between createIndex and the write here drops a definition the caller can recreate, and one after dropIndex resurrects an index that is dropped again. Neither can change a query result, which is what makes a file outside the write-ahead log an honest place to keep this. Nothing that affects correctness may be stored this way.

The file is line oriented and readable, one record per line: V or E, a tab, then the property key with backslash, tab, newline and carriage return escaped, so a key containing any of them survives a round trip.

  • Constructor Details

    • IndexDefinitions

      public IndexDefinitions(Set<String> vertexKeys, Set<String> edgeKeys)
  • Method Details

    • vertexKeys

      public Set<String> vertexKeys()
    • edgeKeys

      public Set<String> edgeKeys()
    • isEmpty

      public boolean isEmpty()
    • read

      public static IndexDefinitions read(File directory)
      Read the definitions recorded in directory, or an empty set if none have been recorded.

      A file that cannot be read is reported and treated as empty rather than raised. The graph then opens with no indexes, which is exactly how it behaved before definitions were recorded at all, so an unreadable file can never make a store less openable than the data it holds.

    • write

      public void write(File directory)
      Replace the definitions recorded in directory. Written to a temporary file, forced to the device and renamed into place, so a crash leaves either the previous set or the new one and never a partial file.