Search in sources :

Example 1 with TupleExprSparqlStatisticsCollector

use of query.statistics.TupleExprSparqlStatisticsCollector 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);
    }
}
Also used : TupleExprSparqlStatisticsCollector(query.statistics.TupleExprSparqlStatisticsCollector) StandardizingSPARQLParser(openrdffork.StandardizingSPARQLParser) QueryContainerSparqlStatisticsCollector(query.statistics.QueryContainerSparqlStatisticsCollector) MalformedQueryException(org.openrdf.query.MalformedQueryException) MalformedQueryException(org.openrdf.query.MalformedQueryException) NoURIException(utility.NoURIException)

Aggregations

StandardizingSPARQLParser (openrdffork.StandardizingSPARQLParser)1 MalformedQueryException (org.openrdf.query.MalformedQueryException)1 QueryContainerSparqlStatisticsCollector (query.statistics.QueryContainerSparqlStatisticsCollector)1 TupleExprSparqlStatisticsCollector (query.statistics.TupleExprSparqlStatisticsCollector)1 NoURIException (utility.NoURIException)1