Search in sources :

Example 66 with StandardJanusGraph

use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.

the class JanusGraphTraversalUtil method getJanusGraph.

public static StandardJanusGraph getJanusGraph(final Traversal.Admin<?, ?> traversal) {
    Optional<Graph> optionalGraph = traversal.getGraph();
    if (!optionalGraph.isPresent()) {
        return null;
    }
    Graph graph = optionalGraph.get();
    if (graph instanceof StandardJanusGraph) {
        return (StandardJanusGraph) graph;
    }
    if (graph instanceof StandardJanusGraphTx) {
        return ((StandardJanusGraphTx) graph).getGraph();
    }
    return null;
}
Also used : Graph(org.apache.tinkerpop.gremlin.structure.Graph) JanusGraphBlueprintsGraph(org.janusgraph.graphdb.tinkerpop.JanusGraphBlueprintsGraph) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) StandardJanusGraphTx(org.janusgraph.graphdb.transaction.StandardJanusGraphTx) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph)

Example 67 with StandardJanusGraph

use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.

the class JanusGraphLocalQueryOptimizerStrategy method apply.

@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    if (!traversal.getGraph().isPresent())
        return;
    final StandardJanusGraph janusGraph = JanusGraphTraversalUtil.getJanusGraph(traversal);
    if (janusGraph == null) {
        return;
    }
    boolean batchPropertyPrefetching = janusGraph.getConfiguration().batchPropertyPrefetching();
    int txVertexCacheSize = janusGraph.getConfiguration().getTxVertexCacheSize();
    applyJanusGraphVertexSteps(traversal, batchPropertyPrefetching, txVertexCacheSize);
    applyJanusGraphPropertiesSteps(traversal);
    inspectLocalTraversals(traversal);
}
Also used : StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph)

Example 68 with StandardJanusGraph

use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.

the class JanusGraphMultiQueryStrategy method apply.

@Override
public void apply(final Admin<?, ?> traversal) {
    if (!traversal.getGraph().isPresent() || TraversalHelper.onGraphComputer(traversal) || // this strategy should not run on those traversals either, because it can also insert barrier().
    !TraversalHelper.getStepsOfAssignableClassRecursively(DropStep.class, traversal).isEmpty()) {
        return;
    }
    final StandardJanusGraph janusGraph = JanusGraphTraversalUtil.getJanusGraph(traversal);
    if (janusGraph == null) {
        return;
    }
    final Optional<StandardJanusGraphTx> tx = JanusGraphTraversalUtil.getJanusGraphTx(traversal);
    boolean useMultiQuery = tx.isPresent() ? tx.get().getConfiguration().useMultiQuery() : janusGraph.getConfiguration().useMultiQuery();
    if (!useMultiQuery) {
        return;
    }
    insertMultiQuerySteps(traversal, janusGraph.getConfiguration().limitBatchSize());
    configureMultiQueriables(traversal);
}
Also used : StandardJanusGraphTx(org.janusgraph.graphdb.transaction.StandardJanusGraphTx) DropStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropStep) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph)

Aggregations

StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)68 Test (org.junit.jupiter.api.Test)38 MapConfiguration (org.apache.commons.configuration2.MapConfiguration)25 CommonsConfiguration (org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration)18 GraphDatabaseConfigurationBuilder (org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder)18 HashMap (java.util.HashMap)13 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)9 Test (org.junit.Test)9 MapConfiguration (org.apache.commons.configuration.MapConfiguration)8 JanusGraphManager (org.janusgraph.graphdb.management.JanusGraphManager)8 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)6 GraphDatabaseConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration)6 PropertyKey (org.janusgraph.core.PropertyKey)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 Graph (org.apache.tinkerpop.gremlin.structure.Graph)4 Backend (org.janusgraph.diskstorage.Backend)4 WriteConfiguration (org.janusgraph.diskstorage.configuration.WriteConfiguration)4 TimestampProvider (org.janusgraph.diskstorage.util.time.TimestampProvider)4 StandardJanusGraphTx (org.janusgraph.graphdb.transaction.StandardJanusGraphTx)4 JanusGraph (org.janusgraph.core.JanusGraph)3