how delete one spatial layer in effective way

248 views
Skip to first unread message

Rita

unread,
Jul 15, 2013, 9:42:35 AM7/15/13
to ne...@googlegroups.com
Hi,
I'm using Neo4j Spatial. I need to update my layer so I want to delete it and recreate from scratch to mantain the layer allineate with the graph.
Can you suggest me how to remove the layer without affecting other indexes and graph? My tentatives fail.

I try to use the following instructions:

config = new HashMap<String, String>();
       
        config
.put(LayerNodeIndex.LAT_PROPERTY_KEY, "la");
       
        config
.put(LayerNodeIndex.LON_PROPERTY_KEY, "lo");
        config
.put(SpatialIndexProvider.GEOMETRY_TYPE, LayerNodeIndex.POINT_PARAMETER);
       
        layerIndex
= new LayerNodeIndex("layerIndex", graph, config);

        layerIndex
.delete()

          
but the layer is still there!

Then I try to use the following
        SpatialDatabaseService s = new SpatialDatabaseService(graph);
       
       
Listener l = new Listener() {

           
@Override
           
public void begin(int i) {
               
           
}

           
@Override
           
public void worked(int i) {
               
           
}

           
@Override
           
public void done() {
               
           
}
       
};
        s
.deleteLayer("layerIndex", l);


but I got this error:

Exception in thread "main" org.neo4j.graphdb.NotFoundException: More than one relationship[RTREE_REFERENCE, INCOMING] fo
und
for NodeImpl#7208228
 at org
.neo4j.kernel.impl.core.NodeImpl.getSingleRelationship(NodeImpl.java:305)
 at org
.neo4j.kernel.impl.core.NodeProxy.getSingleRelationship(NodeProxy.java:125)
 at org
.neo4j.collections.rtree.RTreeIndex$1.onIndexReference(RTreeIndex.java:163)
 at org
.neo4j.collections.rtree.RTreeIndex.visitInTx(RTreeIndex.java:372)
 at org
.neo4j.collections.rtree.RTreeIndex.visitInTx(RTreeIndex.java:365)
 at org
.neo4j.collections.rtree.RTreeIndex.visitInTx(RTreeIndex.java:365)
 at org
.neo4j.collections.rtree.RTreeIndex.removeAll(RTreeIndex.java:157)
 at org
.neo4j.gis.spatial.DefaultLayer.delete(DefaultLayer.java:296)
 at org
.neo4j.gis.spatial.SpatialDatabaseService.deleteLayer(SpatialDatabaseService.java:300)
..



Many thanks in advance.
Best regards

Rita

Peter Neubauer

unread,
Jul 15, 2013, 9:50:30 AM7/15/13
to Neo4j User
Rita,
any chance of adding to https://github.com/neo4j/spatial/blob/master/src/test/java/org/neo4j/gis/spatial/IndexProviderTest.java#L152 some more code to make it fail with your error, so we can fix it?

Please do that, and give us a Pull Request, so I can look at it.

/peter


Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Kids in Malmö this summer?        - http://www.kidscraft.se
Neo4j questions? Use GraphGist. - http://gist.neo4j.org



Rita

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Rita

unread,
Jul 15, 2013, 10:30:03 AM7/15/13
to ne...@googlegroups.com
Thanks for the reply Peter,
sorry but I don't understand what I should do, what code I have to add. Can you explain me, please?

In any case I see that the node which is generating the error has 2 RTREE_REFERNCE relationship, instead of the others with only one. The nodes before this one were deleted!
So the problem could be because of creation of the layer?

I use this instructions:

        config = new HashMap<String, String>();
        config
.put(LayerNodeIndex.LAT_PROPERTY_KEY, "la");
        config
.put(LayerNodeIndex.LON_PROPERTY_KEY, "lo");
        config
.put(SpatialIndexProvider.GEOMETRY_TYPE, LayerNodeIndex.POINT_PARAMETER);
        layerIndex
= new LayerNodeIndex("layerIndex", graph, config);

       
Transaction tx = graph.beginTx();
        index
= graph.index();
       
        nodes
= index.forNodes("nodeA");
        hits
= nodes.query("idpv", "*");
       
Node node = null;
       
while (hits.iterator().hasNext()) {
            node
= hits.iterator().next();
             layerIndex
.add(node, "", "");            
       
}
        hits
.close();
        tx
.success();
        tx
.finish();

I can query it without problems..

Thanks,
Rita

Peter Neubauer

unread,
Jul 15, 2013, 10:42:04 AM7/15/13
to Neo4j User
Hi Rita,
just looked at the code - deleting indexes is not (yet) implemented. Could you please raise an issue on that?

/peter


Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Kids in Malmö this summer?        - http://www.kidscraft.se
Neo4j questions? Use GraphGist. - http://gist.neo4j.org


Rita

unread,
Jul 15, 2013, 11:20:45 AM7/15/13
to ne...@googlegroups.com

Rita

unread,
Jul 15, 2013, 11:57:07 AM7/15/13
to ne...@googlegroups.com
Nodes of the layer are still there also with removing one per time:

for (Node n : nodes) {
                layerIndex.remove(n);
}

Rita

Rita

unread,
Jul 16, 2013, 4:03:21 AM7/16/13
to ne...@googlegroups.com
Also this instruction for delete:

Layer layer = s.getLayer("layerIndexPV");
((RTreeIndex)layer.getIndex()).removeAll(true, l);

raise the error :


Exception in thread "main" org.neo4j.graphdb.NotFoundException: More than one relationship[RTREE_REFERENCE, INCOMING]


For the moment I have solved removing:
  1. RTREE_REFERENCE relationships when they exceed 1 per node
  2. the directory which contains the spatial index
In this way in future I can rebuild the update spatial index.

Rita

Michael Hunger

unread,
Jul 16, 2013, 5:00:35 AM7/16/13
to ne...@googlegroups.com
Do you have multiple spatial indexes (implying multiple r-trees?) then initially when you are trying to delete them?

Michael

Rita

unread,
Jul 16, 2013, 5:44:14 AM7/16/13
to ne...@googlegroups.com
Hi Michael,
no, in this case I have only one spatial index when I try to delete it.

Rita
Reply all
Reply to author
Forward
0 new messages