GraphDB 8.6.1 Free-地理空间谓词不适用于运行时,但适用于Workbench

时间:2018-12-06 12:54:29

标签: geospatial graphdb geosparql

我正在使用未启用规则集的回购。 Query_1 使用 geof:sfIntersects(),而 Query_2 使用 geo:sfIntersects 谓词。 使用Workbench v8.6.1,Query_1可以正确执行,而Query_2不能正确执行,不返回任何行,如文档中所述。 启用GeoSPARQL插件后,使用工作台可以正确执行两个查询,但是Query_2更快。 使用Java POM中的Runtime v8.6.1,我尝试针对启用了GeoSPARQL插件的仓库执行Query_1和Query_2。 Query_1可以正确执行(与Workbench一样),但是Query_2不能正确执行而不返回任何行(就像禁用了GeoSPARQL插件一样!)。 我有证据表明已启用GeoSPARQL插件,因为如果我在工作台上重复执行相同的任务,则两个查询都会成功,同时 /storage/GeoSPARQL/v2/config.properties 具有以下内容:

#GeoSPARQL configuration
#Thu Dec 06 09:30:54 EET 2018
precision=11
prefixtree=QUAD
prefixtree.current=QUAD
precision.current=11
enabled=true

java选项正确指向 -Dregister-external-plugins = / home / tioannid / graphdb-free-8.6.1 / lib / plugins

查询_1:

PREFIX geof: <http://www.opengis.net/def/function/geosparql/> 
PREFIX geo: <http://www.opengis.net/ont/geosparql#>  
PREFIX lgd: <http://data.linkedeodata.eu/ontology#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?s1 ?o1 WHERE { 
 ?s1 geo:asWKT ?o1 . 
  FILTER(geof:sfIntersects(?o1, "POLYGON((23.708496093749996 37.95719224376526,22.906494140625 40.659805938378526,11.524658203125002 48.16425348854739,-0.1181030273437499 51.49506473014367,-3.2189941406250004 55.92766341247031,-5.940856933593749 54.59116279530599,-3.1668090820312504 51.47967237816337,23.708496093749996 37.95719224376526))"^^<http://www.opengis.net/ont/geosparql#wktLiteral>)). 
} 

5782 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Version: 8.6, revision: -1564293007
5789 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Build date: Wed Jul 18 17:58:42 EEST 2018
5846 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Started repository scalability_10K in READ/WRITE mode.
5846 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'partialRDFS' to default value 'false'
...
6841 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Searching for plugins available in the classpath...
6877 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin rdfrank
6878 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin direct
6878 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin geospatial
6878 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin notifications
6879 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin expose-entity
6879 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin literals-index
6879 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin script
6879 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin plugincontrol
6880 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin magic-predicates
6880 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'register-plugins' to default value '[]'
6880 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Registering external plugins...
6888 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Scanning /home/tioannid/graphdb-free-8.6.1/lib/plugins/sparql-mm for plugins
6902 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin sparql-mm
6903 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Scanning /home/tioannid/graphdb-free-8.6.1/lib/plugins/lucene-connector for plugins
7021 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin lucene-connector
7021 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Scanning /home/tioannid/graphdb-free-8.6.1/lib/plugins/dependencies-plugin for plugins
7030 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin dependencies-plugin
7030 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Scanning /home/tioannid/graphdb-free-8.6.1/lib/plugins/lucene for plugins
7057 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin lucene
7057 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Scanning /home/tioannid/graphdb-free-8.6.1/lib/plugins/autocomplete-plugin for plugins
7074 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin autocomplete
7074 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Scanning /home/tioannid/graphdb-free-8.6.1/lib/plugins/graphdb-geosparql-plugin for plugins
7136 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin GeoSPARQL
7137 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'disable-plugins' to default value '[]'
7140 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugins... (DEFAULT)
7141 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'expose-entity'
7249 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'autocomplete'
7251 [main] INFO  com.ontotext.trree.plugin.autocomplete.AutocompletePluginUtils  - >>>>>>>> AutocompletePlugin: No configuration file found at /media/sf_VM_Shared/PHD/GraphDB_Repos/repositories/scalability_10K/storage/autocomplete/config.properties. Assuming default options for plugin.
7257 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'direct'
7259 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'lucene'
7263 [main] INFO  com.ontotext.plugin.lucene  - No Lucene indices were found
7263 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'plugincontrol'
7264 [main] INFO  com.ontotext.trree.plugin.plugincontrol.PluginControlPlugin  - Plugin:plugincontrol initialized
7264 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'script'
7265 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'magic-predicates'
7265 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering InverseMagicPredicate: http://spinrdf.org/spif#foreach
7266 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering TupleFunction: http://www.openrdf.org/contrib/lucenesail#search
7266 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering TupleFunction: http://jena.hpl.hp.com/ARQ/list#length
7266 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering InverseMagicPredicate: http://jena.hpl.hp.com/ARQ/property#concat
7266 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering InverseMagicPredicate: http://spinrdf.org/spif#for
7267 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering TupleFunction: http://www.openrdf.org/contrib/lucenesail#withinDistance
7267 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering InverseMagicPredicate: http://spinrdf.org/spif#split
7267 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering TupleFunction: http://jena.hpl.hp.com/ARQ/list#member
7267 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering TupleFunction: http://jena.hpl.hp.com/ARQ/list#index
7267 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering InverseMagicPredicate: http://jena.hpl.hp.com/ARQ/property#strSplit
7267 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'literals-index'
7312 [main] INFO  com.ontotext.plugin.literals-index  - Literals indices restored.
7312 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'geospatial'
7313 [main] INFO  com.ontotext.trree.plugin.geo.GeoSpatialPlugin  - Plugin:geospatial initialized
7314 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'sparql-mm'
7349 [main] INFO  com.ontotext.graphdb.sparqlmm.FunctionLoader  - Registered 48 functions from package com.github.tkurz.sparqlmm.function.
7349 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'dependencies-plugin'
7355 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'GeoSPARQL'
9407 [main] INFO  com.ontotext.plugin.GeoSPARQL  - >>>>>>>> GeoSPARQL: Initializing Lucene indexer...
9612 [main] INFO  com.ontotext.plugin.GeoSPARQL  - >>>>>>>> GeoSPARQL: Lucene indexer initialized!
9641 [main] INFO  com.ontotext.trree.geosparql.FunctionLoader  - Registered 50 functions from package com.useekm.geosparql.
9641 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'lucene-connector'
9660 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'rdfrank'
9682 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'notifications'
9686 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Finished initializing plugins
9687 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'graphdb.page.cache.size' to default value '3.6G'
9830 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'do.resolve.entities' to default value 'true'
9830 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'do.load.data' to default value 'true'
9830 [main] INFO  com.ontotext.rio.parallel.ParallelLoader  - Data will be parsed + resolved + loaded.
10019 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'use.parallel.file.inserts' to default value 'true'
10030 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'custom.validation.queries.file' to default value 'null'
10058 [pool-3-thread-1] INFO  GraphDBSUT  - Evaluating query...
10293 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'deduplicate.construct' to default value 'true'
10450 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'reuse.vars.in.subselects' to default value 'false'
10473 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'in-clause-max-members' to default value '16'
10473 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'query.convert.values.clause' to default value 'true'
10488 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'hash.join' to default value 'false'
10488 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'merge.join' to default value 'false'
10489 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'PTO' to default value '2'
10489 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'FSIPC' to default value '2'
12418 [pool-3-thread-1] INFO  GraphDBSUT  - Query evaluated with 554 results and 0 scan errors!
12579 [main] INFO  Experiment  - Query executed (cold, 0, 0): 242902950 + 1910235260 = 2153138210, 554
12579 [main] INFO  GraphDBSUT  - Closing..
12579 [main] INFO  GraphDBSUT  - [GraphDB.close] Closing connection...

Query_2日志:

PREFIX geof: <http://www.opengis.net/def/function/geosparql/> 
PREFIX geo: <http://www.opengis.net/ont/geosparql#>  
PREFIX lgd: <http://data.linkedeodata.eu/ontology#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?s1 ?o1 WHERE { 
 ?s1 geo:asWKT ?o1 . 
 ?s1 geo:sfIntersects "POLYGON((23.708496093749996 37.95719224376526,22.906494140625 40.659805938378526,11.524658203125002 48.16425348854739,-0.1181030273437499 51.49506473014367,-3.2189941406250004 55.92766341247031,-5.940856933593749 54.59116279530599,-3.1668090820312504 51.47967237816337,23.708496093749996 37.95719224376526))"^^<http://www.opengis.net/ont/geosparql#wktLiteral> . 
} 

5758 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Version: 8.6, revision: -1564293007
5764 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Build date: Wed Jul 18 17:58:42 EEST 2018
5820 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Started repository scalability_10K in READ/WRITE mode.
5820 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'partialRDFS' to default value 'false'
...
6978 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Searching for plugins available in the classpath...
7016 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin rdfrank
7017 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin direct
7018 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin geospatial
7018 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin notifications
7019 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin expose-entity
7019 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin literals-index
7021 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin script
7022 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin plugincontrol
7023 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin magic-predicates
7023 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'register-plugins' to default value '[]'
7023 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Registering external plugins...
7031 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Scanning /home/tioannid/graphdb-free-8.6.1/lib/plugins/sparql-mm for plugins
7045 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin sparql-mm
7045 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Scanning /home/tioannid/graphdb-free-8.6.1/lib/plugins/lucene-connector for plugins
7167 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin lucene-connector
7167 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Scanning /home/tioannid/graphdb-free-8.6.1/lib/plugins/dependencies-plugin for plugins
7175 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin dependencies-plugin
7175 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Scanning /home/tioannid/graphdb-free-8.6.1/lib/plugins/lucene for plugins
7194 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin lucene
7194 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Scanning /home/tioannid/graphdb-free-8.6.1/lib/plugins/autocomplete-plugin for plugins
7211 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin autocomplete
7211 [main] INFO  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Scanning /home/tioannid/graphdb-free-8.6.1/lib/plugins/graphdb-geosparql-plugin for plugins
7266 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Registering plugin GeoSPARQL
7266 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'disable-plugins' to default value '[]'
7267 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugins... (DEFAULT)
7268 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'expose-entity'
7367 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'autocomplete'
7369 [main] INFO  com.ontotext.trree.plugin.autocomplete.AutocompletePluginUtils  - >>>>>>>> AutocompletePlugin: No configuration file found at /media/sf_VM_Shared/PHD/GraphDB_Repos/repositories/scalability_10K/storage/autocomplete/config.properties. Assuming default options for plugin.
7374 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'direct'
7375 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'lucene'
7378 [main] INFO  com.ontotext.plugin.lucene  - No Lucene indices were found
7378 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'plugincontrol'
7379 [main] INFO  com.ontotext.trree.plugin.plugincontrol.PluginControlPlugin  - Plugin:plugincontrol initialized
7379 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'script'
7379 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'magic-predicates'
7380 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering InverseMagicPredicate: http://spinrdf.org/spif#foreach
7380 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering TupleFunction: http://www.openrdf.org/contrib/lucenesail#search
7381 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering TupleFunction: http://jena.hpl.hp.com/ARQ/list#length
7381 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering InverseMagicPredicate: http://jena.hpl.hp.com/ARQ/property#concat
7381 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering InverseMagicPredicate: http://spinrdf.org/spif#for
7381 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering TupleFunction: http://www.openrdf.org/contrib/lucenesail#withinDistance
7381 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering InverseMagicPredicate: http://spinrdf.org/spif#split
7381 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering TupleFunction: http://jena.hpl.hp.com/ARQ/list#member
7381 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering TupleFunction: http://jena.hpl.hp.com/ARQ/list#index
7381 [main] INFO  com.ontotext.plugin.magic-predicates  - Registering InverseMagicPredicate: http://jena.hpl.hp.com/ARQ/property#strSplit
7381 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'literals-index'
7427 [main] INFO  com.ontotext.plugin.literals-index  - Literals indices restored.
7428 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'geospatial'
7429 [main] INFO  com.ontotext.trree.plugin.geo.GeoSpatialPlugin  - Plugin:geospatial initialized
7430 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'sparql-mm'
7461 [main] INFO  com.ontotext.graphdb.sparqlmm.FunctionLoader  - Registered 48 functions from package com.github.tkurz.sparqlmm.function.
7461 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'dependencies-plugin'
7464 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'GeoSPARQL'
9320 [main] INFO  com.ontotext.plugin.GeoSPARQL  - >>>>>>>> GeoSPARQL: Initializing Lucene indexer...
9511 [main] INFO  com.ontotext.plugin.GeoSPARQL  - >>>>>>>> GeoSPARQL: Lucene indexer initialized!
9531 [main] INFO  com.ontotext.trree.geosparql.FunctionLoader  - Registered 50 functions from package com.useekm.geosparql.
9531 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'lucene-connector'
9544 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'rdfrank'
9561 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Initializing plugin 'notifications'
9563 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Finished initializing plugins
9563 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'graphdb.page.cache.size' to default value '3.6G'
9767 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'do.resolve.entities' to default value 'true'
9768 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'do.load.data' to default value 'true'
9768 [main] INFO  com.ontotext.rio.parallel.ParallelLoader  - Data will be parsed + resolved + loaded.
9957 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'use.parallel.file.inserts' to default value 'true'
9968 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'custom.validation.queries.file' to default value 'null'
10009 [pool-3-thread-1] INFO  GraphDBSUT  - Evaluating query...
10205 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'deduplicate.construct' to default value 'true'
10278 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'reuse.vars.in.subselects' to default value 'false'
10304 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'in-clause-max-members' to default value '16'
10304 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'query.convert.values.clause' to default value 'true'
11725 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'hash.join' to default value 'false'
11740 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'merge.join' to default value 'false'
11742 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'PTO' to default value '2'
11743 [pool-3-thread-1] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'FSIPC' to default value '2'
12162 [main] INFO  Experiment  - Query executed (cold, 0, 0): 86401 + 86401 = 86401, -1
12162 [main] INFO  GraphDBSUT  - Closing..
12162 [main] INFO  GraphDBSUT  - [GraphDB.close] Closing connection...

如果此功能仅在Workbench上正常工作,那就太浪费了。

致谢

1 个答案:

答案 0 :(得分:2)

在这里您可以找到一个小型应用程序,该应用程序使用 graphdb-free-runtime 对通过HTTP的远程存储库和由API创建的存储库进行查询:

import com.ontotext.trree.OwlimSchemaRepository;
import com.ontotext.trree.monitorRepository.MonitorRepository;
import org.eclipse.rdf4j.query.TupleQuery;
import org.eclipse.rdf4j.query.TupleQueryResult;
import org.eclipse.rdf4j.repository.Repository;
import org.eclipse.rdf4j.repository.RepositoryConnection;
import org.eclipse.rdf4j.repository.http.HTTPRepository;
import org.eclipse.rdf4j.rio.RDFFormat;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

public class GeoSparqlQuery {

    static String ENABLE_GEOSPARQL = "PREFIX : <http://www.ontotext.com/plugins/geosparql#>\n" +
            "\n" +
            "INSERT DATA {\n" +
            "  _:s :enabled \"true\" .\n" +
            "}";

    static String QUERY = "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" +
            "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n" +
            "SELECT *\n" +
            "WHERE {\n" +
            "    ?s1 geo:asWKT ?o1 .\n" +
            "    ?s1 geo:sfIntersects \"POLYGON ((5.458713474968683 52.524611984480096,5.458637011977173 52.524609190664023,5.458637214924984 52.524607132456225,5.458578935662133 52.524605001674729,5.458581008700381 52.524584006157092,5.458522758969258 52.524581893304763,5.458522961907719 52.524579826109878,5.45849061731855 52.524578650283736,5.458347292731427 52.524587723773628,5.458352380416623 52.524535603524541,5.458719649697075 52.524549006933817,5.458713474968683 52.524611984480096))\"\n" +
            "}";

    public static void main(String... args) throws IOException {
        testRemoteRepo();
        testNewRepo();
    }

    public static void testRemoteRepo() {
        Repository repo = new HTTPRepository("http://localhost:7200", "geosparql");
        repo.initialize();

        try (RepositoryConnection conn = repo.getConnection()) {
            queryReturnsResults(conn);
        } finally {
            repo.shutDown();
        }
    }

    public static void testNewRepo() throws IOException {
        File data = new File(GeoSparqlQuery.class.getClassLoader().getResource("data.ttl").getFile());
        File tempDir = Files.createTempDirectory("graphdb").toFile();
        tempDir.deleteOnExit();

        OwlimSchemaRepository sail = new OwlimSchemaRepository();
        sail.setDataDir(tempDir);
        Repository repo = new MonitorRepository(sail);
        repo.initialize();

        try (RepositoryConnection conn = repo.getConnection()) {
            conn.add(data, "urn:base", RDFFormat.TURTLE);
            conn.prepareUpdate(ENABLE_GEOSPARQL).execute();

            queryReturnsResults(conn);
        } finally {
            repo.shutDown();
        }
    }

    private static void queryReturnsResults(RepositoryConnection conn) {
        TupleQuery tupleQuery = conn.prepareTupleQuery(QUERY);
        TupleQueryResult result = tupleQuery.evaluate();

        if (!result.hasNext()) {
            throw new RuntimeException("No results returned");
        }
        while (result.hasNext()) {
            System.out.println(result.next().toString());
        }
    }
}

使用选项 -Dgraphdb.extra.plugins = 插件路径 运行该应用程序。
pom.xml 中,我包括了 graphdb-runtime ,但排除了一些包含 lucene 的依赖项(因为在类路径上可能有多个lucene是危险):

<dependency>
    <groupId>com.ontotext.graphdb</groupId>
    <artifactId>graphdb-free-runtime</artifactId>
    <version>8.6.1</version>
    <exclusions>
        <exclusion>
            <groupId>org.eclipse.rdf4j</groupId>
            <artifactId>rdf4j-storage</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.eclipse.rdf4j</groupId>
            <artifactId>rdf4j-sail-lucene</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.eclipse.rdf4j</groupId>
            <artifactId>rdf4j-sail-lucene-spin</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.eclipse.rdf4j</groupId>
            <artifactId>rdf4j-sail-elasticsearch</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.eclipse.rdf4j</groupId>
            <artifactId>rdf4j-sail-solr</artifactId>
        </exclusion>
    </exclusions>
</dependency>