use of org.apache.tinkerpop.gremlin.structure.Graph in project titan by thinkaurelius.
the class TitanTraversalUtil method getTx.
public static TitanTransaction getTx(Traversal.Admin<?, ?> traversal) {
TitanTransaction tx = null;
Optional<Graph> optGraph = TraversalHelper.getRootTraversal(traversal.asAdmin()).getGraph();
if (traversal instanceof FulgoraElementTraversal) {
tx = (TitanTransaction) optGraph.get();
} else {
if (!optGraph.isPresent())
throw new IllegalArgumentException("Traversal is not bound to a graph: " + traversal);
Graph graph = optGraph.get();
if (graph instanceof TitanTransaction)
tx = (TitanTransaction) graph;
else if (graph instanceof TitanBlueprintsGraph)
tx = ((TitanBlueprintsGraph) graph).getCurrentThreadTx();
else
throw new IllegalArgumentException("Traversal is not bound to a Titan Graph, but: " + graph);
}
if (tx == null)
throw new IllegalArgumentException("Not a valid start step for a Titan traversal: " + traversal);
if (tx.isOpen())
return tx;
else
return ((StandardTitanTx) tx).getNextTx();
}
use of org.apache.tinkerpop.gremlin.structure.Graph in project titan by thinkaurelius.
the class CassandraInputFormatIT method testReadWideVertexWithManyProperties.
@Test
public void testReadWideVertexWithManyProperties() {
int numProps = 1 << 16;
long numV = 1;
mgmt.makePropertyKey("p").cardinality(Cardinality.LIST).dataType(Integer.class).make();
mgmt.commit();
finishSchema();
for (int j = 0; j < numV; j++) {
Vertex v = graph.addVertex();
for (int i = 0; i < numProps; i++) {
v.property("p", i);
}
}
graph.tx().commit();
assertEquals(numV, (long) graph.traversal().V().count().next());
Map<String, Object> propertiesOnVertex = graph.traversal().V().valueMap().next();
List<?> valuesOnP = (List) propertiesOnVertex.values().iterator().next();
assertEquals(numProps, valuesOnP.size());
Graph g = GraphFactory.open("target/test-classes/cassandra-read.properties");
GraphTraversalSource t = g.traversal(GraphTraversalSource.computer(SparkGraphComputer.class));
assertEquals(numV, (long) t.V().count().next());
propertiesOnVertex = t.V().valueMap().next();
valuesOnP = (List) propertiesOnVertex.values().iterator().next();
assertEquals(numProps, valuesOnP.size());
}
use of org.apache.tinkerpop.gremlin.structure.Graph in project grakn by graknlabs.
the class TxFactoryJanusTest method testBuildIndexedGraphWithCommit.
@Test
public void testBuildIndexedGraphWithCommit() throws Exception {
Graph graph = getGraph();
addConcepts(graph);
graph.tx().commit();
assertIndexCorrect(graph);
}
use of org.apache.tinkerpop.gremlin.structure.Graph in project grakn by graknlabs.
the class TxFactoryJanusTest method getGraph.
private static JanusGraph getGraph() {
Keyspace name = Keyspace.of("hehe" + UUID.randomUUID().toString().replaceAll("-", ""));
when(session.keyspace()).thenReturn(name);
janusGraphFactory = new TxFactoryJanus(session);
Graph graph = janusGraphFactory.open(GraknTxType.WRITE).getTinkerPopGraph();
assertThat(graph, instanceOf(JanusGraph.class));
return (JanusGraph) graph;
}
use of org.apache.tinkerpop.gremlin.structure.Graph in project janusgraph by JanusGraph.
the class AstyanaxColumnPaginationTest method retrieveBoundaryColumnPaginationEdges.
@Test
public void retrieveBoundaryColumnPaginationEdges() {
final Graph graph = JanusGraphFactory.open(getBaseStorageConfiguration());
final Vertex v = graph.addVertex();
final Vertex v2 = graph.addVertex();
for (int i = 0; i < DEFAULT_READ_PAGE_SIZE; i++) {
v.addEdge("edgeLabel", v2);
}
graph.tx().commit();
assertEquals(DEFAULT_READ_PAGE_SIZE, graph.traversal().V(v).outE().toList().size());
}
Aggregations