Package org.neo4j.graphdb

Examples of org.neo4j.graphdb.GraphDatabaseService.beginTx()


    GraphDatabaseService db = graphDb();
    SpatialDatabaseService sdb = new SpatialDatabaseService(db);
    SimplePointLayer layer = sdb.createSimplePointLayer("my-points", "x", "y");

    Coordinate[] coords = makeCoordinateDataFromTextFile("NEO4J-SPATIAL.txt", testOrigin);
    try (Transaction tx = db.beginTx()) {
      for (Coordinate coordinate : coords) {
        Node n = db.createNode();
        n.setProperty("x", coordinate.x);
        n.setProperty("y", coordinate.y);
        layer.add(n);
View Full Code Here


    double x_offset = 0.15, y_offset = 0.15;
    SimplePointLayer layerA = sdb.createSimplePointLayer("my-points-A", "xa", "ya", "bbox_a");
    SimplePointLayer layerB = sdb.createSimplePointLayer("my-points-B", "xb", "yb", "bbox_b");

    Coordinate[] coords = makeCoordinateDataFromTextFile("NEO4J-SPATIAL.txt", testOrigin);
    try (Transaction tx = db.beginTx()) {
      for (Coordinate coordinate : coords) {
        Node n = db.createNode();
        n.setProperty("xa", coordinate.x);
        n.setProperty("ya", coordinate.y);
        n.setProperty("xb", coordinate.x + x_offset);
View Full Code Here

    double[] centreA = bboxA.centre();
    double[] centreB = bboxB.centre();

    List<SpatialDatabaseRecord> resultsA;
    List<SpatialDatabaseRecord> resultsB;
    try (Transaction tx = db.beginTx()) {
      resultsA = GeoPipeline.startNearestNeighborLatLonSearch(layerA,
          new Coordinate(centreA[0] + 0.1, centreA[1]), 10.0).toSpatialDatabaseRecordList();
      resultsB = GeoPipeline.startNearestNeighborLatLonSearch(layerB,
          new Coordinate(centreB[0] + 0.1, centreB[1]), 10.0).toSpatialDatabaseRecordList();
      tx.success();
View Full Code Here

    double distanceInKm = 0.01;
    HashSet<Node> results = new HashSet<Node>();
    System.out.println("Searching for geometries near "+coordinates.size()+" locations: " + coordinates.get(0) + " ... "
        + coordinates.get(coordinates.size() - 1));
    performance = new Performance("search points");
    try (Transaction tx = graphDb.beginTx()) {
      for (Coordinate coordinate : coordinates) {
        List<Node> res = GeoPipeline.startNearestNeighborLatLonSearch(layer, coordinate, distanceInKm)
            .sort("OrthodromicDistance").toNodeList();
        results.addAll(res);
      }
View Full Code Here

    for (Entry<String, Geometry> entry: testGeoms.entrySet()) {
      String gname = entry.getKey();
      Geometry geometry = entry.getValue();
      System.out.println("Searching for geometries near Geometry: " + gname);
      performance = new Performance(gname);
      try (Transaction tx = graphDb.beginTx()) {
        List<Node> res = runSearch(GeoPipeline.startIntersectSearch(layer, geometry), true);
        performance.stop(res);
        performances.put(performance.name,performance);
        System.out.println("Geometry search took " + performance.duration() + " seconds to find " + res.size() + " results");
        tx.success();
View Full Code Here

    public void testWithSeparateTransactions() throws Exception {
        final GraphDatabaseService gdb = new TestGraphDatabaseFactory().newImpermanentDatabase();
        final Thread t = new Thread() {
            @Override
            public void run() {
                final Transaction tx = gdb.beginTx();
                final Index<Node> index = gdb.index().forNodes("Test");
                assertEquals("Test", gdb.index().nodeIndexNames()[0]);
                tx.success();
                tx.close();
            }
View Full Code Here

                tx.success();
                tx.close();
            }
        };
        t.start();t.join();
        Transaction tx = gdb.beginTx();
        try {
            final ExecutionResult result = new ExecutionEngine(gdb).execute("start n=node:Test('name:*') return n");
            assertEquals(0,IteratorUtil.count(result));
            assertEquals("Test", gdb.index().nodeIndexNames()[0]);
        } finally {
View Full Code Here

    @Test
    public void shouldIncludeCorrectRelationships() {
        GraphDatabaseService database = new TestGraphDatabaseFactory().newImpermanentDatabase();

        try (Transaction tx = database.beginTx()) {
            Node n1 = database.createNode();
            Node n2 = database.createNode();
            Relationship r = n1.createRelationshipTo(n2, withName("TEST"));
            r.setProperty("test", "test");
View Full Code Here

    @Test
    public void shouldIncludeCorrectRelationships() {
        GraphDatabaseService database = new TestGraphDatabaseFactory().newImpermanentDatabase();

        try (Transaction tx = database.beginTx()) {
            Node n = database.createNode(label("Test"));
            n.setProperty("test", "test");

            assertTrue(IncludeNodes.all().include(n));
            assertTrue(IncludeNodes.all().with("Test").include(n));
View Full Code Here

    @Test
    public void testRandom() {
        GraphDatabaseService database = new TestGraphDatabaseFactory().newImpermanentDatabase();

        try (Transaction tx = database.beginTx()) {
            database.createNode();
            tx.success();
        }

        try (Transaction tx = database.beginTx()) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.