Jena/Arq:查询处理卡住了



如果以下SPARQL查询有问题:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX :<http://www.test.at/DA.owl#>
SELECT ?ModuleName ?SLAName ?SLOName ?SLOTypeName ?SLOTHV (AVG(DISTINCT ?SLTTV) AS ?AVGTrackValue)  (COUNT(DISTINCT ?SLT) AS ?SLTCOUNT) 
WHERE {
    ?Module rdf:type :ServiceModule .
    ?SLA rdf:type :ServiceLevelAgreement.
    ?SLO rdf:type :ServiceLevelObjective .
    ?SLT rdf:type :ServiceLevelTracking .
    ?Day rdf:type :Day .
    ?Holiday rdf:type :Holiday .
    ?rel1 rdf:type :RelationFact .
    ?rel2 rdf:type :RelationFact .
    ?rel3 rdf:type :RelationFact .
    ?rel4 rdf:type :RelationFact .
    ?rel5 rdf:type :RelationFact .
    ?Module :hasName ?ModuleName .
    ?SLA :hasName ?SLAName .
    ?SLO :hasName ?SLOName .
    ?SLO :hasType ?SLOType . 
    ?SLO :hasThresholdValue ?SLOTHV .
    ?SLOType :hasName ?SLOTypeName .            
    ?SLT :hasDayName ?SLTDayName .
    ?SLT :hasType ?SLTType .        
    ?SLT :hasTrackedDateTime ?trackTime .
    ?SLT :hasTrackedValue ?SLTTV .
    ?Day :hasDayName ?DayName .
    ?Holiday :hasDate ?HolidayDate .
    ?Holiday :hasStartTime ?HolidayStartTime .
    ?Holiday :hasEndTime ?HolidayEndTime .      
    ?rel1 :hasParent ?Module .
    ?rel1 :hasChild ?SLA .  
    ?rel2 :hasParent ?Module.
    ?rel2 :hasChild ?SLT .      
    ?rel3 :hasParent ?SLA .
    ?rel3 :hasChild ?SLO .
    ?rel4 :hasParent ?SLA .
    ?rel4 :hasChild ?Day .
    ?rel5 :hasParent ?SLA .
    ?rel5 :hasChild ?Holiday .  
    Filter(regex(str(?ModuleName), "E-mail")) .
    Filter(?SLOType = ?SLTType) .
    Filter(xsd:dateTime(?trackTime)  >=  xsd:dateTime("2012-08-15T12:00:00") && ?trackTime  <  xsd:dateTime("2012-08-15T13:00:00")) .
    Filter(?DayName = ?SLTDayName || (xsd:dateTime("2012-08-15T00:00:00") = ?HolidayDate && xsd:dateTime(?trackTime) >= xsd:dateTime("2012-08-15T12:00:00") &&  xsd:dateTime(?trackTime) < xsd:dateTime("2012-08-15T14:00:00")))
} 
GROUP BY ?ModuleName ?SLAName ?SLOName ?SLOTypeName ?SLOTHV
HAVING (?AVGTrackValue < ?SLOTHV)

在 potégé 4.2 中,此查询可以毫无问题地工作,并在 1 秒内返回结果。此外,SPARQLer Query Validator (http://www.sparql.org/query-validator.html) 的语法检查表明 SPARQL 查询有效。但是使用 jena arq 引擎,查询处理在等待结果集时一直卡住。我从命令行使用 jena-arq-2.9.1 以及在带有以下代码的 java 应用程序中尝试了它:

    Query q = QueryFactory.create(queryString);
    QueryExecution qexec = QueryExecutionFactory.create(q, currentOntologyModel);
    try {
        ResultSet results = qexec.execSelect();
        while (results.hasNext()) {
            QuerySolution soln = results.nextSolution();
            .
            .
            .
            <some other code>
            .
            .
            .
            }
        }
    } finally {
        qexec.close();
    }

也许有人知道问题是什么。

据推测,数据在内存中。

看起来查询优化器没有找到有效的计划。 开始时所有未连接的rdf:type都可能导致计算效率低下的中间交叉积。

重新排序三重模式可能会有所帮助(mayeb 将 rdf:type 移到最后? 查询本身不足以知道 - 它取决于数据)。 如果您发现更快的订单,请将其发送到 Apache 的耶拿用户列表。

谢谢你的回答安迪。这似乎是执行计划的问题。现在我正在使用子选择来检索 ?SLT 和查询工作完美。这是现在有效的查询:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX :<http://www.test.at/DA.owl#>
SELECT ?ModuleName ?SLAName ?SLOName ?SLOTypeName ?SLOTHV (AVG(DISTINCT ?SLTTV) AS     ?AVGTrackValue)  (COUNT(DISTINCT ?SLT) AS ?SLTCOUNT) 
WHERE {
?Module rdf:type :ServiceModule .
?SLA rdf:type :ServiceLevelAgreement.
?SLO rdf:type :ServiceLevelObjective .
?Day rdf:type :Day .
?Holiday rdf:type :Holiday .
?rel1 rdf:type :RelationFact .
?rel3 rdf:type :RelationFact .
?rel4 rdf:type :RelationFact .
?rel5 rdf:type :RelationFact .
?Module :hasName ?ModuleName .
?SLA :hasName ?SLAName .
?SLO :hasName ?SLOName .
?SLO :hasType ?SLOType . 
?SLO :hasThresholdValue ?SLOTHV .
?SLOType :hasName ?SLOTypeName .            
?SLT :hasDayName ?SLTDayName .
?SLT :hasType ?SLTType .        
?SLT :hasTrackedDateTime ?trackTime .
?SLT :hasTrackedValue ?SLTTV .
?Day :hasDayName ?DayName .
?Holiday :hasDate ?HolidayDate .
?Holiday :hasStartTime ?HolidayStartTime .
?Holiday :hasEndTime ?HolidayEndTime .      
?rel1 :hasParent ?Module .
?rel1 :hasChild ?SLA .     
?rel3 :hasParent ?SLA .
?rel3 :hasChild ?SLO .
?rel4 :hasParent ?SLA .
?rel4 :hasChild ?Day .
?rel5 :hasParent ?SLA .
?rel5 :hasChild ?Holiday .
{
    SELECT ?SLT ?SLTType ?ModuleName
    WHERE {
    ?SLT rdf:type :ServiceLevelTracking .
    ?rel2 rdf:type :RelationFact .
    ?Module :hasName ?ModuleName .
    Filter(regex(str(?ModuleName), "E-mail")) .
    ?rel2 :hasParent ?Module.
    ?rel2 :hasChild ?SLT    
    }
}   
Filter(?SLOType = ?SLTType) .
Filter(xsd:dateTime(?trackTime)  >=  xsd:dateTime("2012-08-15T12:00:00") && ?trackTime  <  xsd:dateTime("2012-08-15T13:00:00")) .
Filter(?DayName = ?SLTDayName || (xsd:dateTime("2012-08-15T00:00:00") = ?HolidayDate && xsd:dateTime(?trackTime) >= xsd:dateTime("2012-08-15T12:00:00") &&  xsd:dateTime(?trackTime) < xsd:dateTime("2012-08-15T14:00:00")))
} 
GROUP BY ?ModuleName ?SLAName ?SLOName ?SLOTypeName ?SLOTHV
HAVING (?AVGTrackValue < ?SLOTHV)

相关内容

  • 没有找到相关文章

最新更新