Class OrientGraph

java.lang.Object
org.apache.tinkerpop.gremlin.orientdb.OrientGraph
All Implemented Interfaces:
AutoCloseable, OGraph, org.apache.tinkerpop.gremlin.structure.Graph, org.apache.tinkerpop.gremlin.structure.util.Host

public final class OrientGraph extends Object implements OGraph
  • Field Details

  • Constructor Details

  • Method Details

    • open

      public static OrientGraph open()
    • open

      public static OrientGraph open(String url)
    • open

      public static OrientGraph open(String url, String user, String password)
    • open

      public static OrientGraph open(org.apache.commons.configuration2.Configuration config)
    • features

      public org.apache.tinkerpop.gremlin.structure.Graph.Features features()
      Specified by:
      features in interface org.apache.tinkerpop.gremlin.structure.Graph
    • database

      public ODatabaseDocument database()
    • makeActive

      public void makeActive()
    • addVertex

      public org.apache.tinkerpop.gremlin.structure.Vertex addVertex(Object... keyValues)
      Specified by:
      addVertex in interface org.apache.tinkerpop.gremlin.structure.Graph
    • executeSql

      public OGremlinResultSet executeSql(String sql, Object... params)
    • executeSql

      public OGremlinResultSet executeSql(String sql, Map params)
      Specified by:
      executeSql in interface OGraph
    • querySql

      public OGremlinResultSet querySql(String sql, Object... params)
    • querySql

      public OGremlinResultSet querySql(String sql, Map params)
      Specified by:
      querySql in interface OGraph
    • execute

      public OGremlinResultSet execute(String language, String script, Map params)
    • compute

      public <C extends org.apache.tinkerpop.gremlin.process.computer.GraphComputer> C compute(Class<C> graphComputerClass) throws IllegalArgumentException
      Specified by:
      compute in interface org.apache.tinkerpop.gremlin.structure.Graph
      Throws:
      IllegalArgumentException
    • compute

      public org.apache.tinkerpop.gremlin.process.computer.GraphComputer compute() throws IllegalArgumentException
      Specified by:
      compute in interface org.apache.tinkerpop.gremlin.structure.Graph
      Throws:
      IllegalArgumentException
    • elementFactory

      public OElementFactory elementFactory()
      Specified by:
      elementFactory in interface OGraph
    • vertices

      public Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> vertices(Object... vertexIds)
      Specified by:
      vertices in interface org.apache.tinkerpop.gremlin.structure.Graph
    • labelToClassName

      public String labelToClassName(String label, String prefix)
      Convert a label to orientdb class name
      Specified by:
      labelToClassName in interface OGraph
    • classNameToLabel

      public String classNameToLabel(String className)
      Convert a orientdb class name to label
      Specified by:
      classNameToLabel in interface OGraph
    • executeWithRetry

      public <T> T executeWithRetry(int nRetries, Function<OrientGraph,T> function)
      Tries to execute a lambda in a transaction, retrying it if an ONeedRetryException is thrown.

      If the Graph has an active transaction, then the transaction has to be empty (no operations executed yet) and after the execution you will be in a new transaction.

      Type Parameters:
      T - the return type of the lambda
      Parameters:
      nRetries - the maximum number of retries (> 0)
      function - a lambda containing application code to execute in a commit/retry loop
      Returns:
      The result of the execution of the lambda
      Throws:
      IllegalStateException - if there are operations in the current transaction
      ONeedRetryException - if the maximum number of retries is executed and all failed with an ONeedRetryException
      IllegalArgumentException - if nRetries is <= 0
      UnsupportedOperationException - if this type of graph does not support automatic commit/retry or does not support transactions
    • convertValue

      protected Object convertValue(OIndex idx, Object iValue)
    • getIndexedVertices

      public Stream<OrientVertex> getIndexedVertices(OIndex index, Iterator<Object> valueIter)
      Specified by:
      getIndexedVertices in interface OGraph
    • getIndexedEdges

      public Stream<OrientEdge> getIndexedEdges(OIndex index, Iterator<Object> valueIter)
      Specified by:
      getIndexedEdges in interface OGraph
    • getIndexedKeys

      public Set<String> getIndexedKeys(String className)
    • getIndexedKeys

      public Set<String> getIndexedKeys(Class<? extends org.apache.tinkerpop.gremlin.structure.Element> elementClass, String label)
      Specified by:
      getIndexedKeys in interface OGraph
    • getIndexedKeys

      public Set<String> getIndexedKeys(Class<? extends org.apache.tinkerpop.gremlin.structure.Element> elementClass)
    • getVertexIndexedKeys

      public Set<String> getVertexIndexedKeys(String label)
    • getEdgeIndexedKeys

      public Set<String> getEdgeIndexedKeys(String label)
    • edges

      public Iterator<org.apache.tinkerpop.gremlin.structure.Edge> edges(Object... edgeIds)
      Specified by:
      edges in interface org.apache.tinkerpop.gremlin.structure.Graph
    • elements

      protected <A extends org.apache.tinkerpop.gremlin.structure.Element> Iterator<A> elements(String elementClass, Function<ORecord,A> toA, Object... elementIds)
    • getRecord

      protected ORecord getRecord(ORID id)
    • createRecordId

      protected static ORID createRecordId(Object id)
    • getRawDocument

      protected OElement getRawDocument(ORecord record)
    • tx

      public OrientTransaction tx()
      Specified by:
      tx in interface org.apache.tinkerpop.gremlin.structure.Graph
    • drop

      public void drop()
      (Blueprints Extension) Drops the database
    • isClosed

      public boolean isClosed()
      Checks if the Graph has been closed.
      Returns:
      True if it is closed, otherwise false
    • begin

      public void begin()
    • commit

      public void commit()
    • rollback

      public void rollback()
    • variables

      public org.apache.tinkerpop.gremlin.structure.Graph.Variables variables()
      Specified by:
      variables in interface org.apache.tinkerpop.gremlin.structure.Graph
    • configuration

      public org.apache.commons.configuration2.Configuration configuration()
      Specified by:
      configuration in interface org.apache.tinkerpop.gremlin.structure.Graph
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface org.apache.tinkerpop.gremlin.structure.Graph
    • createVertexClass

      public String createVertexClass(String label)
      Specified by:
      createVertexClass in interface OGraph
    • createEdgeClass

      public String createEdgeClass(String label)
      Specified by:
      createEdgeClass in interface OGraph
    • createClass

      public void createClass(String className, String superClassName)
    • existClass

      public boolean existClass(String label)
      Specified by:
      existClass in interface OGraph
    • createClass

      public void createClass(String className, OClass superClass)
    • getRawDatabase

      public ODatabaseDocument getRawDatabase()
      Specified by:
      getRawDatabase in interface OGraph
    • getClassName

      protected <E> String getClassName(Class<org.apache.tinkerpop.gremlin.structure.T> elementClass)
    • prepareIndexConfiguration

      protected void prepareIndexConfiguration(org.apache.commons.configuration2.Configuration config)
    • createVertexIndex

      public <E extends org.apache.tinkerpop.gremlin.structure.Element> void createVertexIndex(String key, String label, org.apache.commons.configuration2.Configuration configuration)
    • createEdgeIndex

      public <E extends org.apache.tinkerpop.gremlin.structure.Element> void createEdgeIndex(String key, String label, org.apache.commons.configuration2.Configuration configuration)
    • execute

      public <RET> RET execute(OCallable<RET,OrientGraph> iCallable, String... iOperationStrings) throws RuntimeException
      Throws:
      RuntimeException
    • io

      public <I extends org.apache.tinkerpop.gremlin.structure.io.Io> I io(org.apache.tinkerpop.gremlin.structure.io.Io.Builder<I> builder)
      Specified by:
      io in interface org.apache.tinkerpop.gremlin.structure.Graph
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isTransactionActive

      protected boolean isTransactionActive()
    • setElementFactory

      public void setElementFactory(OElementFactory elementFactory)