Search in sources :

Example 6 with Neo4jGraph

use of com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph in project blueprints by tinkerpop.

the class Neo4jBatchGraphTest method testAddingVerticesWithUserIdsThenSettingProperties.

public void testAddingVerticesWithUserIdsThenSettingProperties() {
    List<Long> ids = new ArrayList<Long>(Arrays.asList(100L, 5L, 10L, 4L, 10000L));
    final String directory = this.getWorkingDirectory();
    final Neo4jBatchGraph batch = new Neo4jBatchGraph(directory);
    for (final Long id : ids) {
        Vertex v = batch.addVertex(id);
        v.setProperty("theKey", id);
    }
    for (final Long id : ids) {
        assertNotNull(batch.getVertex(id));
        assertEquals(batch.getVertex(id).getProperty("theKey"), id);
    }
    assertNull(batch.getVertex(1L));
    assertNull(batch.getVertex(2L));
    assertNull(batch.getVertex(200000L));
    batch.shutdown();
    // native neo4j graph load
    final Graph graph = new Neo4jGraph(directory);
    assertEquals(count(graph.getVertices()), ids.size());
    for (final Long id : ids) {
        assertNotNull(graph.getVertex(id));
        assertEquals(graph.getVertex(id).getProperty("theKey"), id);
        assertEquals(graph.getVertex(id).getPropertyKeys().size(), 1);
    }
    assertNull(graph.getVertex(1L));
    assertNull(graph.getVertex(2L));
    assertNull(graph.getVertex(200000L));
    graph.shutdown();
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) Neo4jGraph(com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph) IndexableGraph(com.tinkerpop.blueprints.IndexableGraph) Graph(com.tinkerpop.blueprints.Graph) Neo4jGraph(com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph) ArrayList(java.util.ArrayList)

Example 7 with Neo4jGraph

use of com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph in project blueprints by tinkerpop.

the class Neo4jBatchGraphTest method testAddingVerticesWithUserIdsAsStringsThenSettingProperties.

public void testAddingVerticesWithUserIdsAsStringsThenSettingProperties() {
    List<Object> ids = new ArrayList<Object>(Arrays.asList(100L, 5.0d, "10", 4.0f, "10000.00"));
    final String directory = this.getWorkingDirectory();
    final Neo4jBatchGraph batch = new Neo4jBatchGraph(directory);
    for (final Object id : ids) {
        Vertex v = batch.addVertex(id);
        v.setProperty("theKey", id);
    }
    for (final Object id : ids) {
        assertNotNull(batch.getVertex(id));
        assertEquals(batch.getVertex(id).getProperty("theKey"), id);
    }
    assertNull(batch.getVertex(1L));
    assertNull(batch.getVertex(2L));
    assertNull(batch.getVertex(200000L));
    batch.shutdown();
    // native neo4j graph load
    final Graph graph = new Neo4jGraph(directory);
    assertEquals(count(graph.getVertices()), ids.size());
    assertNotNull(graph.getVertex(100l));
    assertNotNull(graph.getVertex(5l));
    assertNotNull(graph.getVertex(10l));
    assertNotNull(graph.getVertex(4l));
    assertNotNull(graph.getVertex(10000));
    graph.shutdown();
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) Neo4jGraph(com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph) IndexableGraph(com.tinkerpop.blueprints.IndexableGraph) Graph(com.tinkerpop.blueprints.Graph) Neo4jGraph(com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph) ArrayList(java.util.ArrayList)

Example 8 with Neo4jGraph

use of com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph in project blueprints by tinkerpop.

the class Neo4jGraphSailTest method createGraph.

protected KeyIndexableGraph createGraph() throws Exception {
    String directory = System.getProperty("neo4jGraphDirectory");
    if (directory == null) {
        directory = this.getWorkingDirectory();
    }
    Neo4jGraph g = new Neo4jGraph(directory);
    g.setCheckElementsInTransaction(true);
    return g;
}
Also used : Neo4jGraph(com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph)

Aggregations

Neo4jGraph (com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph)8 Vertex (com.tinkerpop.blueprints.Vertex)6 ArrayList (java.util.ArrayList)5 Edge (com.tinkerpop.blueprints.Edge)4 IndexableGraph (com.tinkerpop.blueprints.IndexableGraph)4 Graph (com.tinkerpop.blueprints.Graph)3 HashMap (java.util.HashMap)2 Index (com.tinkerpop.blueprints.Index)1 Parameter (com.tinkerpop.blueprints.Parameter)1 PropertyFilteredIterable (com.tinkerpop.blueprints.util.PropertyFilteredIterable)1 GraphMLReader (com.tinkerpop.blueprints.util.io.graphml.GraphMLReader)1 HashSet (java.util.HashSet)1 Random (java.util.Random)1