use of query.statistics.QueryContainerSparqlStatisticsCollector in project QueryAnalysis by Wikidata.
the class OpenRDFQueryHandler method computeSparqlStatistics.
@Override
protected void computeSparqlStatistics() {
if (getValidityStatus() != QueryHandler.Validity.VALID) {
this.sparqlStatistics = new HashMap<>();
return;
}
try {
ASTQueryContainer queryContainer = new StandardizingSPARQLParser().getDebuggedASTQueryContainer(getQueryString(), BASE_URI);
QueryContainerSparqlStatisticsCollector queryContainerSparqlStatisticsCollector = new QueryContainerSparqlStatisticsCollector();
queryContainer.jjtAccept(queryContainerSparqlStatisticsCollector, null);
this.sparqlStatistics = queryContainerSparqlStatisticsCollector.getStatistics();
TupleExprSparqlStatisticsCollector tupleExprSparqlStatisticsCollector = new TupleExprSparqlStatisticsCollector();
this.query.getTupleExpr().visitChildren(tupleExprSparqlStatisticsCollector);
this.query.getTupleExpr().visit(tupleExprSparqlStatisticsCollector);
this.sparqlStatistics.putAll(tupleExprSparqlStatisticsCollector.getStatistics());
this.primaryLanguage = tupleExprSparqlStatisticsCollector.getPrimaryLanguage();
} catch (TokenMgrError | MalformedQueryException e) {
logger.error("Failed to parse the query although it was found valid - this is a serious bug.", e);
} catch (VisitorException e) {
logger.error("Failed to calculate the SPARQL Keyword Statistics. Error occured while visiting the query.", e);
} catch (Exception e) {
logger.error("An unknown error occured while computing the sparql statistics: ", e);
}
}
Aggregations