From 08749c199e2b518aad33b827c5816084f258d350 Mon Sep 17 00:00:00 2001 From: anquetil Date: Wed, 22 Jul 2026 10:16:36 +0200 Subject: [PATCH] removing dead code in corese.core.next.query --- .../core/next/query/api/QueryLanguage.java | 7 -- .../core/next/query/api/Transformer.java | 21 ---- .../api/exception/QuerySyntaxException.java | 18 ---- .../exception/QueryValidationException.java | 9 -- .../UnsupportedQueryFeatureException.java | 9 -- .../core/next/query/api/io/ResultFormat.java | 43 -------- .../next/query/api/result/BindingSet.java | 19 ---- .../query/api/result/GraphQueryResult.java | 30 ------ .../query/api/result/TupleQueryResult.java | 12 --- .../query/impl/parser/SparqlAstBuilder.java | 22 ---- .../impl/parser/SparqlQueryAstBuilder.java | 25 ----- .../listener/SelectQueryAstListener.java | 4 +- .../rule/AbstractSemanticValidationRule.java | 9 -- .../impl/result/CoreseGraphQueryResult.java | 9 -- .../impl/sparql/ast/ClearRequestAst.java | 8 +- .../impl/sparql/ast/CreateRequestAst.java | 9 -- .../query/impl/sparql/ast/LoadRequestAst.java | 10 -- .../query/impl/sparql/ast/ProjectionAsts.java | 9 -- .../impl/sparql/ast/UpdateRequestAst.java | 4 - .../ast/constraint/FunctionCallAst.java | 7 -- .../impl/sparql/ast/constraint/StrLenAst.java | 6 -- .../query/impl/sparql/ast/path/PathAst.java | 7 -- .../sparql/bridge/CoreseAstQueryBuilder.java | 9 -- .../sparql/bridge/SparqlAstToExpression.java | 16 +-- .../json/JsonResultSerializerOptions.java | 9 -- .../xml/XmlResultSerializerOptions.java | 20 ---- .../query/kgram/api/core/BindingContext.java | 16 --- .../core/next/query/kgram/api/core/Edge.java | 76 +------------ .../core/next/query/kgram/api/core/Node.java | 10 -- .../query/kgram/api/core/PointerType.java | 4 - .../query/kgram/api/core/Pointerable.java | 4 - .../query/kgram/api/query/ProcessVisitor.java | 78 -------------- .../next/query/kgram/api/query/Producer.java | 30 ------ .../core/next/query/kgram/core/Eval.java | 4 - .../core/next/query/kgram/core/ExpEdge.java | 24 ----- .../core/next/query/kgram/core/Mapping.java | 75 ------------- .../core/next/query/kgram/core/Mappings.java | 16 --- .../core/next/query/kgram/core/Memory.java | 20 ---- .../core/next/query/kgram/core/Query.java | 102 ------------------ .../next/query/kgram/core/QuerySorter.java | 5 - .../next/query/kgram/event/EventImpl.java | 4 - .../core/next/query/kgram/filter/Checker.java | 21 +--- .../core/next/query/kgram/path/GraphPath.java | 6 -- .../next/query/kgram/sorter/core/QPGraph.java | 9 -- .../kgram/tool/ApproximateSearchEnv.java | 42 -------- .../query/kgram/tool/EnvironmentImpl.java | 6 +- .../next/query/kgram/tool/ResultsImpl.java | 6 +- .../kgram/tool/StorageManagerProducer.java | 11 -- .../ast/TriplePatternAstTestSupport.java | 3 - 49 files changed, 7 insertions(+), 916 deletions(-) diff --git a/src/main/java/fr/inria/corese/core/next/query/api/QueryLanguage.java b/src/main/java/fr/inria/corese/core/next/query/api/QueryLanguage.java index 7e4d16760..394074b92 100644 --- a/src/main/java/fr/inria/corese/core/next/query/api/QueryLanguage.java +++ b/src/main/java/fr/inria/corese/core/next/query/api/QueryLanguage.java @@ -30,13 +30,6 @@ public enum QueryLanguage { QueryLanguage(String name) { this.name = name; } - /** - * Returns the canonical name of the query language. - * - * @return the language name as a string - */ - public String getName() { return name; } - @Override public String toString() { return name; } } \ No newline at end of file diff --git a/src/main/java/fr/inria/corese/core/next/query/api/Transformer.java b/src/main/java/fr/inria/corese/core/next/query/api/Transformer.java index 38f293c11..e3c7a550b 100644 --- a/src/main/java/fr/inria/corese/core/next/query/api/Transformer.java +++ b/src/main/java/fr/inria/corese/core/next/query/api/Transformer.java @@ -29,25 +29,4 @@ Query compileQuery(String queryString, QueryLanguage queryLanguage) Update compileUpdate(String updateString, QueryLanguage queryLanguage) throws QuerySyntaxException; - /** - * Convenience method to compile a SPARQL query. - * - * @param queryString the SPARQL query text - * @return the compiled query - * @throws QuerySyntaxException if the query string is syntactically invalid - */ - default Query compileSPARQL(String queryString) throws QuerySyntaxException { - return compileQuery(queryString, QueryLanguage.SPARQL); - } - - /** - * Convenience method to compile a SPARQL UPDATE. - * - * @param updateString the SPARQL UPDATE text - * @return the compiled update - * @throws QuerySyntaxException if the update string is syntactically invalid - */ - default Update compileSPARQLUpdate(String updateString) throws QuerySyntaxException { - return compileUpdate(updateString, QueryLanguage.SPARQL); - } } \ No newline at end of file diff --git a/src/main/java/fr/inria/corese/core/next/query/api/exception/QuerySyntaxException.java b/src/main/java/fr/inria/corese/core/next/query/api/exception/QuerySyntaxException.java index 98ccd9e81..f97a137db 100644 --- a/src/main/java/fr/inria/corese/core/next/query/api/exception/QuerySyntaxException.java +++ b/src/main/java/fr/inria/corese/core/next/query/api/exception/QuerySyntaxException.java @@ -75,24 +75,6 @@ public int getColumn() { return column; } - /** - * Checks whether line information is available for this syntax error. - * - * @return {@code true} if the line number is known (>= 1), {@code false} otherwise - */ - public boolean hasLineInfo() { - return line >= 1; - } - - /** - * Checks whether column information is available for this syntax error. - * - * @return {@code true} if the column number is known (>= 1), {@code false} otherwise - */ - public boolean hasColumnInfo() { - return column >= 1; - } - /** * Formats the error message to include line and column information when available. * diff --git a/src/main/java/fr/inria/corese/core/next/query/api/exception/QueryValidationException.java b/src/main/java/fr/inria/corese/core/next/query/api/exception/QueryValidationException.java index 1127ae8a0..de20ae0d9 100644 --- a/src/main/java/fr/inria/corese/core/next/query/api/exception/QueryValidationException.java +++ b/src/main/java/fr/inria/corese/core/next/query/api/exception/QueryValidationException.java @@ -15,13 +15,4 @@ public QueryValidationException(String message) { super(message); } - /** - * Constructs a QueryValidationException with a detail message and cause. - * - * @param message the detail message explaining why the query is invalid - * @param cause the underlying cause of the validation failure - */ - public QueryValidationException(String message, Throwable cause) { - super(message, cause); - } } diff --git a/src/main/java/fr/inria/corese/core/next/query/api/exception/UnsupportedQueryFeatureException.java b/src/main/java/fr/inria/corese/core/next/query/api/exception/UnsupportedQueryFeatureException.java index 70a9de447..939dd14b9 100644 --- a/src/main/java/fr/inria/corese/core/next/query/api/exception/UnsupportedQueryFeatureException.java +++ b/src/main/java/fr/inria/corese/core/next/query/api/exception/UnsupportedQueryFeatureException.java @@ -15,13 +15,4 @@ public UnsupportedQueryFeatureException(String message) { super(message); } - /** - * Constructs an UnsupportedQueryFeatureException with a detail message and cause. - * - * @param message the detail message explaining which query feature is not supported - * @param cause the underlying cause that exposed the unsupported feature - */ - public UnsupportedQueryFeatureException(String message, Throwable cause) { - super(message, cause); - } } diff --git a/src/main/java/fr/inria/corese/core/next/query/api/io/ResultFormat.java b/src/main/java/fr/inria/corese/core/next/query/api/io/ResultFormat.java index bbb9c3235..6e73af450 100644 --- a/src/main/java/fr/inria/corese/core/next/query/api/io/ResultFormat.java +++ b/src/main/java/fr/inria/corese/core/next/query/api/io/ResultFormat.java @@ -3,8 +3,6 @@ import fr.inria.corese.core.next.data.api.base.io.FileFormat; import java.util.List; -import java.util.Locale; -import java.util.Optional; /** * Describes the standard SPARQL result serialization formats. @@ -51,47 +49,6 @@ public ResultFormat( super(name, extensions, mimeTypes); } - /** - * Finds a known SPARQL result format by its name (case-insensitive). - * - * @param name The name of the format (e.g., "XML"). - * @return An Optional containing the matching ResultFormat if found. - */ - public static Optional byName(String name) { - String n = name.toLowerCase(Locale.ROOT); - return all().stream() - .filter(format -> format.getName().equalsIgnoreCase(n)) - .findFirst(); - } - - /** - * Finds a known SPARQL result format by file extension (case-insensitive). - * - * @param extension The file extension (for example, {@code "srx"}). - * @return an optional containing the matching result format - */ - public static Optional byExtension(String extension) { - String ext = extension.toLowerCase(Locale.ROOT); - return all().stream() - .filter(format -> format.getExtensions().stream() - .anyMatch(e -> e.equalsIgnoreCase(ext))) - .findFirst(); - } - - /** - * Finds a known SPARQL result format by MIME type (case-insensitive). - * - * @param mimeType The MIME type (for example, {@code "application/sparql-results+json"}). - * @return an optional containing the matching result format - */ - public static Optional byMimeType(String mimeType) { - String mime = mimeType.toLowerCase(Locale.ROOT); - return all().stream() - .filter(format -> format.getMimeTypes().stream() - .anyMatch(m -> m.equalsIgnoreCase(mime))) - .findFirst(); - } - /** * Returns all known SPARQL result formats. * diff --git a/src/main/java/fr/inria/corese/core/next/query/api/result/BindingSet.java b/src/main/java/fr/inria/corese/core/next/query/api/result/BindingSet.java index 9bbdec979..2ed8716a6 100644 --- a/src/main/java/fr/inria/corese/core/next/query/api/result/BindingSet.java +++ b/src/main/java/fr/inria/corese/core/next/query/api/result/BindingSet.java @@ -4,10 +4,6 @@ import fr.inria.corese.core.next.query.api.TupleQuery; import java.util.Set; -import java.util.Spliterator; -import java.util.Spliterators; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; /** * A set of variable bindings representing a single solution in a SPARQL @@ -48,19 +44,4 @@ public interface BindingSet extends Iterable { */ Value getValue(String name); - /** - * Returns a sequential {@link Stream} over the bindings. - * - * @return a sequential stream over the bindings in this result - * @throws IllegalStateException if this result has been closed - */ - default Stream stream() { - return StreamSupport.stream( - Spliterators.spliteratorUnknownSize( - iterator(), - Spliterator.ORDERED | Spliterator.NONNULL - ), - false - ); - } } \ No newline at end of file diff --git a/src/main/java/fr/inria/corese/core/next/query/api/result/GraphQueryResult.java b/src/main/java/fr/inria/corese/core/next/query/api/result/GraphQueryResult.java index 2443457be..bc59f3668 100644 --- a/src/main/java/fr/inria/corese/core/next/query/api/result/GraphQueryResult.java +++ b/src/main/java/fr/inria/corese/core/next/query/api/result/GraphQueryResult.java @@ -5,8 +5,6 @@ import java.io.Closeable; import java.util.*; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; /** * Represents the result of evaluating a SPARQL CONSTRUCT or DESCRIBE query. @@ -55,34 +53,6 @@ public Statement next() { }; } - /** - * Returns all remaining statements as a {@link List}. - * - * @return a list containing all remaining statements (never {@code null}) - * @throws IllegalStateException if this result has been closed - */ - default List asList() { - List list = new ArrayList<>(); - this.forEach(list::add); - return list; - } - - /** - * Returns a sequential {@link Stream} over the statements in this result. - * - * @return a sequential stream over the statements in this result - * @throws IllegalStateException if this result has been closed - */ - default Stream stream() { - return StreamSupport.stream( - Spliterators.spliteratorUnknownSize( - iterator(), - Spliterator.ORDERED | Spliterator.NONNULL - ), - false - ); - } - /** * Closes this result and releases any underlying resources such as * I/O streams, network connections, or database cursors. diff --git a/src/main/java/fr/inria/corese/core/next/query/api/result/TupleQueryResult.java b/src/main/java/fr/inria/corese/core/next/query/api/result/TupleQueryResult.java index 49f12d4a2..e468aef19 100644 --- a/src/main/java/fr/inria/corese/core/next/query/api/result/TupleQueryResult.java +++ b/src/main/java/fr/inria/corese/core/next/query/api/result/TupleQueryResult.java @@ -68,18 +68,6 @@ public BindingSet next() { }; } - /** - * Returns all remaining results as a {@link List}. - * - * @return a list containing all remaining binding sets (never {@code null}) - * @throws IllegalStateException if this result has been closed - */ - default List asList() { - List list = new ArrayList<>(); - this.forEach(list::add); - return list; - } - /** * Returns a sequential {@link Stream} over the query results. * diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/parser/SparqlAstBuilder.java b/src/main/java/fr/inria/corese/core/next/query/impl/parser/SparqlAstBuilder.java index 4ab90e08e..0e39ec83c 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/parser/SparqlAstBuilder.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/parser/SparqlAstBuilder.java @@ -181,9 +181,6 @@ public List getPrefixDeclaration() { return this.prefixDeclarations; } - // --- Abstract query creation class --- - public abstract QueryAst getResult(); - // --- Pattern creation --- protected boolean hasCurrentGroup() { @@ -738,14 +735,6 @@ public TermAst termFromGraphTerm(SparqlParser.GraphTermContext ctx) { return this.iri(ctx.getText()); } - public TermAst termFromGraphRef(SparqlParser.GraphRefContext ctx) { - if (ctx.iriRef() != null) { - return termFromIriRef(ctx.iriRef()); - } else { - throw new QueryEvaluationException("Expecting an IRIRef in the Graph clause"); - } - } - public List termListFromObjectList(SparqlParser.ObjectListContext ctx) { List out = new ArrayList<>(); for (var obj : ctx.object_()) { @@ -1578,17 +1567,6 @@ public TermAst termFromAggregate(SparqlParser.AggregateContext ctx) { throw new QueryEvaluationException("Unsupported aggregate: " + ctx.getText()); } - public GraphRefAst graphRefFromGraphOrDefault(SparqlParser.GraphOrDefaultContext ctx) { - if (ctx.DEFAULT() != null) { - return GraphRefAsts.defaultGraph(); - } - if(ctx.iriRef() != null) { - IriAst graphIri = (IriAst) termFromIriRef(ctx.iriRef()); - return GraphRefAsts.graph(graphIri); - } - throw new QueryEvaluationException("Unexpected value for Graph reference or default " + ctx.getText()); - } - public GraphRefAst graphRefFromGraphRef(SparqlParser.GraphRefContext ctx) { if(ctx.iriRef() != null) { IriAst graphIri = (IriAst) termFromIriRef(ctx.iriRef()); diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/parser/SparqlQueryAstBuilder.java b/src/main/java/fr/inria/corese/core/next/query/impl/parser/SparqlQueryAstBuilder.java index 90c57384e..9ba882f7e 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/parser/SparqlQueryAstBuilder.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/parser/SparqlQueryAstBuilder.java @@ -187,13 +187,6 @@ public void setProjectionAll() { this.projection = ProjectionAsts.selectAll(); } - /** - * Sets explicit SELECT variables (e.g. SELECT ?s ?p). Variable names may include ? or $ prefix. - */ - public void setProjectionVariables(List variableNames) { - setProjectionVariables(variableNames, List.of()); - } - /** * Sets explicit SELECT variables where some may be introduced by {@code (expr AS ?var)}. * Variable names may include ? or $ prefix. @@ -266,17 +259,6 @@ public void setProjectionVariables( else this.projection = newProjection; } - /** - * Sets the projection from an existing AST. - */ - public void setProjection(ProjectionAst projection) { - ProjectionAst effectiveProjection = projection != null ? projection : ProjectionAsts.selectAll(); - if (hasCurrentSelect()) { - getCurrentSelectFrame().projection = effectiveProjection; - } - else this.projection = effectiveProjection; - } - public void addValues(List mappings) { this.values.addAll(mappings); } @@ -472,13 +454,6 @@ private SolutionModifierAst buildSolutionModifier(SelectFrame frame) { frame.offset); } - public boolean isOrdered() { - if (hasCurrentSelect()) { - return !getCurrentSelectFrame().orderConditions.isEmpty(); - } - return !this.orderConditions.isEmpty(); - } - /** * Set the order condition * @param expr either a variable or a contraint diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/parser/listener/SelectQueryAstListener.java b/src/main/java/fr/inria/corese/core/next/query/impl/parser/listener/SelectQueryAstListener.java index 194c97675..60c8f3626 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/parser/listener/SelectQueryAstListener.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/parser/listener/SelectQueryAstListener.java @@ -18,11 +18,9 @@ * In {@link #enterSelectQuery(SparqlParser.SelectQueryContext)} we: * 1. Call {@link SparqlQueryAstBuilder#enterSelectQuery()} to set query type. * 2. Extract the projection from the parse context (grammar: {@code (var_+ | '*')}) and call - * {@link SparqlQueryAstBuilder#setProjectionAll()} or {@link SparqlQueryAstBuilder#setProjectionVariables(List)}. + * {@link SparqlQueryAstBuilder#setProjectionAll()}. *

* The WHERE clause is built by {@link BgpAstListener} (enter/exit GroupGraphPattern, TriplesBlock, addTriple). - * At {@link SparqlAstBuilder#getResult()}, the builder produces a {@link fr.inria.corese.core.next.query.impl.sparql.ast.SelectQueryAst} - * with both {@link fr.inria.corese.core.next.query.impl.sparql.ast.ProjectionAst} and the WHERE group. *

* Grammar {@code subSelect} (nested {@code SELECT} in a group) uses the same {@link SparqlAstBuilder} stack frames as a top-level SELECT. *

diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/parser/semantic/rule/AbstractSemanticValidationRule.java b/src/main/java/fr/inria/corese/core/next/query/impl/parser/semantic/rule/AbstractSemanticValidationRule.java index 1d9a100f0..9dd470aa5 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/parser/semantic/rule/AbstractSemanticValidationRule.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/parser/semantic/rule/AbstractSemanticValidationRule.java @@ -6,7 +6,6 @@ import fr.inria.corese.core.next.query.impl.sparql.ast.ConstructQueryAst; import fr.inria.corese.core.next.query.impl.sparql.ast.DescribeQueryAst; import fr.inria.corese.core.next.query.impl.sparql.ast.GroupByAst; -import fr.inria.corese.core.next.query.impl.sparql.ast.GroupGraphPatternAst; import fr.inria.corese.core.next.query.impl.sparql.ast.QueryAst; import fr.inria.corese.core.next.query.impl.sparql.ast.SelectQueryAst; import fr.inria.corese.core.next.query.impl.sparql.ast.SolutionModifierAst; @@ -44,10 +43,6 @@ protected final Set collectVisibleVariables(QueryAst queryAst) { return variableScopeAnalyzer.collectVisibleVariables(queryAst); } - protected final Set collectVisibleVariables(GroupGraphPatternAst whereClause) { - return variableScopeAnalyzer.collectVisibleVariables(whereClause); - } - protected final Set collectReferencedVariables(TermAst term) { return variableScopeAnalyzer.collectReferencedVariables(term); } @@ -115,10 +110,6 @@ protected QueryDiagnostic buildOutOfScopeDiagnostic(String variableName, ScopeCl return buildOutOfScopeDiagnostic(getDiagnosticSource(), variableName, clause.label()); } - protected QueryDiagnostic buildOutOfScopeDiagnostic(String variableName, String clause) { - return buildOutOfScopeDiagnostic(getDiagnosticSource(), variableName, clause); - } - public static QueryDiagnostic buildOutOfScopeDiagnostic(String source, String variableName, String clause) { return new QueryDiagnostic( QueryDiagnostic.Kind.SEMANTIC_ERROR, diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/result/CoreseGraphQueryResult.java b/src/main/java/fr/inria/corese/core/next/query/impl/result/CoreseGraphQueryResult.java index 3c5884355..9d4c2de67 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/result/CoreseGraphQueryResult.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/result/CoreseGraphQueryResult.java @@ -1,6 +1,5 @@ package fr.inria.corese.core.next.query.impl.result; -import fr.inria.corese.core.next.data.api.Model; import fr.inria.corese.core.next.data.api.Statement; import fr.inria.corese.core.next.query.api.result.GraphQueryResult; @@ -13,14 +12,6 @@ public class CoreseGraphQueryResult implements GraphQueryResult { private Iterator iterator; - public CoreseGraphQueryResult(Model model) { - this.iterator = model.iterator(); - } - - public CoreseGraphQueryResult(Iterator it) { - this.iterator = it; - } - @Override public boolean hasNext() { return this.iterator.hasNext(); diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/ClearRequestAst.java b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/ClearRequestAst.java index ff9b86002..52992128c 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/ClearRequestAst.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/ClearRequestAst.java @@ -8,13 +8,7 @@ * @param silent Determine if the resolution of the query must be resolved silently or not. */ public record ClearRequestAst(GraphRefAst graphRef, boolean silent) implements UpdateRequestUnitAst { - /** - * Construct CLEAR query with empty prologue and a silent flag to false. - * @param graphRef targeted graph to be cleared - */ - public ClearRequestAst(GraphRefAst graphRef) { - this( graphRef, false); - } + @Override public void accept(AstVisitor visitor) { diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/CreateRequestAst.java b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/CreateRequestAst.java index 7e4ccc3e3..80ba5cb23 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/CreateRequestAst.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/CreateRequestAst.java @@ -22,15 +22,6 @@ public record CreateRequestAst(GraphRefAst graphRef, boolean silent) implements } } - /** - * Construct a CREATE query with the silent flag set to false. - * - * @param graphRef the named graph to create - */ - public CreateRequestAst(GraphRefAst graphRef) { - this(graphRef, false); - } - @Override public void accept(AstVisitor visitor) { visitor.visit(this); diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/LoadRequestAst.java b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/LoadRequestAst.java index 50bff0c90..6087f8822 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/LoadRequestAst.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/LoadRequestAst.java @@ -17,16 +17,6 @@ public record LoadRequestAst(GraphRefAst fromClause, GraphRefAst toClause, boole } - /** - * Construct a LOAD query with an empty prologue and a silent flag to false. - * @param fromClause From clause, set of graphs IRIs - * @param toClause To clause. Set of Graph IRIs - */ - public LoadRequestAst(GraphRefAst fromClause, GraphRefAst toClause) { - this(fromClause, toClause, false); - } - - @Override public void accept(AstVisitor visitor) { visitor.visit(this); diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/ProjectionAsts.java b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/ProjectionAsts.java index 2694896c2..aeb92fa47 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/ProjectionAsts.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/ProjectionAsts.java @@ -26,15 +26,6 @@ public static ProjectionAst of(List variables) { return new ProjectionAst(false, List.copyOf(variables), Set.of(), Map.of(), Map.of()); } - /** - * SELECT ?v1 (expr AS ?v2) ... : project plain variables and expression-bound variables. - * Expression-bound variables are those introduced by {@code (expr AS ?var)} in the SELECT clause; - * they are included in {@code variables} but are not required to be visible in the WHERE clause. - */ - public static ProjectionAst of(List variables, Set expressionBoundVariables) { - return of(variables, expressionBoundVariables, Map.of(), Map.of()); - } - /** * SELECT ?v1 (expr AS ?v2) ... with expression metadata retained for expression-bound projections. */ diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/UpdateRequestAst.java b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/UpdateRequestAst.java index 20a8a9ea6..6416683f1 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/UpdateRequestAst.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/UpdateRequestAst.java @@ -14,10 +14,6 @@ public record UpdateRequestAst(QueryPrologueAst prologue, List arguments) implements ExprAst { - FunctionCallAst(List args) { - this(args.getFirst(), args.subList(1, args.size() - 1)); - if (args.isEmpty()) { - throw new QuerySyntaxException("Unexpected number of arguments for function call constructor"); - } - } @Override public String getName() { diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/constraint/StrLenAst.java b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/constraint/StrLenAst.java index 87e9876db..60bd69c35 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/constraint/StrLenAst.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/constraint/StrLenAst.java @@ -1,7 +1,5 @@ package fr.inria.corese.core.next.query.impl.sparql.ast.constraint; -import java.util.List; - import fr.inria.corese.core.next.query.impl.sparql.ast.TermAst; /** @@ -14,10 +12,6 @@ public StrLenAst(TermAst arg) { super(arg); } - public StrLenAst(List args) { - super(args); - } - @Override public String getName() { return "STRLEN"; diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/path/PathAst.java b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/path/PathAst.java index a4f56cf16..179f8956b 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/path/PathAst.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/path/PathAst.java @@ -1,7 +1,6 @@ package fr.inria.corese.core.next.query.impl.sparql.ast.path; import fr.inria.corese.core.next.query.impl.parser.semantic.support.VisitableAst; -import fr.inria.corese.core.next.query.impl.sparql.ast.TermAst; public sealed interface PathAst extends VisitableAst @@ -14,10 +13,4 @@ public sealed interface PathAst InversePathAst, NegatedPropertySetPathAst { - /** - * Wraps a single term (IRI, variable, etc.) as a property path. - */ - static PathAst from(TermAst term) { - return new PredicatePathAst(term); - } } diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/bridge/CoreseAstQueryBuilder.java b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/bridge/CoreseAstQueryBuilder.java index 04ea7270e..6e52ede70 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/bridge/CoreseAstQueryBuilder.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/bridge/CoreseAstQueryBuilder.java @@ -142,15 +142,6 @@ public Query toNextQuery(ConstructQueryAst constructQueryAst) { return query; } - /** - * Converts a SPARQL {@code FILTER} clause by converting {@link FilterAst#operator()} the same way as - * {@link #toNextFilter(TermAst)}. - */ - public Filter toNextFilter(FilterAst filterClause) { - Objects.requireNonNull(filterClause, "filterClause"); - return toNextFilter(filterClause.operator()); - } - /** * Converts a filter expression carried as {@link TermAst}: must be a {@link ConstraintAst}. */ diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/bridge/SparqlAstToExpression.java b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/bridge/SparqlAstToExpression.java index a51cf72e7..303a51b99 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/bridge/SparqlAstToExpression.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/bridge/SparqlAstToExpression.java @@ -39,19 +39,6 @@ case LiteralAst(String lexical, String lang, String datatype) -> }; } - /** - * Converts the operator of a SPARQL {@code FILTER} clause ({@link FilterAst}) the same way as - * {@link #toNextFilter(TermAst)}. - * - *

Prefer {@link CoreseAstQueryBuilder#toNextFilter(FilterAst)} at call sites that build queries. - * A filter containing {@code EXISTS} / {@code NOT EXISTS} requires - * {@link #toNextFilter(FilterAst, WhereCompiler)} so its graph pattern can be compiled. - */ - public static Filter toNextFilter(FilterAst filterClause) { - Objects.requireNonNull(filterClause, "filterClause"); - return toNextFilter(filterClause.operator()); - } - /** * Converts a {@code FILTER} clause, compiling the graph pattern of any embedded * {@code EXISTS} / {@code NOT EXISTS} with the given {@link WhereCompiler}. @@ -65,8 +52,7 @@ public static Filter toNextFilter(FilterAst filterClause, WhereCompiler whereCom * Converts a filter {@link TermAst} to an {@link Expression}, then wraps it as a * {@link Filter} with {@link Filter#coreseNextSource()} set to {@code filterExpression}. * - *

Prefer {@link CoreseAstQueryBuilder#toNextFilter(TermAst)} at call sites that build queries; this - * method is the shared implementation. For a full {@link FilterAst} node, use {@link #toNextFilter(FilterAst)}. + * For a full {@link FilterAst} node, use {@link #toNextFilter(FilterAst)}. * Filters containing {@code EXISTS} / {@code NOT EXISTS} require * {@link #toNextFilter(TermAst, WhereCompiler)} so their graph pattern can be compiled. */ diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/io/serializer/json/JsonResultSerializerOptions.java b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/io/serializer/json/JsonResultSerializerOptions.java index 778113329..8568a03fe 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/io/serializer/json/JsonResultSerializerOptions.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/io/serializer/json/JsonResultSerializerOptions.java @@ -43,14 +43,5 @@ public Builder addLink(String link) { return this; } - /** - * Adds a set of links to be added to the header of the SPARQL results. - * @param links preferably a set of URIs - * @return this - */ - public Builder addLinks(Collection links) { - this.links.addAll(links); - return this; - } } } diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/io/serializer/xml/XmlResultSerializerOptions.java b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/io/serializer/xml/XmlResultSerializerOptions.java index 89da119a3..d298152d9 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/sparql/io/serializer/xml/XmlResultSerializerOptions.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/sparql/io/serializer/xml/XmlResultSerializerOptions.java @@ -46,26 +46,6 @@ public Builder setXMLSetting(String key, String value) { return this; } - /** - * Adds a link to be added to the header of the SPARQL results. - * @param link preferably a URI - * @return this - */ - public XmlResultSerializerOptions.Builder addLink(String link) { - this.links.add(link); - return this; - } - - /** - * Adds a set of links to be added to the header of the SPARQL results. - * @param links preferably a set of URIs - * @return this - */ - public XmlResultSerializerOptions.Builder addLinks(Collection links) { - this.links.addAll(links); - return this; - } - @Override public XmlResultSerializerOptions build() { return new XmlResultSerializerOptions(this); diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/BindingContext.java b/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/BindingContext.java index 15bb5e25f..4f73fd36a 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/BindingContext.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/BindingContext.java @@ -58,22 +58,6 @@ default void share(BindingContext other) { } } - /** - * Clears all variables defined in this context. - */ - default void clear() { - getBindings().clear(); - } - - /** - * Returns the number of defined variables. - * - * @return the number of bindings - */ - default int size() { - return getBindings().size(); - } - /** * Tests if the context is empty. * diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/Edge.java b/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/Edge.java index 91b3cd960..3b6c2a3ad 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/Edge.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/Edge.java @@ -1,7 +1,6 @@ package fr.inria.corese.core.next.query.kgram.api.core; import fr.inria.corese.core.sparql.api.IDatatype; -import fr.inria.corese.core.sparql.triple.parser.AccessRight; /** * Interface for Producer iterator that encapsulate Edge or Node with its Graph @@ -27,10 +26,6 @@ default int nbGraphNode() { Node getNode(int i); - @SuppressWarnings("unused") - default void setNode(int i, Node n) { - } - default Node getEdgeNode() { return getProperty(); @@ -43,10 +38,6 @@ default Node getEdgeVariable() { // edge variable or edge node Node getProperty(); - @SuppressWarnings("unused") - default void setProperty(Node node) { - } - /** * Is node returned by getNode() @@ -67,25 +58,8 @@ default int getEdgeIndex() { default void setEdgeIndex(int n) { } - // manage access right - default AccessRight.AccessRights getLevel() { - return AccessRight.AccessRights.NONE; - } - @SuppressWarnings("unused") - default Edge setLevel(AccessRight.AccessRights b) { - return this; - } - - - // use case: internal index edge - default boolean isInternal() { - return nbNode() == 2 && !isTripleNode(); - } - Node getGraph(); - @SuppressWarnings("unused") - default void setGraph(Node n) { - } + @Override Edge getEdge(); @@ -109,40 +83,6 @@ default boolean isNested() { default void setNested(boolean b) { } - default boolean isAsserted() { - return !isNested(); - } - - default void setAsserted(boolean b) { - setNested(!b); - } - - // edge created as nested triple expression - // bind (<> as ?t) - // values ?t { <> } - default boolean isCreated() { - return false; - } - @SuppressWarnings("unused") - default void setCreated(boolean b) { - } - - default Node getGraphNode() { - return getGraph(); - } - - default Node getSubjectNode() { - return getNode(0); - } - - default Node getPropertyNode() { - return getProperty(); - } - - default Node getObjectNode() { - return getNode(1); - } - default IDatatype getGraphValue() { Node node = getGraph(); if (node == null) { @@ -171,26 +111,12 @@ default boolean isTripleNode() { return false; } - default boolean sameTerm(Edge e) { - return sameTermWithoutGraph(e) - && (getGraphValue() == null || e.getGraphValue() == null - ? getGraphValue() == e.getGraphValue() - : getGraphValue().sameTerm(e.getGraphValue())); - } - default boolean sameTermWithoutGraph(Edge e) { return getSubjectValue().sameTerm(e.getSubjectValue()) && getPredicateValue().sameTerm(e.getPredicateValue()) && getObjectValue().sameTerm(e.getObjectValue()); } - default boolean equals(Edge e) { - return equalsWithoutGraph(e) - && (getGraphValue() == null || e.getGraphValue() == null - ? getGraphValue() == e.getGraphValue() - : getGraphValue().equals(e.getGraphValue())); - } - default boolean equalsWithoutGraph(Edge e) { return getObjectValue().equals(e.getObjectValue()) && getSubjectValue().equals(e.getSubjectValue()) diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/Node.java b/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/Node.java index 7fd69ee0c..dd16ea0f5 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/Node.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/Node.java @@ -49,7 +49,6 @@ default int compareTo(Node node) { return getDatatypeValue().compareTo(node.getDatatypeValue()); } - String getLabel(); boolean isVariable(); @@ -93,13 +92,4 @@ default boolean isTriple() { return getDatatypeValue().isTriple(); } - // triple reference with edge inside - default boolean isTripleWithEdge() { - return isTriple() && getEdge() != null; - } - - default void setEdge(Edge e) { - getDatatypeValue().setEdge((fr.inria.corese.core.kgram.api.core.Edge) e); - } - } diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/PointerType.java b/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/PointerType.java index 83dbce7ef..3f6e79fa0 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/PointerType.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/PointerType.java @@ -33,8 +33,4 @@ public enum PointerType { name = DT + n; } - public String getName() { - return name; - } - } diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/Pointerable.java b/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/Pointerable.java index d2e217ba7..c1e5a2d0e 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/Pointerable.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/api/core/Pointerable.java @@ -18,10 +18,6 @@ default PointerType pointerType() { return PointerType.UNDEF; } - default Object getPointerObject() { - return this; - } - default Mappings getMappings() { return null; } diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/api/query/ProcessVisitor.java b/src/main/java/fr/inria/corese/core/next/query/kgram/api/query/ProcessVisitor.java index 996cd8c2a..f8f7f2039 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/api/query/ProcessVisitor.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/api/query/ProcessVisitor.java @@ -18,37 +18,14 @@ public interface ProcessVisitor extends Pointerable { int SLICE_DEFAULT = 20; - default boolean isActive() { - return true; - } - - default void setActive(boolean b) { - } - default boolean isShareable() { return false; } - default Eval getProcessor() { - return null; - } - - default void setProcessor(Eval e) { - } - default IDatatype defaultValue() { return null; } - // before query and before lock graph - default IDatatype prepare() { - return defaultValue(); - } - - default IDatatype init() { - return defaultValue(); - } - default IDatatype init(Query q) { return defaultValue(); } @@ -61,18 +38,6 @@ default IDatatype after(Mappings map) { return defaultValue(); } - default IDatatype construct(Mappings map) { - return defaultValue(); - } - - default boolean entailment() { - return false; - } - - default IDatatype entailment(Query rule, List construct, List where) { - return defaultValue(); - } - default IDatatype start(Query q) { return defaultValue(); } @@ -93,19 +58,10 @@ default boolean limit(Mappings map) { return true; } - default int timeout(Node serv) { - return 0; - } - default int slice() { return SLICE_DEFAULT; } - @Deprecated - default int slice(Node serv, Mappings map) { - return SLICE_DEFAULT; - } - default IDatatype produce(Eval eval, Node g, Edge edge) { return defaultValue(); } @@ -187,19 +143,6 @@ default IDatatype aggregate(Eval eval, Expr e, IDatatype val) { return val; } - default IDatatype function(Eval eval, Expr funcall, Expr fundef) { - return defaultValue(); - } - - - default IDatatype error(Eval eval, Expr exp, IDatatype... param) { - return null; - } - - default IDatatype overload(Eval eval, Expr exp, IDatatype res, IDatatype... param) { - return null; - } - default boolean produce() { return false; } @@ -216,29 +159,8 @@ default boolean filter() { return false; } - default boolean overload(Expr exp, IDatatype res, IDatatype dt1, IDatatype dt2) { - return false; - } - default int compare(Eval eval, int res, IDatatype dt1, IDatatype dt2) { return res; } - default IDatatype datatype(IDatatype type, IDatatype sup) { - return type; - } - - default IDatatype insert(IDatatype path, Edge edge) { - return defaultValue(); - } - - default IDatatype delete(Edge edge) { - return defaultValue(); - } - - default IDatatype update(Query q, List delete, List insert) { - return defaultValue(); - } - - } diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/api/query/Producer.java b/src/main/java/fr/inria/corese/core/next/query/kgram/api/query/Producer.java index 96aa9c169..b456017f4 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/api/query/Producer.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/api/query/Producer.java @@ -6,9 +6,7 @@ import fr.inria.corese.core.next.query.kgram.core.Query; import fr.inria.corese.core.next.query.kgram.core.SparqlException; import fr.inria.corese.core.sparql.api.IDatatype; -import fr.inria.corese.core.sparql.datatype.DatatypeMap; -import java.util.ArrayList; import java.util.List; /** @@ -73,34 +71,6 @@ default void finish(Query q) { */ Iterable getEdges(Node gNode, List from, Edge qEdge, Environment env); - @SuppressWarnings("unused") - default Iterable getEdges(Node s, Node p, Node o, List from) { - return new ArrayList<>(0); - } - - @SuppressWarnings("unused") - default Edge insert(Node g, Node s, Node p, Node o) { - return null; - } - - @SuppressWarnings("unused") - default Iterable delete(Node g, Node s, Node p, Node o) { - return null; - } - - - //return IDatatype list of IDatatype edge - // ldscript iterator - default IDatatype getEdges(Iterable it) { - ArrayList list = new ArrayList<>(); - for (Edge edge : it) { - if (edge != null) { - list.add(DatatypeMap.createObject(edge)); - } - } - return DatatypeMap.newList(list); - } - Mappings getMappings(Node gNode, List from, Exp exp, Environment env) throws SparqlException; /* diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/core/Eval.java b/src/main/java/fr/inria/corese/core/next/query/kgram/core/Eval.java index f0e6e398c..0b7f12a15 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/core/Eval.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/core/Eval.java @@ -183,10 +183,6 @@ public Mappings query(Query q) throws SparqlException { return query(null, q, null); } - public Mappings query(Query q, Mapping m) throws SparqlException { - return query(null, q, m); - } - public Mappings query(Node graphNode, Query q, Mapping m) throws SparqlException { return queryBasic(graphNode, q, m); } diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/core/ExpEdge.java b/src/main/java/fr/inria/corese/core/next/query/kgram/core/ExpEdge.java index 21e690527..d8d95007e 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/core/ExpEdge.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/core/ExpEdge.java @@ -19,30 +19,6 @@ public class ExpEdge extends Exp { super(t); } - /* - ?s ope cst | cst ope ?s ope ::= = < <= > >= - - fun(?s, cst) fun ::= contains, strstarts, strends, regex - - node ::= subject, predicate, object - - getFilter(node, type) getFilters(node, type) - getFilter(node) getFilters(node) - getFilters() - - ?x p ?y filters (?y < 12) (?x = ) - getFilter(object) = (?y < 12) - - */ - - public Filter getFilter(int node, int type) { - List list = getFilters(node, type); - if (list.isEmpty()) { - return null; - } - return list.getFirst(); - } - /** * node: subject|predicate|object * type: operator or function or any diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/core/Mapping.java b/src/main/java/fr/inria/corese/core/next/query/kgram/core/Mapping.java index fffb9b834..54db6546d 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/core/Mapping.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/core/Mapping.java @@ -226,10 +226,6 @@ public Node[] getSelect() { return getSelectNodes(); } - public void setSelect(Node[] nodes) { - setSelectNodes(nodes); - } - @Override public Path getPath(Node qNode) { Node node = getNode(qNode); @@ -239,20 +235,6 @@ public Path getPath(Node qNode) { return node.getPath(); } - /** - * Index of qNode in mapping (not in stack) - */ - int getIndex(Node qNode) { - int i = 0; - for (Node node : getQueryNodes()) { - if (qNode == node) { - return i; - } - i++; - } - return i; - } - boolean isPath(int n) { return getPath(n) != null; @@ -291,10 +273,6 @@ String toString(String sep) { return sb.toString(); } - public List getNodes(String varString) { - return getNodes(varString, false); - } - public List getNodes(String varString, boolean distinct) { List list = new ArrayList<>(); if (getMappings() != null) { @@ -324,16 +302,6 @@ void computeDistinct(List list) { set(list, getDistinctNodes()); } - void prepareModify(Query q) { - if (!q.getOrderBy().isEmpty()) { - setOrderBy(new Node[q.getOrderBy().size()]); - } - if (!q.getGroupBy().isEmpty()) { - // group by node retrieved in variable hashmap - setGroupBy(new Node[0]); - } - } - void set(List list, Node[] array) { int i = 0; for (Node qNode : list) { @@ -385,22 +353,6 @@ public Mapping project(Node q) { return create(q, value); } - /** - * use case: bind(sparql('select ?x ?y where { ... }') as (?z, ?t)) rename - * ?x as ?z and ?y as ?t in all Mapping as well as in Mappings select - */ - public void rename(List oselect, List nselect) { - int size = Math.min(oselect.size(), nselect.size()); - for (int i = 0; i < size; i++) { - for (int j = 0; j < getQueryNodes().length; j++) { - if (oselect.get(i).equals(getQueryNodes()[j])) { - getQueryNodes()[j] = nselect.get(i); - break; - } - } - } - } - // TODO: manage Node isPath public void fixQueryNodes(Query q) { for (int i = 0; i < getQueryNodes().length; i++) { @@ -444,14 +396,6 @@ public Node getQueryNode(int n) { return getQueryNodes()[n]; } - public Object getNodeObject(String name) { - Node node = getNode(name); - if (node == null) { - return null; - } - return node.getNodeObject(); - } - // variable name only public Node getNodeValue(String name) { return values.get(name); @@ -587,18 +531,6 @@ public Node[] getNodes() { return getTargetNodes(); } - /** - * rename query nodes Used by Producer.map() to return Mappings - */ - public void setNodes(List lNodes) { - int n = 0; - for (Node qNode : lNodes) { - if (n < getQueryNodes().length) { - getQueryNodes()[n++] = qNode; - } - } - } - public Edge[] getQueryEdges() { return queryEdges; } @@ -884,13 +816,6 @@ boolean contains(Node node) { return false; } - Mappings getAggregateMappings() { - if (getMappings() == null) { - return new Mappings().add(this); - } - return getMappings(); - } - @Override public BindingContext getBind() { return bindingContext; diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/core/Mappings.java b/src/main/java/fr/inria/corese/core/next/query/kgram/core/Mappings.java index 719171c80..f9437c987 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/core/Mappings.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/core/Mappings.java @@ -8,7 +8,6 @@ import fr.inria.corese.core.next.query.kgram.event.EventImpl; import fr.inria.corese.core.next.query.kgram.event.EventManager; import fr.inria.corese.core.sparql.api.IDatatype; -import fr.inria.corese.core.sparql.triple.parser.ASTQuery; import java.util.*; @@ -117,10 +116,6 @@ public String getDatatypeLabel() { return String.format("[Mappings: size=%s]", size()); } - public void init(Query q) { - init(q, false); - } - void init(Query q, boolean subEval) { initiate(q, !subEval && q.isDistinct()); } @@ -188,10 +183,6 @@ public boolean isDistinct() { return isDistinct; } - int count() { - return count; - } - void setCount(int n) { count = n; } @@ -251,13 +242,6 @@ public Mappings setQuery(Query q) { return this; } - public ASTQuery getAST() { - if (getQuery() == null) { - return null; - } - return getQuery().getAST(); - } - @Override public String toString() { return toString(false); diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/core/Memory.java b/src/main/java/fr/inria/corese/core/next/query/kgram/core/Memory.java index 7426d440b..99667db78 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/core/Memory.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/core/Memory.java @@ -260,18 +260,6 @@ void copyInto(Query sub, Memory mem, Exp exp) { } } - /** - * Use case: exists {} in aggregate Copy Mapping into this fresh Memory - * similar to copyInto - */ - void copy(Mapping map, Exp exp) { - if (map.hasBind()) { - copy(map.getBind(), exp); - } - share(getBind(), map.getBind()); - push(map, -1); - } - /** * exists { } * PRAGMA: when exists is in function, this memory is empty @@ -939,10 +927,6 @@ public Edge getEdge(Edge qEdge) { return result[qEdge.getEdgeIndex()]; } - public Edge[] getQueryEdges() { - return qEdges; - } - @Override public Edge[] getEdges() { return result; @@ -1110,10 +1094,6 @@ public void setObject(Object o) { object = o; } - boolean isFake() { - return isFake; - } - public void setFake(boolean isFake) { this.isFake = isFake; } diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/core/Query.java b/src/main/java/fr/inria/corese/core/next/query/kgram/core/Query.java index 0b0f34078..ace164296 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/core/Query.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/core/Query.java @@ -839,58 +839,6 @@ public Exp getDelete() { return delete; } - /** - * If there is an aggregate, there should be no variable in select - * SELECT ?P (COUNT(?O) AS ?C) WHERE { ?S ?P ?O } - */ - boolean checkAggregate() { - boolean hasVariable = false, hasAggregate = false; - - for (Exp exp : getSelectFun()) { - if (exp.getFilter() == null) { - if (!exp.status()) { - // special case, status=true means - // exp was generated by transformer as input arg of another select exp - // see checkFilterVariables - hasVariable = true; - } - } else if (exp.getFilter().isRecAggregate()) { - hasAggregate = true; - } - } - return !(hasAggregate && hasVariable); - } - - /** - * - * Check that select variables and expressions are compatible with group by - * SELECT ((?O1 + ?O2) AS ?O12) (COUNT(?O1) AS ?C) WHERE { ?S :p ?O1; :q ?O2 - * } GROUP BY (?S) - * - * - */ - boolean checkGroupBy(Exp exp) { - if (exp.getFilter() != null) { - // variables should be in group by or in aggregate - // (fun(count(?x)) as y - if (exp.getFilter().isRecAggregate()) { - return true; - } - if (member(exp.getNode(), getGroupBy())) { - // use case: select ?x where {} group by (f(?y) as ?x) - return true; - } - - List list = exp.getFilter().getVariables(); - for (String var : list) { - if (!member(var, getGroupBy())) { - return false; - } - } - } else return member(exp.getNode(), getGroupBy()); - return true; - } - boolean member(Node node, List lExp) { return member(node.getLabel(), lExp); } @@ -1503,23 +1451,6 @@ public Query groupBy(Node node) { return this; } - public Query select(Node node) { - if (node != null && doesNotContain(getSelectFun(), node)) { - addSelect(node); - } - return this; - } - - Query complete(Query q1, Query q2) { - q1.setOuterQuery(this); - q2.setOuterQuery(this); - setGlobalQuery(getBody()); - setSelect(q1, q2); - collect(); - setAST(q2.getAST()); - return this; - } - void setSelect(Query q1, Query q2) { List list = new ArrayList<>(); list.addAll(q1.getSelectFun()); @@ -1597,19 +1528,11 @@ public void setSynchronized(boolean b) { public boolean isSynchronized() { return isSynchronized; } - - public Object getTransformer() { - return getGlobalQuery().getPPrinter(null); - } public void setTransformer(String p, Object transformer) { getGlobalQuery().setPPrinter(p, transformer); } - public void setTransformer(Object transformer) { - setTransformer(null, transformer); - } - Object getPPrinter(String p) { if (p == null) { return transformer; @@ -1689,14 +1612,6 @@ public void setExtension(ASTExtension ext) { this.extension = ext; } - public Expr getExpression(String name, boolean inherit){ - Expr ee = getLocalExpression(name); - if (ee == null && inherit){ - return getGlobalExpression(name); - } - return ee; - } - public Expr getLocalExpression(String name){ if (getExtension() != null){ @@ -1771,14 +1686,6 @@ public boolean isTransformationTemplate() { } - public HashMap getEnvironment() { - return tprinter; - } - - public void setEnvironment(HashMap map) { - tprinter = map; - } - @Override public Mapping getMapping() { @@ -1843,13 +1750,4 @@ public void setAlgebra(boolean algebra) { this.algebra = algebra; } - public Mappings getSelection() { - return selection; - } - - public Mappings getDiscorevy() { - return discorevy; - } - - } diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/core/QuerySorter.java b/src/main/java/fr/inria/corese/core/next/query/kgram/core/QuerySorter.java index 9a3d53531..c1bca8c74 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/core/QuerySorter.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/core/QuerySorter.java @@ -347,11 +347,6 @@ public List findBindings(Exp exp) { return exp.varBind(); } - - public void setSorter(Sorter sort) { - this.sort = sort; - } - /** * JOIN service */ diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/event/EventImpl.java b/src/main/java/fr/inria/corese/core/next/query/kgram/event/EventImpl.java index c46dee4d4..e6db15b11 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/event/EventImpl.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/event/EventImpl.java @@ -21,10 +21,6 @@ public class EventImpl implements Event { boolean isSuccess = true; Object object, arg, arg2; - EventImpl(int n){ - type = n; - } - EventImpl(int n, Object o){ type = n; object = o; diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/filter/Checker.java b/src/main/java/fr/inria/corese/core/next/query/kgram/filter/Checker.java index 29ba6b700..b87ff0075 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/filter/Checker.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/filter/Checker.java @@ -34,14 +34,6 @@ public Checker(Query q){ query = q; } - /** - * var1=cst || var2=cst - */ - public boolean check(String v1, String v2, Expr ee){ - Pattern p = path(v1, v2); - return matcher.match(p, ee); - } - /** * Check one filter */ @@ -51,18 +43,7 @@ public boolean check(Expr ee){ // hence return false (check correctness is false) return ! b; } - - /** - * Check two filters for contradiction: - * ?x = ?y vs ?x != ?y - */ - - public boolean check(Expr e1, Expr e2){ - // fake a AND using a pattern - Pattern and = new Pattern(BOOL, AND, e1, e2); - return check(and); - } - + /** * Return true if a false pattern matches diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/path/GraphPath.java b/src/main/java/fr/inria/corese/core/next/query/kgram/path/GraphPath.java index e1ed4b377..948d3028c 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/path/GraphPath.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/path/GraphPath.java @@ -1,7 +1,6 @@ package fr.inria.corese.core.next.query.kgram.path; -import fr.inria.corese.core.next.query.kgram.api.core.Node; import fr.inria.corese.core.next.query.kgram.api.query.Environment; /** @@ -31,9 +30,4 @@ public GraphPath(PathFinder pc, Environment mem){ this.mem = mem; } - void process(){ - Node cstart = finder.get(mem, finder.getIndex()); - finder.process(cstart, mem); - } - } diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/sorter/core/QPGraph.java b/src/main/java/fr/inria/corese/core/next/query/kgram/sorter/core/QPGraph.java index 67df39561..3de963710 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/sorter/core/QPGraph.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/sorter/core/QPGraph.java @@ -27,15 +27,6 @@ public class QPGraph { // map(node, edges) private Map> graph = null; - public QPGraph(Exp exp, List bindings) { - this.bindings = bindings; - this.nodes = new ArrayList<>(); - this.edges = new ArrayList<>(); - - createNodes(exp); - createEdges(); - } - public QPGraph(List exps, List bindings) { this.bindings = bindings; this.nodes = new ArrayList<>(); diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/tool/ApproximateSearchEnv.java b/src/main/java/fr/inria/corese/core/next/query/kgram/tool/ApproximateSearchEnv.java index c7c9d01e7..accf9dce0 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/tool/ApproximateSearchEnv.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/tool/ApproximateSearchEnv.java @@ -2,7 +2,6 @@ import fr.inria.corese.core.next.query.kgram.api.core.Expr; import fr.inria.corese.core.next.query.kgram.api.core.Node; -import fr.inria.corese.core.next.query.kgram.api.query.Environment; import java.util.*; @@ -53,47 +52,11 @@ public String toString() { return sb.toString(); } - private Double aggregate(Environment env, List lv) { - if (lv.isEmpty()) { - return 1.0; - } - - double sim = 1; - - //calculate similarity - for (Expr var : lv) { - Node node = env.getNode(var); - if (node == null) { - continue; - } - - Double s = this.getSimilarity(var, (Node) node.getValue()); - if (s != null) { - sim *= s; - } - } - return sim; - } - - public List getVariables() { - List lv = new ArrayList<>(); - for (Key k : this.all.keySet()) { - lv.add(k.getVar()); - } - - return lv; - } - static class Key { private final Expr var; private Node uri; - public Key(Expr var, Node uri) { - this(var); - this.uri = uri; - } - public Key(Expr var) { this.var = var; } @@ -131,11 +94,6 @@ static class Value { private double similarity = -1; private final String algorithms; - public Value(Node node, String algorithms, double sim) { - this(node, algorithms); - this.similarity = sim; - } - public Value(Node node, String algorithms) { this.node = node; this.algorithms = algorithms; diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/tool/EnvironmentImpl.java b/src/main/java/fr/inria/corese/core/next/query/kgram/tool/EnvironmentImpl.java index d710c53ac..d0824777f 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/tool/EnvironmentImpl.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/tool/EnvironmentImpl.java @@ -19,11 +19,7 @@ public class EnvironmentImpl implements Environment { public EnvironmentImpl(){ } - - EnvironmentImpl(Query q){ - query = q; - } - + @Override public int count() { return 0; diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/tool/ResultsImpl.java b/src/main/java/fr/inria/corese/core/next/query/kgram/tool/ResultsImpl.java index 794ab654b..9bbd4d81c 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/tool/ResultsImpl.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/tool/ResultsImpl.java @@ -16,11 +16,7 @@ public class ResultsImpl implements Results { ResultsImpl(Mappings ms){ maps = ms; } - - public static ResultsImpl create(Mappings ms){ - return new ResultsImpl(ms); - } - + public List getSelect() { return maps.getSelect(); } diff --git a/src/main/java/fr/inria/corese/core/next/query/kgram/tool/StorageManagerProducer.java b/src/main/java/fr/inria/corese/core/next/query/kgram/tool/StorageManagerProducer.java index abb545752..e45009d64 100644 --- a/src/main/java/fr/inria/corese/core/next/query/kgram/tool/StorageManagerProducer.java +++ b/src/main/java/fr/inria/corese/core/next/query/kgram/tool/StorageManagerProducer.java @@ -7,7 +7,6 @@ import fr.inria.corese.core.next.data.impl.temp.CoreseAdaptedValueFactory; import fr.inria.corese.core.next.query.api.exception.UnsupportedQueryFeatureException; import fr.inria.corese.core.next.query.kgram.api.core.Edge; -import fr.inria.corese.core.next.query.kgram.api.core.Graph; import fr.inria.corese.core.next.query.kgram.api.core.Node; import fr.inria.corese.core.next.query.kgram.api.core.Regex; import fr.inria.corese.core.next.query.kgram.api.query.Environment; @@ -125,11 +124,6 @@ public Node getNode(Object value) { return null; } - @Override - public IDatatype getValue(Object value) { - return getDatatypeValue(value); - } - @Override public IDatatype getDatatypeValue(Object value) { if (value instanceof Node node) { @@ -181,11 +175,6 @@ public Mappings getMappings(Node graphNode, List from, Exp exp, Environmen return mappings; } - @Override - public Graph getGraph() { - return null; - } - /** * Converts a KGRAM query edge into the storage-layer statement pattern. * diff --git a/src/test/java/fr/inria/corese/core/next/query/impl/sparql/ast/TriplePatternAstTestSupport.java b/src/test/java/fr/inria/corese/core/next/query/impl/sparql/ast/TriplePatternAstTestSupport.java index 070014642..30dce5c88 100644 --- a/src/test/java/fr/inria/corese/core/next/query/impl/sparql/ast/TriplePatternAstTestSupport.java +++ b/src/test/java/fr/inria/corese/core/next/query/impl/sparql/ast/TriplePatternAstTestSupport.java @@ -20,7 +20,4 @@ public static TermAst simplePredicateTerm(TriplePatternAst triple) { return ((PredicatePathAst) predicate).predicate(); } - public static PredicatePathAst predicatePath(TermAst term) { - return new PredicatePathAst(term); - } }