Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Jena Spatial - seems to browse the entire index spatial index multiple time

$
0
0
Hi everybody,

I'm still trying to use Jena Spatial and got a strange behavior.

I'm running a set of query to count all the entity of a given class in a radius of a certain point.
For example, there are 3 interesting entity - ent1,ent2,ent3- and 3 classes - cl1,cl2,cl3-.
I search for every entity of type cl1 near to ent1, then near to ent2, and last near to ent3.
Then I do it for cl2 etc...

My problem is that a certain point (always the same), when spatial matching become possible, it seems that JENA spatial is doing something wrong, and browse all the index many times, looking for something. A debug logging extract will follow ([1]).

Any idea of what can cause such a loop ?

The queries that I execute are :

#Query that return the entity of class %class% in a radius of %distance%
#of the coordinate %entity_latitude% %entity_longitude%
PREFIX spatial: <http://jena.apache.org/spatial#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?entity
WHERE{
   
#simple entity here. i.e. entity that are point.
    {
        ?entity a %class% .
        ?entity a <http://linkedgeodata.org/meta/Node> .
        ?entity spatial:withinCircle (%entity_latitude% %entity_longitude% %distance% 'm') .
    }
    UNION
    #complex entity here
    {
        ?entity a %class% .
        ?entity <http://geovocab.org/geometry#geometry> ?geometry .
        ?geometry <http://linkedgeodata.org/ontology/posSeq> ?sequence .
        ?sequence ?blankPredicate ?nodeGeometry.
        ?node <http://geovocab.org/geometry#geometry> ?nodeGeometry .
        ?node a <http://linkedgeodata.org/meta/Node> .
        ?node spatial:withinCircle (%entity_latitude% %entity_longitude% %distance% 'm') .
    }

where %class% is the class of searched entity (ex: cl1), %entity_latitude% %entity_longitude% are the lat/long properties of the entity of interest (ex: ent1 lat and long) and, obviously, %distance% is the radius of the search.

I execute such queries on data coming from Linked Open Geo Data(http://linkedgeodata.org)that are conversion of Open Street Map data to RDF.

Here comes an excerpt of the log file :

2014-08-04 09:23:49,407 [DEBUG] (ReorderTransformationSubstitution.java:reorder:88) Reorder: (?entity <::type> <::AbandonedRailway>) (?entity <::type> <::Node>)
2014-08-04 09:23:49,407 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:144) >> Input
    0        5 : ?entity <::type> <::AbandonedRailway>
    1        5 : ?entity <::type> <::Node>
2014-08-04 09:23:49,407 [DEBUG]
(ReorderTransformationSubstitution.java:chooseNext:153) << Output
    ?entity <::type> <::AbandonedRailway>
2014-08-04 09:23:49,407 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:144) >> Input
    0          : null
    1        1 : TERM <::type> <::Node>
2014-08-04 09:23:49,407 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:153) << Output
    TERM <::type> <::Node>
2014-08-04 09:23:49,407 [DEBUG] (ReorderTransformationSubstitution.java:reorder:88) Reorder: (?entity <::type> <::AbandonedRailway>) (?entity <::geometry> ?geometry) (?geometry <::posSeq> ?sequence) (?sequence
?blankPredicate ?nodeGeometry) (?node <::geometry> ?nodeGeometry) (?node <::type> <::Node>)
2014-08-04 09:23:49,408 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:144) >> Input
    0        5 : ?entity <::type> <::AbandonedRailway>
    1       30 : ?entity <::geometry> ?geometry
    2       30 : ?geometry <::posSeq> ?sequence
    3      100 : ?sequence ?blankPredicate ?nodeGeometry
    4       30 : ?node <::geometry> ?nodeGeometry
    5        5 : ?node <::type>
<::Node>
2014-08-04 09:23:49,408 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:153) << Output
    ?entity <::type> <::AbandonedRailway>
2014-08-04 09:23:49,408 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:144) >> Input
    0          : null
    1        2 : TERM <::geometry> ?geometry
    2       30 : ?geometry <::posSeq> ?sequence
    3      100 : ?sequence ?blankPredicate ?nodeGeometry
    4       30 : ?node <::geometry> ?nodeGeometry
    5        5 : ?node <::type> <::Node>
2014-08-04 09:23:49,408 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:153) << Output
    TERM <::geometry> ?geometry
2014-08-04 09:23:49,408 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:144) >> Input
    0          : null
    1          : null
    2        2 : TERM <::posSeq> ?sequence
    3      100 : ?sequence ?blankPredicate ?nodeGeometry
    4       30 : ?node
<::geometry> ?nodeGeometry
    5        5 : ?node <::type> <::Node>
2014-08-04 09:23:49,408 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:153) << Output
    TERM <::posSeq> ?sequence
2014-08-04 09:23:49,408 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:144) >> Input
    0          : null
    1          : null
    2          : null
    3       10 : TERM ?blankPredicate ?nodeGeometry
   
4       30 : ?node <::geometry> ?nodeGeometry
    5        5 : ?node <::type> <::Node>
2014-08-04 09:23:49,408 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:153) << Output
    ?node <::type> <::Node>
2014-08-04 09:23:49,408 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:144) >> Input
    0          : null
    1          : null
    2          : null
    3       10 : TERM ?blankPredicate ?nodeGeometry
    4        2 : TERM <::geometry> ?nodeGeometry
    5          : null
2014-08-04 09:23:49,408 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:153) << Output
    TERM <::geometry> ?nodeGeometry
2014-08-04 09:23:49,409 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:144) >> Input
    0          : null
    1          : null
    2          : null
    3       10 : TERM ?blankPredicate
TERM
    4          : null
    5          : null
2014-08-04 09:23:49,409 [DEBUG] (ReorderTransformationSubstitution.java:chooseNext:153) << Output
    TERM ?blankPredicate TERM
2014-08-04 09:23:49,779 [DEBUG] (SpatialOperationWithCircleBase.java:objectToStruct:178) Trying SpatialMatch: (Circle(Pt(x=-0.078548,y=51.52302), d=0.0° 0.10km) -1 IsWithin)
2014-08-04 09:23:57,118 [DEBUG] (SpatialOperationWithCircleBase.java:objectToStruct:178) Trying SpatialMatch: (Circle(Pt(x=-0.078548,y=51.52302), d=0.0° 0.10km) -1 IsWithin)
[...]
2014-08-04 09:27:24,324 [DEBUG] (SpatialOperationWithCircleBase.java:objectToStruct:178) Trying SpatialMatch: (Circle(Pt(x=-0.078548,y=51.52302), d=0.0° 0.10km) -1 IsWithin)

The SpatialOperationWithCircleBase is executed 38 times before going to the next step. It takes near to 20 minutes to get a result for a simple spatial query with the current implementation, I assume that this isn't normal.

Thanks in advance,

VAISSE-LESTEVEN Arthur.

Viewing all articles
Browse latest Browse all 5648

Trending Articles