diff --git a/src/main/java/fr/inria/corese/core/kgram/api/core/Edge.java b/src/main/java/fr/inria/corese/core/kgram/api/core/Edge.java index 0313cd4c0..1971234fd 100644 --- a/src/main/java/fr/inria/corese/core/kgram/api/core/Edge.java +++ b/src/main/java/fr/inria/corese/core/kgram/api/core/Edge.java @@ -209,12 +209,6 @@ default Node getTripleNode() { default void setTripleNode(Node node) { } - 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()) @@ -222,12 +216,6 @@ && 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()) diff --git a/src/main/java/fr/inria/corese/core/kgram/api/query/ProcessVisitor.java b/src/main/java/fr/inria/corese/core/kgram/api/query/ProcessVisitor.java index e7acb161a..90af4e832 100644 --- a/src/main/java/fr/inria/corese/core/kgram/api/query/ProcessVisitor.java +++ b/src/main/java/fr/inria/corese/core/kgram/api/query/ProcessVisitor.java @@ -17,9 +17,6 @@ public interface ProcessVisitor extends Pointerable { int SLICE_DEFAULT = 20; - default boolean isActive() { - return true; - } default void setActive(boolean b) { } diff --git a/src/main/java/fr/inria/corese/core/kgram/core/Distinct.java b/src/main/java/fr/inria/corese/core/kgram/core/Distinct.java index 51aa7387e..384aa55c8 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/Distinct.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/Distinct.java @@ -26,12 +26,6 @@ public class Distinct { list = l; } - /** - * @return the byIndex - */ - public static boolean isByIndex() { - return byIndex; - } /** * @param aByIndex the byIndex to set diff --git a/src/main/java/fr/inria/corese/core/kgram/core/Eval.java b/src/main/java/fr/inria/corese/core/kgram/core/Eval.java index fe016258e..f9764bc78 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/Eval.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/Eval.java @@ -174,23 +174,6 @@ public void set(Provider p) { provider = p; } - public void set(Producer p) { - setProducer(p); - } - - public void set(Matcher m) { - match = m; - } - - public void set(Evaluator e) { - evaluator = e; - } - - @Deprecated - public Results exec(Query q) throws SparqlException { - Mappings maps = query(q, null); - return ResultsImpl.create(maps); - } /** * Main eval function @@ -256,9 +239,6 @@ void share(ProcessVisitor vis) { public void finish(Query q, Mappings map) { } - public Mappings eval(Node gNode, Query q, Mapping map) throws SparqlException { - return eval(gNode, q, map, null); - } /** * Mapping m is binding parameter, possibly null @@ -337,14 +317,6 @@ int query(Node gNode, Query q, Mapping m, Mappings map) throws SparqlException { } } - /** - * External values clause evaluated as join(values, body) - */ - int queryWithJoinValues(Node gNode, Query q, Mappings map) - throws SparqlException { - Exp values = Exp.create(Type.AND, q.getValues()); - return evalExp(gNode, q, Exp.create(Type.JOIN, values, q.getBody()), map); - } /** * Bind external values one by one in memory and eval one by one @@ -388,25 +360,6 @@ void countProfile() { getResults().add(m); } - /** - * Subquery processed by a function call that return Mappings Producer may - * cast the result into Mappings use case: {select xpath(?x, '/book/title') - * as ?val where {}} Mappings may be completed by filter (e.g. for casting) - * Mappings will be processed later by aggregates and order by/limit etc. - */ - private void function() throws SparqlException { - Exp exp = query.getFunction(); - if (exp == null) { - return; - } - Mappings lMap = eval(exp.getFilter(), memory, exp.getNodeList()); - if (lMap != null) { - for (Mapping map : lMap) { - map = complete(map, getProducer()); - submit(map); - } - } - } /** * additional filter of functional select xpath() as ?val xsd:integer(?val) @@ -432,33 +385,6 @@ private Mapping complete(Mapping map, Producer p) throws SparqlException { return map; } - // draft for processing EXTERN expression - public void add(Plugin p) { - plugin = p; - } - - public void setMappings(Mappings lMap) { - initialResults = lMap; - } - - void debug() { - logger.warn(Message.Prefix.LOOP.getString(), nbCall + " " + nbEdge); - if (results.size() == 0) { - if (query.isFail()) { - logger.warn(Message.Prefix.FAIL.getString()); - for (Filter filter : query.getFailures()) { - logger.warn(filter + " "); - } - } else { - if (maxExp == null) { - logger.warn(Message.Prefix.FAIL_AT.getString(), "init phase, e.g. parameter binding"); - } else { - logger.warn(Message.Prefix.FAIL_AT.getString(), maxExp); - getTrace().append(String.format("SPARQL fail at: %s", maxExp)).append(System.getProperty("line.separator")); - } - } - } - } StringBuilder getTrace() { return getBind().getTrace(); @@ -709,9 +635,6 @@ private Memory copyMemory(Memory memory, Query query, Query sub, Exp exp) { return mem; } - void setLevel(int n) { - level = n; - } public void setSubEval(boolean b) { isSubEval = b; @@ -769,9 +692,6 @@ public Mappings getResults() { return results; } - void setResult(Mappings r) { - results = r; - } // total init (for global query) public void init(Query q) { @@ -1363,14 +1283,6 @@ private int service(Producer p, Node graphNode, Exp exp, Mappings data, Stack st return backtrack; } - // stack = just one service: store and return result directly - int result(Producer p, Mappings lMap, int n) throws SparqlException { - for (Mapping map : lMap) { - complete(getQuery(), map, true); - solution(p, map, n); - } - return STOP; - } // process additional variable provided by service // such as ?_server_0 in federated mode @@ -2006,13 +1918,6 @@ void submit(Mapping map) { } } - public int nbResult() { - return getResults().size(); - } - - public int getCount() { - return nbEdge; - } private boolean match(Edge qEdge, Edge edge, Node gNode, Node graphNode, Memory memory) { if (!getMatcher().match(qEdge, edge, memory)) { @@ -2029,28 +1934,6 @@ private boolean push(Producer p, Edge qEdge, Edge ent, Node gNode, Node node, in return env.push(p, qEdge, ent, n); } - private boolean match(Node qNode, Node node, Node gNode, Node graphNode) { - Memory env = getMemory(); - if (!getMatcher().match(qNode, node, env)) { - return false; - } - if (gNode == null) { - return true; - } - return getMatcher().match(gNode, graphNode, env); - } - - private boolean push(Node qNode, Node node, Node gNode, Node graphNode, int n) { - Memory env = getMemory(); - if (!env.push(qNode, node, n)) { - return false; - } - if (gNode != null && !env.push(gNode, graphNode, n)) { - env.pop(qNode); - return false; - } - return true; - } // for path private boolean match(Mapping map) { @@ -2095,9 +1978,6 @@ void createManager() { } } - public EventManager getEventManager() { - return manager; - } public void setEventManager(EventManager man) { manager = man; @@ -2123,9 +2003,6 @@ void set(Stack current) { this.current = current; } - public Stack getStack() { - return current; - } public SPARQLEngine getSPARQLEngine() { return sparqlEngine; @@ -2154,19 +2031,6 @@ public void setStop(boolean stop) { - /* - * ************************************************************************* - * - * Alternative interpreter - * - */ - - public void finish() { - setStop(true); - join.setStop(true); - evalGraphNew.setStop(true); - optional.setStop(true); - } /** * SPARQL algebra requires kgram to compute BGP exp and return Mappings @@ -2178,18 +2042,6 @@ Mappings exec(Node gNode, Producer p, Exp exp, Mapping m) throws SparqlException return p.getMappings(gNode, from, exp, memory); } - void process(Exp exp, Mapping m) { - if (exp.getNodeList() != null) { - for (Node qnode : exp.getNodeList()) { - Node node = m.getNodeValue(qnode); - if (node != null) { - memory.push(qnode, node, -1); - } - } - } else { - memory.push(m, 0); - } - } /** * Evaluate exp with SPARQL Algebra on Mappings, not with Memory stack @@ -2383,9 +2235,6 @@ public boolean isJoinMappings() { return joinMappings; } - public void setJoinMappings(boolean joinMappings) { - this.joinMappings = joinMappings; - } public ResultListener getListener() { return listener; diff --git a/src/main/java/fr/inria/corese/core/kgram/core/Exp.java b/src/main/java/fr/inria/corese/core/kgram/core/Exp.java index 2d44374a1..c6f99f408 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/Exp.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/Exp.java @@ -106,13 +106,6 @@ public static Exp create(Type t, Exp e1, Exp e2) { return e; } - public static Exp create(Type t, Exp e1, Exp e2, Exp e3) { - Exp e = create(t); - e.add(e1); - e.add(e2); - e.add(e3); - return e; - } public static Exp create(Type t, Exp e1) { Exp e = create(t); @@ -169,9 +162,6 @@ public boolean isSystem() { return isSystem; } - public void setSystem(boolean b) { - isSystem = b; - } public int getLevel() { return level; @@ -230,9 +220,6 @@ public Exp duplicate() { return exp; } - public boolean hasArg() { - return !args.isEmpty(); - } @Override public int size() { @@ -243,9 +230,6 @@ public void add(Exp e) { args.add(e); } - public void add(Edge e) { - args.add(create(Type.EDGE, e)); - } public void add(Node n) { args.add(create(Type.NODE, n)); @@ -375,9 +359,6 @@ public void skip(boolean b) { skip = b; } - public boolean skip() { - return skip; - } public void status(boolean b) { status = b; @@ -407,9 +388,6 @@ public boolean isStatement() { } } - public int getIndex() { - return index; - } public void setIndex(int n) { index = n; @@ -448,9 +426,6 @@ public void setSilent(boolean b) { isSilent = b; } - public boolean isNode() { - return type == Type.NODE; - } public boolean isEdge() { return type == Type.EDGE; @@ -472,9 +447,6 @@ public boolean isJoin() { return type == Type.JOIN; } - public boolean isAndJoin() { - return isJoin() || (isBGPAnd() && size() == 1 && get(0).isJoin()); - } public boolean isAnd() { return type == Type.AND; @@ -504,22 +476,11 @@ public boolean isService() { return type == Type.SERVICE; } - public boolean isAtomic() { - return type == Type.FILTER || type == Type.EDGE || type == Type.NODE - || type == Type.ACCEPT; - } public void setType(Type n) { type = n; } - Exp getNext() { - return next; - } - - void setNext(Exp e) { - next = e; - } public List getExpList() { return args; @@ -660,13 +621,6 @@ public boolean isPath() { return type == Type.PATH; } - public void setPath(Exp path) { - this.path = path; - } - - public void setPath(boolean b) { - isPath = b; - } public boolean isValues() { return type == Type.VALUES; @@ -676,9 +630,6 @@ public void setValues(Exp values) { this.values = values; } - public boolean isBind() { - return type == Type.BIND; - } public void setBind(Exp bind) { this.bind = bind; @@ -732,13 +683,6 @@ public void setObject(Object o) { object = o; } - public Producer getProducer() { - return producer; - } - - public void setProducer(Producer p) { - producer = p; - } public List getObjectValues() { if (object instanceof List) { @@ -1091,12 +1035,6 @@ public boolean bound(List fvec, List evec) { return true; } - public boolean bind(Filter f) { - List lVar = f.getVariables(); - List lVarExp = new ArrayList<>(); - share(lVar, lVarExp); - return bound(lVar, lVarExp); - } /** * Return variable nodes of this exp use case: find the variables for select @@ -1297,9 +1235,6 @@ public List getRecordInScopeNodes(boolean bind) { return getInScopeNodeList(); } - public List getRecordInScopeNodes() { - return getRecordInScopeNodes(true); - } public List getRecordInScopeNodesWithoutBind() { return getRecordInScopeNodes(false); @@ -1410,9 +1345,6 @@ boolean isBindCst() { return type() == Type.OPT_BIND && size() == 1; } - boolean isBindVar() { - return type() == Type.OPT_BIND && size() == 2; - } /** * Add BIND ?x = ?y @@ -1472,16 +1404,6 @@ boolean bind(Node node) { return false; } - boolean match(Node node, Filter f) { - if (!node.isVariable() || f.getExp().isRecExist()) { - return false; - } - List lVar = f.getVariables(); - if (lVar.size() != 1) { - return false; - } - return lVar.get(0).equals(node.getLabel()); - } /** * this is FILTER with TEST ?x < ?y @@ -1490,55 +1412,6 @@ public int oper() { return getFilter().getExp().oper(); } - boolean check(Exp filter, int index) { - int oper = filter.oper(); - if (oper == ExprType.LT || oper == ExprType.LE) { - return index == 0; - } else if (oper == ExprType.GT || oper == ExprType.GE) { - return index == 1; - } - return false; - } - - boolean order(Exp filter, int index) { - int oper = filter.oper(); - if (oper == ExprType.LT || oper == ExprType.LE) { - return index == 0; - } else if (oper == ExprType.GT || oper == ExprType.GE) { - return index == 1; - } - return true; - } - - /** - * index of Node in Edge - */ - public int indexNode(Node node) { - if (!isEdge()) { - return -1; - } - for (int i = 0; i < nbNode(); i++) { - if (node.same(getNode(i))) { - return i; - } - } - return -1; - } - - /** - * index of node in FILTER ?x < ?y - */ - public int indexVar(Node node) { - Expr ee = getFilter().getExp(); - String name = node.getLabel(); - for (int i = 0; i < 2; i++) { - if (ee.getExp(i).type() == ExprType.VARIABLE - && ee.getExp(i).getLabel().equals(name)) { - return i; - } - } - return -1; - } boolean isBound(List lvar, List lnode) { for (String varString : lvar) { @@ -1837,9 +1710,6 @@ boolean isGraphFirstWith(Type type) { return type() == Type.GRAPH && size() > 1 && get(1).isFirstWith(type); } - boolean isJoinFirstWith(Type type) { - return isFirstWith(type) || isGraphFirstWith(type); - } Exp complete(Mappings map) { if (map == null || !map.isNodeList()) { @@ -1854,17 +1724,11 @@ Exp getValues(Mappings map) { return createValues(map.getNodeList(), map); } - public boolean isMappings() { - return mappings; - } public void setMappings(Mappings m) { map = m; } - public void setMappings(boolean mappings) { - this.mappings = mappings; - } public boolean isGenerated() { return generated; @@ -1882,13 +1746,6 @@ public void setInScopeNodeList(List simpleNodeList) { this.simpleNodeList = simpleNodeList; } - public Query getExternQuery() { - return externQuery; - } - - public void setExternQuery(Query externQuery) { - this.externQuery = externQuery; - } public int getNum() { return num; diff --git a/src/main/java/fr/inria/corese/core/kgram/core/ExpEdge.java b/src/main/java/fr/inria/corese/core/kgram/core/ExpEdge.java index 3a09a5342..f78bb9ae6 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/ExpEdge.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/ExpEdge.java @@ -18,25 +18,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) { - return getFilter(node, ExprType.JOKER); - } public Filter getFilter(int node, int type) { List list = getFilters(node, type); @@ -46,9 +27,6 @@ public Filter getFilter(int node, int type) { return list.get(0); } - public List getFilters(int node) { - return getFilters(node, ExprType.JOKER); - } /** * node: subject|predicate|object diff --git a/src/main/java/fr/inria/corese/core/kgram/core/ExpHandler.java b/src/main/java/fr/inria/corese/core/kgram/core/ExpHandler.java index e7c551a0a..bbdd12aeb 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/ExpHandler.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/ExpHandler.java @@ -33,10 +33,6 @@ public ExpHandler(boolean exist, boolean inSubScope, boolean bind, boolean blank setExist(exist).setInSubScope(inSubScope).setBind(bind).setBlank(blank); } - public ExpHandler(boolean exist, boolean inSubScope, boolean bind) { - this(); - setExist(exist).setInSubScope(inSubScope).setBind(bind); - } public ExpHandler(boolean inSubScope, boolean bind) { this(); @@ -114,25 +110,16 @@ public List getNodeList() { return nodeList; } - public void setNodeList(List nodeList) { - this.nodeList = nodeList; - } public List getSelectNodeList() { return selectNodeList; } - public void setSelectNodeList(List selectNodeList) { - this.selectNodeList = selectNodeList; - } public List getExistNodeList() { return existNodeList; } - public void setExistNodeList(List existNodeList) { - this.existNodeList = existNodeList; - } public boolean isInSubScope() { return inSubScope; diff --git a/src/main/java/fr/inria/corese/core/kgram/core/Group.java b/src/main/java/fr/inria/corese/core/kgram/core/Group.java index 207c7e2a1..61f79eb60 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/Group.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/Group.java @@ -41,9 +41,6 @@ public static boolean isCompareIndex() { } - public static void setCompareIndex(boolean b) { - compareIndex = b; - } public static Group create(List lNode) { return new Group(lNode); @@ -100,13 +97,6 @@ public int compare(Mappings lm1, Mappings lm2) { return lm1.compare(m1, m2); } - Node getGroupBy(Mapping map, Node qNode, int n) { - if (isDistinct) { - return map.getDistinctNode(n); - } else { - return map.getGroupBy(qNode, n); - } - } /** * add map in a group by diff --git a/src/main/java/fr/inria/corese/core/kgram/core/Mapping.java b/src/main/java/fr/inria/corese/core/kgram/core/Mapping.java index c74f477f9..36370f867 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/Mapping.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/Mapping.java @@ -210,21 +210,6 @@ public void initValues() { } } - @Deprecated - public void bind(Node qNode, Node tNode) { - Node[] qq = new Node[getQueryNodes().length + 1]; - Node[] tt = new Node[getTargetNodes().length + 1]; - int i = 0; - for (Node q : getQueryNodes()) { - qq[i] = q; - tt[i] = getTargetNodes()[i]; - i++; - } - qq[i] = qNode; - tt[i] = tNode; - setQueryNodes(qq); - setTargetNodes(tt); - } @Override public int count() { @@ -300,9 +285,6 @@ void setOrderBy(Node node) { getOrderByNodes()[0] = node; } - public Node[] getGroupBy() { - return getGroupByNodes(); - } void setGroupBy(Node[] nodes) { setGroupByNodes(nodes); @@ -316,17 +298,6 @@ public void setSelect(Node[] nodes) { setSelectNodes(nodes); } - @Deprecated - public void rename(Node oName, Node nName) { - int i = 0; - for (Node qn : getQueryNodes()) { - if (qn != null && qn.getLabel().equals(oName.getLabel())) { - getQueryNodes()[i] = nName; - return; - } - i++; - } - } @Override public Path getPath(Node qNode) { @@ -337,13 +308,6 @@ public Path getPath(Node qNode) { return node.getPath(); } - public Path getPath(String name) { - Node qNode = getQueryNode(name); - if (qNode == null) { - return null; - } - return getPath(qNode); - } /** * Index of qNode in mapping (not in stack) @@ -368,14 +332,6 @@ public int pathLength(Node qNode) { return path.length(); } - @Override - public int pathWeight(Node qNode) { - Path path = getPath(qNode); - if (path == null) { - return -1; - } - return path.weight(); - } boolean isPath(int n) { return getPath(n) != null; @@ -430,9 +386,6 @@ String toString(String sep) { return sb.toString(); } - public List getNodes(Node varNode) { - return getNodes(varNode.getLabel()); - } public List getNodes(String varString) { return getNodes(varString, false); @@ -488,12 +441,6 @@ void set(List list, Node[] array) { } } - /** - * min(?l, groupBy(?x, ?y)) retrieve value of ?x ?y in an array - */ - Node getGroupNode(int n) { - return getGroupAlter()[n]; - } Node[] getGroupNodes() { return getGroupAlter(); @@ -503,17 +450,6 @@ Node getDistinctNode(int n) { return getDistinctNodes()[n]; } - public Node[] getDistinct() { - return getDistinctNodes(); - } - - public Node getTNode(Node node) { - return getNode(node); - } - - public Node getGroupBy(int n) { - return getGroupByNodes()[n]; - } public Node getGroupBy(Node qNode, int n) { if (getGroupByNodes().length == 0) { @@ -597,9 +533,6 @@ public void setOrderBy(int n, Node node) { getOrderByNodes()[n] = node; } - public void setGroupBy(int n, Node node) { - getGroupByNodes()[n] = node; - } public Node getNode(int n) { return getTargetNodes()[n]; @@ -625,9 +558,6 @@ public Object getNodeObject(String name) { return node.getNodeObject(); } - public Map getNodeValues() { - return values; - } // variable name only public Node getNodeValue(String name) { @@ -699,16 +629,6 @@ Node getNodeBasic(Node node) { return null; } - Node getNodeBasic(String label) { - int n = 0; - for (Node qnode : getQueryNodes()) { - if (qnode.getLabel().equals(label)) { - return getTargetNodes()[n]; - } - n++; - } - return null; - } /** * Use case: @@ -1182,9 +1102,6 @@ public boolean hasBind() { return bind != null && bind.hasBind(); } - Binding getCreateBind() { - return bind; - } @Override public Node get(Expr varExpr) { @@ -1210,10 +1127,6 @@ public Edge getEdge() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } - @Override - public ApproximateSearchEnv getAppxSearchEnv() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } @Override public TripleStore getTripleStore() { diff --git a/src/main/java/fr/inria/corese/core/kgram/core/MappingSet.java b/src/main/java/fr/inria/corese/core/kgram/core/MappingSet.java index e12018fbb..3d409fb03 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/MappingSet.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/MappingSet.java @@ -37,11 +37,6 @@ public class MappingSet { private Mappings targetMapping; - MappingSet(Query q, Mappings map1, Mappings map2) { - set1 = new MappingSet(q, map1); - set2 = new MappingSet(q, map2); - setQuery(q); - } MappingSet(Query q, Exp exp, MappingSet s1, MappingSet s2) { @@ -63,13 +58,6 @@ Mappings getMappings() { return map; } - List getVarList() { - return varList; - } - - boolean isBound() { - return isBound; - } /** * Variables in common in map1 and map2 @@ -216,12 +204,6 @@ void process() { } } - /** - * @return the targetMapping - */ - public Mappings getJoinMappings() { - return targetMapping; - } /** * @param targetMapping the targetMapping to set @@ -230,13 +212,6 @@ public void setJoinMappings(Mappings targetMapping) { this.targetMapping = targetMapping; } - /** - * exp a Join, Minus, Optional, Union - */ - Exp prepareRest(Exp exp) { - Mappings map = prepareMappings(exp); - return getRest(exp, map); - } Exp getRest(Exp exp, Mappings map) { return (map == null) ? exp.rest() : setMappings(exp, map); @@ -253,38 +228,6 @@ Exp setMappings(Exp exp, Mappings map) { return exp.rest(); } - /** - * Process intermediate Mappings - * either as parameter of eval(rest, map) - * or as values clause inserted in rest - * exp is A optional B | A minus B | A join B - */ - Exp setMappings2(Exp exp, Mappings map) { - Exp rest = exp.rest(); - if (exp.isJoin()) { - // join is generated to enable us to pass - // Mappings map as parameter to right argument - // join (A, bgp(B)) - // join (A, union(B, C)) - // join (A, graph(B)) - // join (A, service) - setJoinMappings(map); - } else if (isFederate() || rest.isEvaluableWithMappings()) { - // user case: - // A optional rest | A minus rest - // and 1) rest recursively starts with service clause - // or 2) rest recursively starts with edge/path - // --2) special case taken into account in eval and() - // eval(rest, map) may take Mappings map argument into account - setJoinMappings(map); - } else { - // inject Mappings map in copy of rest as a values clause - // eval(values+rest) - // use case: exp = optional, minus - rest = rest.complete(map); - } - return rest; - } boolean isFederate() { return getQuery().getGlobalQuery().isFederate(); diff --git a/src/main/java/fr/inria/corese/core/kgram/core/Mappings.java b/src/main/java/fr/inria/corese/core/kgram/core/Mappings.java index dd5dcb79c..f1857b55c 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/Mappings.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/Mappings.java @@ -95,10 +95,6 @@ public Mappings() { link = new ArrayList<>(); } - Mappings(Mapping map) { - this(); - add(map); - } Mappings(Query q) { this(); @@ -218,28 +214,11 @@ public Mappings add(Mapping m) { return this; } - public void reject(Mapping m) { - if (reject == null) { - reject = new ArrayList<>(); - } - reject.add(m); - } - - void complete() { - if (reject != null) { - for (Mapping m : reject) { - getMappingList().remove(m); - } - } - } List getList() { return getMappingList(); } - void setList(List l) { - setMappingList(l); - } public void add(Mappings lm) { getMappingList().addAll(lm.getMappingList()); @@ -275,13 +254,6 @@ public void clear() { getMappingList().clear(); } - public void cleanIndex() { - for (Node node : getSelect()) { - if (node != null) { - node.setIndex(-1); - } - } - } @Override public Query getQuery() { @@ -377,18 +349,6 @@ void setSelect(List nodes) { select = nodes; } - public void setSelect(Node node) { - select = new ArrayList<>(1); - select.add(node); - } - - public IDatatype getValue(Node qNode) { - if (size() == 0) { - return null; - } - Mapping map = get(0); - return map.getValue(qNode); - } public List getNodeValueList(String varString) { List alist = new ArrayList<>(); @@ -420,28 +380,6 @@ public Node getNode(String varString) { return map.getNode(varString); } - public Object getNodeObject(String varString) { - if (size() == 0) { - return null; - } - return get(0).getNodeObject(varString); - } - - public Node getNode(Node varString) { - if (size() == 0) { - return null; - } - Mapping map = get(0); - return map.getNode(varString); - } - - public Node getQueryNode(String varString) { - if (size() == 0) { - return null; - } - Mapping map = get(0); - return map.getQueryNode(varString); - } public IDatatype getValue(String varString) { Node node = getNode(varString); @@ -460,32 +398,6 @@ public Object getValue(String varString, int n) { return get(n); } - public Object getValue2(String varString, int n) { - return getValue(varString); - } - - /** - * 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 setNodes(List nodes) { - if (getSelect() != null) { - for (Mapping map : this) { - map.rename(getSelect(), nodes); - } - setSelect(nodes); - } else { - for (Mapping map : this) { - map.setNodes(nodes); - } - } - } - - public void fixQueryNodes(Query q) { - for (Mapping m : this) { - m.fixQueryNodes(q); - } - } /** * select distinct in case of aggregates, accept Mapping now, distinct will @@ -553,16 +465,6 @@ void setValid(boolean b) { isValid = b; } - @Deprecated - boolean same(Node n1, Node n2) { - if (n1 == null) { - return n2 == null; - } else if (n2 == null) { - return false; - } else { - return n1.same(n2); - } - } /** * Query with new modifier @@ -614,14 +516,6 @@ void addSelectVariable(Node node) { } } - /** - * New order by on this Mappings, after query processing - */ - public void modifyOrderBy() { - if (getEval() != null) { - modifyOrderBy(getEval(), getQuery()); - } - } public void modifyOrderBy(Eval eval, Query q) { if (!q.getOrderBy().isEmpty()) { @@ -845,9 +739,6 @@ int genCompare(Node n1, Node n2) { return compare(n1, n2); } - public void genericSort() { - getMappingList().sort(new MappingSorter()); - } @@ -894,17 +785,6 @@ void limitOffset() { * */ - /** - * select count(?doc) as ?count group by ?person ?date order by ?count - * having(?count > 100) TODO: optimize this because we enumerate all - * Mappings for each kind of aggregate we could enumerate Mappings once and - * compute all aggregates for each map - */ - public void aggregate(Query q, Evaluator evaluator, Environment env, Producer p) throws SparqlException { - if (env instanceof Memory) { - aggregate(q, evaluator, (Memory) env, p); - } - } public void aggregate(Evaluator evaluator, Memory memory, Producer p) throws SparqlException { aggregate(getQuery(), evaluator, memory, p); @@ -1100,17 +980,6 @@ void clean() { } } - public void dispose() { - for (Mapping m : this) { - m.dispose(); - } - if (getGroup() != null) { - getGroup().dispose(); - } - if (getDistinct() != null) { - getDistinct().dispose(); - } - } public void prepareAggregate(Mapping map, Query q, Map bn, int n) { setCount(n); @@ -1197,11 +1066,6 @@ public void groupBy() { groupBy(getCreateGroup()); } - public Mappings groupBy(List list) { - Group group = createGroup(list); - groupBy(group); - return this; - } /** * Generate the Mapping list according to the group PRAGMA: replace the @@ -1238,16 +1102,6 @@ public Mappings project() { return this; } - public Mappings project(Node q) { - Mappings map = create(getQuery()); - for (Mapping m : this) { - Mapping res = m.project(q); - if (res != null) { - map.add(res); - } - } - return map; - } /** * for group by ?o1 .. ?on @@ -1278,16 +1132,6 @@ public void setGroup(Group g) { group = g; } - /** - * Generate a group by list of variables - */ - public Group defineGroup(List list) { - ArrayList el = new ArrayList<>(); - for (String name : list) { - el.add(getQuery().getSelectExp(name)); - } - return createGroup(el); - } /** * group by @@ -1362,11 +1206,6 @@ Node getCommonNode(Mappings map) { return get(0).getCommonNode(map.get(0)); } - List getCommonVariables(Mappings map) { - HashMap t1 = unionVariable(); - HashMap t2 = map.unionVariable(); - return intersectionVariable(t1, t2); - } List intersectionVariable(HashMap t1, HashMap t2) { ArrayList varList = new ArrayList<>(); @@ -1399,9 +1238,6 @@ public Mappings union(Mappings lm) { return res; } - public Mappings and(Mappings lm) { - return join(lm); - } public Mappings join(Mappings lm) { Mappings res = Mappings.create(getQuery()); @@ -1524,18 +1360,6 @@ public Mappings option(Mappings lm) { return res; } - public Mappings project(List lExp) { - return new Mappings(); - } - - public Mappings rename(List lExp) { - Mappings res = new Mappings(); - for (Mapping m : this) { - res.add(m.rename(lExp)); - } - - return res; - } /** * Join (var = val) to each Mapping, remove those where var = something else @@ -1616,12 +1440,6 @@ public Map countBooleanValue() { return cmap; } - public Mappings limit(int n) { - while (size() > n) { - remove(size() - 1); - } - return this; - } public Mappings getMappings(Query q, Node varNode, Node val) { Mappings map = create(q); @@ -1642,29 +1460,6 @@ public Mappings getMappings(Query q) { return map.distinct(); } - /** - * Check if all values of a given variable are in same namespace - */ - void select() { - if (size() > 0) { - Mapping m = get(0); - if (m.size() > 0) { - Node varNode = m.getQueryNode(0); - if (varNode.isVariable()) { - IDatatype value = m.getValue(varNode); - if (value.isURI()) { - String ns = value.stringValue(); - boolean check = check(varNode, ns); - if (check) { - ArrayList objectArrayList = new ArrayList<>(); - objectArrayList.add(varNode); - objectArrayList.add(ns); - } - } - } - } - } - } boolean check(Node varNode, String ns) { for (Mapping m : this) { @@ -1680,22 +1475,6 @@ boolean check(Node varNode, String ns) { return true; } - /** - * Assign select nodes to all Mapping - */ - public void finish() { - if (getSelect() != null) { - Node[] nodes = new Node[getSelect().size()]; - int i = 0; - for (Node node : getSelect()) { - nodes[i++] = node; - } - - for (Mapping map : this) { - map.setSelect(nodes); - } - } - } @Override public TripleStore getTripleStore() { @@ -1746,9 +1525,6 @@ public void setDelete(List lDelete) { this.delete = lDelete; } - public int nbSolutions() { - return nbsolutions; - } void setNbsolutions(int nbsolutions) { this.nbsolutions = nbsolutions; @@ -1841,9 +1617,6 @@ public void setError(boolean error) { this.error = error; } - public Object getProvenance() { - return provenance; - } public void setProvenance(Object provenance) { this.provenance = provenance; @@ -1855,35 +1628,6 @@ void setNamedGraph(Node node) { } } - public String getLink(String name) { - for (var url : getLinkList()) { - if (url.contains(name)) { - return url; - } - } - return null; - } - - public String getLastLink(String name) { - for (int i = getLinkList().size() - 1; i >= 0; i--) { - var url = getLinkList().get(i); - if (url.contains(name)) { - return url; - } - } - return null; - } - - public String getLink() { - if (getLinkList().isEmpty()) { - return null; - } - return getLinkList().get(0); - } - - public void setLink(String link) { - addLink(link); - } public void addLink(String link) { getLinkList().add(link); @@ -2015,17 +1759,6 @@ public boolean contains(IDatatype value) { return false; } - public Mappings getResult() { - Query q = getQuery(); - ASTQuery ast = getAST(); - if (ast.hasMetadata(Metadata.SELECTION) && q.getSelection() != null) { - return q.getSelection(); - } - if (ast.hasMetadata(Metadata.DISCOVERY) && q.getDiscorevy() != null) { - return q.getDiscorevy(); - } - return this; - } class VariableSorter implements Comparator { diff --git a/src/main/java/fr/inria/corese/core/kgram/core/Memory.java b/src/main/java/fr/inria/corese/core/kgram/core/Memory.java index da8e1f764..7ba378b9b 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/Memory.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/Memory.java @@ -75,9 +75,6 @@ public Memory(Matcher m, Evaluator e) { this.appxSearchEnv = new ApproximateSearchEnv(); } - public static void recordEdge(boolean b) { - IS_EDGE = b; - } @Override public EventManager getEventManager() { @@ -116,9 +113,6 @@ void setGroup(Mappings lm) { group = lm; } - Mappings getResults() { - return results; - } public Memory setResults(Mappings r) { results = r; @@ -130,9 +124,6 @@ public Query getQuery() { return query; } - public Matcher getMatcher() { - return match; - } @Override public Node getGraphNode() { @@ -144,13 +135,6 @@ public void setGraphNode(Node g) { gNode = g; } - public Stack getStack() { - return stack; - } - - void setStack(Stack s) { - stack = s; - } @Override public Exp getExp() { @@ -162,9 +146,6 @@ public void setExp(Exp ee) { exp = ee; } - public boolean isAggregate() { - return isAggregate; - } public void init(Memory memory) { setGraphNode(memory.getGraphNode()); @@ -354,12 +335,6 @@ void copyInto(Node qNode, Memory mem, int n) { } } - /** - * Store a new result: take a picture of the stack as a Mapping - */ - Mapping store(Query q, Producer p) throws SparqlException { - return store(query, p, false, false); - } Mapping store(Query q, Producer p, boolean subEval) throws SparqlException { return store(query, p, subEval, false); @@ -552,12 +527,6 @@ void setMap(Map m) { bnode = m; } - Mapping store(Query q, Mapping map, Producer p) throws SparqlException { - Node[] gnode = new Node[q.getGroupBy().size()]; - orderGroup(q.getGroupBy(), gnode, p); - map.setGroupBy(gnode); - return map; - } void orderGroup(List lExp, Node[] nodes, Producer p) throws SparqlException { int n = 0; @@ -663,14 +632,6 @@ void pop(Edge q, int length) { } } - void event(Edge q) { - for (int i = 0; i < q.nbNode(); i++) { - Node node = q.getNode(i); - if ((node != null) && (nbNodes[node.getIndex()] == 1)) { - send(Event.BIND, node, nodes[node.getIndex()]); - } - } - } void send(int type, Object obj, Object arg) { Event e = EventImpl.create(type, obj, arg); @@ -978,9 +939,6 @@ public Edge getEdge(Edge qEdge) { return result[qEdge.getEdgeIndex()]; } - public Edge getEdge(int n) { - return result[n]; - } public Edge[] getQueryEdges() { return qEdges; @@ -991,25 +949,6 @@ public Edge[] getEdges() { return result; } - public Edge getEdge(Node qnode) { - for (Edge e : getQueryEdges()) { - if (e.getEdgeVariable() != null - && e.getEdgeVariable().equals(qnode)) { - return getEdge(e); - } - } - return null; - } - - public Edge getEdge(String varString) { - for (Edge e : getQueryEdges()) { - if (e != null && e.getEdgeVariable() != null - && e.getEdgeVariable().getLabel().equals(varString)) { - return getEdge(e); - } - } - return null; - } @Override public Node[] getNodes() { @@ -1092,10 +1031,6 @@ public Node getNode(Expr varExpr) { return getNode(index); } - // Filter evaluator - public Evaluator getEvaluator() { - return eval; - } /* * ************************************* @@ -1107,17 +1042,6 @@ public int count() { return current().size(); } - public int sum(Node qNode) { - return -1; - } - - public Node max(Node qNode) { - return current().max(qNode); - } - - public Node min(Node qNode) { - return current().min(qNode); - } /** * Current group is set by Mappings aggregate function @@ -1148,9 +1072,6 @@ public Iterable getAggregate() { return current(); } - void setAggregate(boolean b) { - isAggregate = b; - } /** * Prepare Mapping for aggregate @@ -1190,9 +1111,6 @@ public Path getPath(Node qNode) { return node.getPath(); } - boolean isPath(Node qNode) { - return getPath(qNode) != null; - } @Override public Object getObject() { diff --git a/src/main/java/fr/inria/corese/core/kgram/core/Merge.java b/src/main/java/fr/inria/corese/core/kgram/core/Merge.java index 50b7698a9..95e276c8c 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/Merge.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/Merge.java @@ -51,11 +51,6 @@ public class ListMappings extends ArrayList { } - public Collection values(){ - List ll = new ArrayList(); - ll.add(list); - return ll; - } public Iterable getValues(){ return list; diff --git a/src/main/java/fr/inria/corese/core/kgram/core/Query.java b/src/main/java/fr/inria/corese/core/kgram/core/Query.java index 2ca2573c3..df35e02e1 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/Query.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/Query.java @@ -59,12 +59,6 @@ public static DQPFactory getFactory() { return factory; } - /** - * @param aFactory the factory to set - */ - public static void setFactory(DQPFactory aFactory) { - factory = aFactory; - } int limit = Integer.MAX_VALUE, offset = 0, // if slice > 0 : service gets mappings from previous pattern by slices @@ -264,9 +258,6 @@ public static Query create(Exp e) { return new Query(e); } - public static Query create(int type) { - return new Query(); - } @Override public String toString() { @@ -315,14 +306,6 @@ public StringBuilder toString(StringBuilder sb) { } - /** - * Add values () {} for this Mappings - */ - public void addMappings(Mappings map) { - Exp values = createValues(getNodeListValues(map), map); - getBody().add(values); - setMappings(map); - } List getNodeListValues(Mappings map) { List list = new ArrayList<>(); @@ -335,9 +318,6 @@ List getNodeListValues(Mappings map) { return list; } - public void set(Sorter s) { - querySorter.setSorter(s); - } public void set(Edge e, Query q) { table.put(e, q); @@ -347,9 +327,6 @@ Query get(Edge e) { return table.get(e); } - public void addQuery(Query q) { - queries.add(q); - } public List getQueries() { return queries; @@ -414,9 +391,6 @@ public void addError(String mes, Object obj) { getGlobalQuery().setError(mes, obj); } - public void addError(String mes, Object obj, boolean duplicate) { - getGlobalQuery().setError(mes, obj, duplicate); - } void setError(String mes, Object obj) { setError(mes, obj, true); @@ -493,9 +467,6 @@ void inherit(Query q) { } } - boolean needEdge(){ - return getGlobalQuery().isRelax() || getGlobalQuery().isRule(); - } public Query getGlobalQuery() { if (query != null) { @@ -519,15 +490,6 @@ boolean isSubQuery() { return query != null; } - /** - * Select Query is empty and does nothing - */ - boolean isEmpty(){ - return isSelect() - && getSelectFun().isEmpty() - && getBody().size() == 0 - && getValues().getMappings() == null; - } public boolean isSelectExpression(){ for (Exp e : getSelectFun()) { @@ -546,13 +508,6 @@ public void setCheckLoop(boolean b) { isCheckLoop = b; } - boolean isPipe() { - return isPipe; - } - - public void setPipe(boolean b) { - isPipe = b; - } /** * Fake local graph node @@ -593,18 +548,6 @@ List getFunList(){ return funList; } - /** - * Return equivalent local node for graph node it may be a local node with - * same variable name it may be a fake node - */ - public Node getGraphNode(Node g) { - Node node = getSelectNode(g.getLabel()); - if (node != null) { - return node; - } else { - return getGraphNode(); - } - } public Exp getFunction() { for (Exp exp : getSelectFun()) { @@ -615,9 +558,6 @@ public Exp getFunction() { return null; } - public static boolean isSPARQL2() { - return true; - } public String getFromName() { List from = getFrom(); @@ -655,17 +595,11 @@ public List getPatternNodes() { return patternNodes; } - public List getQueryNodes() { - return queryNodes; - } public List getPatternSelectNodes() { return patternSelectNodes; } - public List getQuerySelectNodes() { - return querySelectNodes; - } public List getBindingNodes() { if (getValues() == null) { @@ -760,17 +694,6 @@ public void setSlice(int n) { slice = n; } - public int getSlice() { - return slice; - } - - public void setMap(boolean b) { - isMap = b; - } - - public boolean isMap() { - return isMap; - } public void setLimit(int n) { limit = n; @@ -889,25 +812,11 @@ public void setUpdate(boolean b) { isUpdate = b; } - public boolean isTest() { - return isTest; - } public void setTest(boolean b) { isTest = b; } - public boolean isNew() { - return isNew; - } - - public void setNew(boolean b) { - isNew = b; - } - - public boolean isOptimize() { - return isOptimize; - } public void setOptimize(boolean b) { isOptimize = b; @@ -932,9 +841,6 @@ public void setAggregate() { } } - public void addFailure(Filter exp) { - failure.add(exp); - } public List getFailures() { return failure; @@ -944,25 +850,16 @@ public void setSelectFun(List s) { selectExp = s; } - public void addSelect(Exp exp) { - selectExp.add(exp); - } public void addSelect(Node node) { selectExp.add(Exp.create(ExpType.Type.NODE, node)); } - public void addOrderBy(Exp exp) { - orderBy.add(exp); - } public void addOrderBy(Node node) { orderBy.add(Exp.create(ExpType.Type.NODE, node)); } - public void addGroupBy(Exp exp) { - groupBy.add(exp); - } public void addGroupBy(Node node) { groupBy.add(Exp.create(ExpType.Type.NODE, node)); @@ -1052,9 +949,6 @@ public Exp getConstruct() { return construct; } - public Exp getInsert() { - return construct; - } public void setDelete(Exp c) { delete = c; @@ -1064,15 +958,6 @@ public Exp getDelete() { return delete; } - public int nbFun() { - int nbfun = 0; - for (Exp e : getSelectFun()) { - if (e.getFilter() != null) { - nbfun++; - } - } - return nbfun; - } /** * Check that select variables and expressions are compatible with group by @@ -1191,9 +1076,6 @@ public int nbEdges() { return iEdge; } - public synchronized int nbPath() { - return iPath++; - } /** * Called by Eval before query evaluation @@ -1272,9 +1154,6 @@ void complete2() { } } - void compile(Filter f) { - querySorter.compile(f); - } void index(List list) { for (Exp ee : list) { @@ -1660,15 +1539,6 @@ boolean isTriple(Exp exp, String name) { return false; } - boolean inSelect(Node qNode) { - for (Exp exp : getSelectFun()) { - Node node = exp.getNode(); - if (node == qNode) { - return true; - } - } - return false; - } /** * Generate or retrieve index of node @@ -1707,9 +1577,6 @@ int getNodeIndex() { return iNode; } - void setNodeIndex(int n) { - iNode = n; - } /** * @@ -1747,18 +1614,12 @@ public void distinct() { - public boolean isPrinterTemplate() { - return isPrinterTemplate; - } public void setPrinterTemplate(boolean isPrinterTemplate) { this.isPrinterTemplate = isPrinterTemplate; } - public boolean isMatchBlank() { - return isMatch; - } public void setMatchBlank(boolean match) { @@ -1815,25 +1676,6 @@ public void setProfile(String uri) { profile = uri; } - public String getProfile() { - return profile; - } - - public void setNumbering(boolean b) { - isNumbering = b; - } - - public boolean isNumbering() { - return isNumbering; - } - - public Query getTemplateProfile() { - return templateProfile; - } - - public void setTemplateProfile(Query templateProfile) { - this.templateProfile = templateProfile; - } /** * Compute node list for filter variables use case: Pattern compiler (?x = @@ -1855,14 +1697,6 @@ public List getNodes(Filter f) { return lNode; } - /** - * use case: select count(distinct ?x) - */ - public List getAggNodes(Filter f) { - ArrayList lNode = new ArrayList<>(); - getAggNodes(f.getExp(), lNode); - return lNode; - } void getAggNodes(Expr exp, ArrayList lNode) { if (exp.type() == ExprType.VARIABLE) { @@ -1903,42 +1737,6 @@ boolean index(Query query, Expr exp) { return b; } - /** - * ******************************************************************** - * - * Pipeline using operators on queries: union/and/optional/minus - * q1.union(q2).and(q3).optional(q4).minus(q5) - * - ********************************************************************* - */ - public Query union(Query q2) { - Query q1 = this; - Exp exp = Exp.create(ExpType.Type.UNION, q1, q2); - return Query.create(exp).complete(q1, q2); - } - - public Query and(Query q2) { - Query q1 = this; - Exp exp = Exp.create(ExpType.Type.AND, q1, q2); - return Query.create(exp).complete(q1, q2); - } - - public Query minus(Query q2) { - Query q1 = this; - Exp exp = Exp.create(ExpType.Type.MINUS, q1, Exp.create(ExpType.Type.AND, q2)); - return Query.create(exp).complete(q1, q2); - } - - public Query optional(Query q2) { - Query q1 = this; - Exp exp = Exp.create(ExpType.Type.AND, q1, Exp.create(ExpType.Type.OPTION, Exp.create(ExpType.Type.AND, q2))); - return Query.create(exp).complete(q1, q2); - } - - public Query ifthen(Query q1, Query q2) { - - return this; - } public Query orderBy(Node node) { if (node != null && !contain(getOrderBy(), node)) { @@ -1947,9 +1745,6 @@ public Query orderBy(Node node) { return this; } - public Query orderBy(String n) { - return orderBy(getNode(n)); - } public Query groupBy(Node node) { if (node != null && !contain(getGroupBy(), node)) { @@ -1958,9 +1753,6 @@ public Query groupBy(Node node) { return this; } - public Query groupBy(String n) { - return groupBy(getNode(n)); - } public Query select(Node node) { if (node != null && !contain(getSelectFun(), node)) { @@ -1969,9 +1761,6 @@ public Query select(Node node) { return this; } - public Query select(String n) { - return select(getNode(n)); - } Query complete(Query q1, Query q2) { q1.setOuterQuery(this); @@ -2033,16 +1822,6 @@ public Filter getFilter(String name) { return ftable.get(name); } - public Expr getProfile(String name) { - if (templateProfile == null) { - return null; - } - Filter f = templateProfile.getFilter(name); - if (f == null) { - return null; - } - return f.getExp(); - } public Filter getGlobalFilter(String name) { return getGlobalQuery().getFilter(name); @@ -2052,31 +1831,17 @@ public void setFilter(String name, Filter filter) { ftable.put(name, filter); } - public Iterable getFilterNames() { - return ftable.keySet(); - } public Object getPragma(String name) { return pragma.get(name); } - public String getStringPragma(String name) { - return (String) pragma.get(name); - } public boolean hasPragma(String name) { return pragma.get(name) != null; } - public boolean isPragma(String name) { - Object obj = pragma.get(name); - if (obj == null || !(obj instanceof Boolean)) { - return false; - } - Boolean b = (Boolean) obj; - return b; - } public void setPragma(String name, Object value) { pragma.put(name, value); @@ -2103,13 +1868,6 @@ public boolean isDetail() { return isDetail; } - public void setSynchronized(boolean b) { - isSynchronized = b; - } - - public boolean isSynchronized() { - return isSynchronized; - } public Object getTransformer(String p) { return getGlobalQuery().getPPrinter(p); @@ -2165,9 +1923,6 @@ public void setNumber(int number) { this.number = number; } - public boolean isAllResult() { - return true; //isAllResult; - } public void setAllResult(boolean isAllResult) { this.isAllResult = isAllResult; @@ -2189,9 +1944,6 @@ public void setTemplateNL(Exp nl) { this.templateNL = nl; } - public boolean isStdOptional() { - return isOptional; - } public void recordPredicate(Node p, Edge edge) { Integer i = ptable.get(p.getLabel()); @@ -2254,9 +2006,6 @@ public void setCachePath(boolean isCachePath) { } - public int getID() { - return id; - } public void setID(int id) { @@ -2273,30 +2022,6 @@ public void setProvenance(Node provenance) { this.provenance = provenance; } -/* - @Override - public Object getGraph() { - return graph; - } - - - @Override - public void setGraph(Object graph) { - this.graph = graph; - } - - @Override - public String toGraph() { - return getAST().toGraph(); - } -*/ - public void setExtension(boolean b) { - isExtension = b; - } - - public boolean isExtension() { - return isExtension; - } public ASTExtension getExtension() { return extension; @@ -2323,10 +2048,6 @@ public boolean hasDefinition(){ } - // API for Eval event-driven function call - public Expr getExpression(String name){ - return getExpression(name, false); - } public Expr getExpression(String name, boolean inherit){ Expr ee = getLocalExpression(name); @@ -2406,26 +2127,6 @@ public void setBgpGenerator(BgpGenerator bgpGenerator) { this.bgpGenerator = bgpGenerator; } - public HashMap getEdgeAndContext() { - if (getBgpGenerator() == null){ - return null; - } - return getBgpGenerator().getEdgeAndContext(); - } - - - public List getQueryEdgeList() { - return queryEdgeList; - } - - public void setQueryEdgeList(List queryEdgeList) { - this.queryEdgeList = queryEdgeList; - } - - - public boolean isFun() { - return isFun; - } public void setFun(boolean isFun) { @@ -2494,16 +2195,6 @@ public void setEnvironment(HashMap map){ tprinter = map; } - /** - * Use case: PluginImpl kgram() - * Query inherits q transformer information - * @param q - */ - public void complete(Query q, Context context){ - setEnvironment(q.getEnvironment()); - setTransformer(q.getTransformer()); - setContext(context); - } @Override @@ -2517,9 +2208,6 @@ public void setMapping(Mapping mapping) { } - public int getPriority() { - return priority; - } public void setPriority(int priority) { @@ -2545,25 +2233,6 @@ public boolean isInsert() { return isInsert; } - public boolean isUpdateInsert() { - return getAST().isUpdateInsert(); - } - - public boolean isUpdateDelete() { - return getAST().isUpdateDelete(); - } - - public boolean isUpdateInsertData() { - return getAST().isUpdateInsertData(); - } - - public boolean isUpdateDeleteData() { - return getAST().isUpdateDeleteData(); - } - - public boolean isUpdateLoad() { - return getAST().isUpdateLoad(); - } public boolean isLock() { @@ -2586,9 +2255,6 @@ public void setParallel(boolean parallel) { } - public boolean isServiceResult() { - return serviceResult; - } public void setServiceResult(boolean serviceResult) { @@ -2611,9 +2277,6 @@ public boolean isValidate() { } - public void setValidate(boolean validate) { - this.validate = validate; - } public boolean isAlgebra() { @@ -2641,9 +2304,6 @@ public boolean isImportFailure() { } - public void setImportFailure(boolean importFailure) { - this.importFailure = importFailure; - } public Mappings getSelection() { return selection; diff --git a/src/main/java/fr/inria/corese/core/kgram/core/QuerySorter.java b/src/main/java/fr/inria/corese/core/kgram/core/QuerySorter.java index 08ec041df..4ca35caa9 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/QuerySorter.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/QuerySorter.java @@ -264,33 +264,6 @@ void setBind(Query q, Exp exp){ } } - // put the binding variables to concerned edge - void setBind(Exp exp, List bindings) { - for (Exp bid : bindings) { - Node n = bid.get(0).getNode(); - if (bid.type() == ExpType.Type.OPT_BIND - // no bind (?x = ?y) in case of JOIN - && (!Query.testJoin || bid.isBindCst())) { - - for (Exp g : exp) { - if (((g.isEdge() || g.isPath()) && g.getEdge().contains(n)) - && (!bid.isBindCst() || g.bind(bid.first().getNode()))) { - if (g.getBind() == null) { - bid.status(true); - g.setBind(bid); - } - } - } - } - } - } - - boolean contains(Exp exp, Node n) { - if (!exp.isEdge()) { - return false; - } - return exp.getEdge().contains(n); - } void compile(Filter f, VString lVar, boolean opt) { compile(f.getExp(), lVar, opt); @@ -400,9 +373,6 @@ public List findBindings(Exp exp) { } - public Sorter getSorter() { - return sort; - } public void setSorter(Sorter sort) { @@ -501,9 +471,6 @@ public Query getQuery() { return query; } - public void setQuery(Query query) { - this.query = query; - } public Producer getProducer() { return prod; diff --git a/src/main/java/fr/inria/corese/core/kgram/core/Sorter.java b/src/main/java/fr/inria/corese/core/kgram/core/Sorter.java index 79c553533..a13fd0340 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/Sorter.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/Sorter.java @@ -54,25 +54,6 @@ public void sort(Query q, Exp exp, List lVar, List lBind) { } - void check(Query q, Exp exp, List list) { - if (!(exp.isEdge() || exp.isPath())) { - return; - } - - boolean connect = false; - - for (int i = 0; i < exp.nbNode(); i++) { - Node n = exp.getNode(i); - if (list.contains(n)) { - connect = true; - break; - } - } - - if (!connect) { - q.addInfo("Disconnected: ", exp); - } - } public boolean leaveFirst() { return true; diff --git a/src/main/java/fr/inria/corese/core/kgram/core/Stack.java b/src/main/java/fr/inria/corese/core/kgram/core/Stack.java index 826efac36..b6fe04d96 100644 --- a/src/main/java/fr/inria/corese/core/kgram/core/Stack.java +++ b/src/main/java/fr/inria/corese/core/kgram/core/Stack.java @@ -21,13 +21,6 @@ public static Stack create(Exp e){ } // public Exp get(int n){ -// Exp e = super.get(n); -// return e; -// } - - public int getLevel(){ - return level; - } Stack copy(){ Stack st = new Stack(); @@ -35,39 +28,6 @@ Stack copy(){ return st; } - /** - * use case: - * A union B - * exp is A or is B - * Copy the stack for exp - * set exp at level n of new stack - * In addition we store this new stack into exp. - * Next time the data structure will be reused (after clean) - */ - Stack copy(Exp exp, int n){ - Stack st = exp.getStack(); - if (st == null){ - st = new Stack(); - exp.setStack(st); - } - else { - st.clear(); - } - st.addAll(this); - st.set(n, exp); - return st; - } - - Stack copy2(Exp exp, int n){ - Stack st = new Stack(); - st.addAll(this); - st.set(n, exp); - return st; - } - - boolean isCompleted() { - return size() == 1; - } /** * Push all elements of AND in the stack @@ -90,35 +50,6 @@ Stack addCopy(int n, Exp exp) { return copy; } - void reset(int n, Exp exp){ - while (size()-1 > n){ - remove(size()-1); - } - if (size()-1 == n){ - set(n, exp); - } - else { - add(exp); - } - } - - /** - * compile OPTIONAL{EXP} and NOT{EXP} - * as WATCH EXP NEXT - * begin: WATCH - * next: CONTINUE/BACKJUMP - */ - Stack watch(Exp exp, ExpType.Type start, ExpType.Type next, boolean skip, int n){ - Exp end = Exp.create(next); - Exp begin = Exp.create(start, end); - end.add(begin); - end.skip(skip); - - set(n, begin); - add(n+1, exp); - add(n+2, end); - return this; - } @Override public String toString(){ diff --git a/src/main/java/fr/inria/corese/core/kgram/event/EvalListener.java b/src/main/java/fr/inria/corese/core/kgram/event/EvalListener.java index 5783e2cb9..ce434e1fc 100644 --- a/src/main/java/fr/inria/corese/core/kgram/event/EvalListener.java +++ b/src/main/java/fr/inria/corese/core/kgram/event/EvalListener.java @@ -41,11 +41,6 @@ public static EvalListener create() { return el; } - public static EvalListener create(int n) { - EvalListener el = create(); - el.index = n; - return el; - } void init(boolean b) { table = new Hashtable(); @@ -77,13 +72,6 @@ public boolean handle(int sort, boolean b) { } - /** - * Proxy to User Interaction: - * return next, skip, quit, etc. - */ - public void setUser(User b) { - user = b; - } public boolean send(Event e) { @@ -254,9 +242,6 @@ boolean process(Event e) { } - Node getNode(Node qNode) { - return kgram.getEnvironment().getNode(qNode); - } @Override public void setObject(Object obj) { @@ -267,9 +252,6 @@ public void setObject(Object obj) { } } - public Eval getKGRAM() { - return kgram; - } } diff --git a/src/main/java/fr/inria/corese/core/kgram/event/EventImpl.java b/src/main/java/fr/inria/corese/core/kgram/event/EventImpl.java index 01f607e78..2706f8ec2 100644 --- a/src/main/java/fr/inria/corese/core/kgram/event/EventImpl.java +++ b/src/main/java/fr/inria/corese/core/kgram/event/EventImpl.java @@ -128,10 +128,6 @@ static void init(){ - public static EventImpl create(int type){ - EventImpl e = new EventImpl(type); - return e; - } public static EventImpl create(int type, Object obj){ EventImpl e = new EventImpl(type, obj); diff --git a/src/main/java/fr/inria/corese/core/kgram/event/EventManager.java b/src/main/java/fr/inria/corese/core/kgram/event/EventManager.java index 7b6c4ce7c..30707b0ba 100644 --- a/src/main/java/fr/inria/corese/core/kgram/event/EventManager.java +++ b/src/main/java/fr/inria/corese/core/kgram/event/EventManager.java @@ -16,9 +16,6 @@ public class EventManager implements Iterable { List observers = new Vector(); - public static EventManager create() { - return new EventManager(); - } public void addEventListener(EventListener el) { observers.add(el); @@ -26,39 +23,6 @@ public void addEventListener(EventListener el) { } - public void removeEventListener(EventListener el) { - observers.remove(el); - } - - public void removeEventListener(int sort) { - for (int i = 0; i < observers.size();) { - EventListener el = observers.get(i); - if (el.handle(sort)) { - observers.remove(el); - } else { - i++; - } - } - } - - public List getEventListeners() { - return observers; - } - - public void setObject(Object obj) { - for (EventListener el : observers) { - el.setObject(obj); - } - } - - public boolean handle(int sort) { - switch (sort) { - case Event.START: - return isEval; - default: - return true; - } - } @Override public Iterator iterator() { diff --git a/src/main/java/fr/inria/corese/core/kgram/event/StatListener.java b/src/main/java/fr/inria/corese/core/kgram/event/StatListener.java index 0e52b1f6b..affcbfd36 100644 --- a/src/main/java/fr/inria/corese/core/kgram/event/StatListener.java +++ b/src/main/java/fr/inria/corese/core/kgram/event/StatListener.java @@ -60,9 +60,6 @@ public static StatListener create(){ return el; } - public int getStat(int type){ - return stat[type]; - } public boolean send(Event e){ total++; @@ -102,20 +99,6 @@ public boolean send(Event e){ } - public String display(){ - String str = ""; - for (int i = 0; i<= imax; i++){ - String s = Integer.toString(i); - if (i<=9) s = "0" + s; - str += s + " " + status[i] + " " + counter[i]; - if (counter[i] >0){ - str += " " + nf.format(((status[i] * 1.0 / counter[i]) * 100.0)) + "%" ; - } - str += " : " + edges[i]; - str += "\n"; - } - return str; - } public String toString(){ String str = ""; diff --git a/src/main/java/fr/inria/corese/core/kgram/filter/Checker.java b/src/main/java/fr/inria/corese/core/kgram/filter/Checker.java index dad930187..0dd97acbf 100644 --- a/src/main/java/fr/inria/corese/core/kgram/filter/Checker.java +++ b/src/main/java/fr/inria/corese/core/kgram/filter/Checker.java @@ -310,13 +310,6 @@ Pattern eqNotGe(){ return and(term(EQ, e1, e2), not(term(GE, e1, e2))); } - // PRAGMA: not for simple variable - Pattern variable(String name){ - Pattern var = Pattern.variable(name); - Pattern pat = pat(JOKER, JOKER, var); - pat.setRec(true); - return pat; - } Pattern constant(){ return Pattern.constant(); @@ -352,9 +345,6 @@ List rewritable(){ - boolean isPattern(Expr e){ - return e instanceof Pattern; - } Pattern leLt(){ // EXP1 <= EXP2 && EXP1 < EXP2 -> EXP1 = EXP2 @@ -495,9 +485,6 @@ Pattern term(int ope, Pattern e1, Pattern e2){ return pat(TERM, ope, e1, e2); } - Pattern fun(int ope, Pattern e1){ - return pat(FUNCTION, ope, e1); - } diff --git a/src/main/java/fr/inria/corese/core/kgram/filter/Compile.java b/src/main/java/fr/inria/corese/core/kgram/filter/Compile.java index a4494c486..b84480d34 100644 --- a/src/main/java/fr/inria/corese/core/kgram/filter/Compile.java +++ b/src/main/java/fr/inria/corese/core/kgram/filter/Compile.java @@ -48,17 +48,6 @@ public Compile(Query q){ checker = new Checker(query); } - public boolean check(String v1, String v2, Exp exp){ - return checker.check(v1, v2, exp.getFilter().getExp()); - } - - public boolean check(Exp exp){ - return checker.check(exp.getFilter().getExp()); - } - - public boolean check(Exp exp1, Exp exp2){ - return checker.check(exp1.getFilter().getExp(), exp2.getFilter().getExp()); - } /** * exp is a FILTER Exp @@ -95,25 +84,6 @@ public void process(Query q, Exp exp){ } - /** - * ! bound(?x) - */ - void not(Exp exp){ - Filter ff = exp.getFilter(); - Expr ee = ff.getExp(); - Pattern pat = new Pattern(BOOLEAN, NOT, new Pattern(FUNCTION, BOUND, VARIABLE)); - if (matcher.match(pat, ee)){ - // ! bound(?x) - List list = ff.getVariables(); - if (list.size()>0){ - Node node = query.getProperAndSubSelectNode(list.get(0)); - if (node != null){ - exp.setNode(node); - exp.status(true); - } - } - } - } diff --git a/src/main/java/fr/inria/corese/core/kgram/filter/Pattern.java b/src/main/java/fr/inria/corese/core/kgram/filter/Pattern.java index 6dbf9a989..520c01a1a 100644 --- a/src/main/java/fr/inria/corese/core/kgram/filter/Pattern.java +++ b/src/main/java/fr/inria/corese/core/kgram/filter/Pattern.java @@ -80,9 +80,6 @@ static Pattern constant(){ } - Pattern pat(int type){ - return new Pattern(type); - } Pattern pat(int type, int ope, Pattern e1){ return new Pattern(type, ope, e1); @@ -92,25 +89,6 @@ Pattern pat(int type, int ope, Pattern e1, Pattern e2){ return new Pattern(type, ope, e1, e2); } - Pattern not(Pattern e){ - return pat(BOOLEAN, NOT, e); - } - - Pattern and(Pattern e1, Pattern e2){ - return pat(BOOLEAN, AND, e1, e2); - } - - Pattern or(Pattern e1, Pattern e2){ - return pat(BOOLEAN, OR, e1, e2); - } - - Pattern term(int ope, Pattern e1, Pattern e2){ - return pat(TERM, ope, e1, e2); - } - - Pattern fun(int ope, Pattern e1, Pattern e2){ - return pat(FUNCTION, ope, e1, e2); - } @@ -143,9 +121,6 @@ public Expr getExp(int i) { } - public Expr getExp() { - return exp; - } public List getExpList() { @@ -193,9 +168,6 @@ public int oper() { } - public void setExp(Expr e) { - exp = e; - } public void setIndex(int index) { @@ -285,9 +257,6 @@ public void addExp(int i, Expr e) { } - public void local(Expr var) { - - } @Override public Expr getDefine() { diff --git a/src/main/java/fr/inria/corese/core/kgram/path/Automaton.java b/src/main/java/fr/inria/corese/core/kgram/path/Automaton.java index 459d745ec..ad5eddb61 100644 --- a/src/main/java/fr/inria/corese/core/kgram/path/Automaton.java +++ b/src/main/java/fr/inria/corese/core/kgram/path/Automaton.java @@ -50,32 +50,6 @@ public State getIn(){ return in; } - public State getOut(){ - return out; - } - - public void setCurrent(State state){ - current = state; - } - - public State getCurrent(){ - return current; - } - - boolean isBound(){ - return isBound; - } - - public void start(){ - current = in; - for (State state : table){ - state.setLoop(-1); - state.setCount(0); - for (Step step : state.getSteps()){ - step.setWalk(false); - } - } - } public String toString(){ String str = ""; @@ -93,26 +67,6 @@ public String toString(){ return str; } - /** - * Compile regex into automaton - */ - void compile(Regex exp){ - compute(exp, null, false, false, false); - if (pending.size()>0){ - // complete pending transitions to final state - out = create(); - for (Step step : pending){ - step.setState(out); - } - pending.clear(); - } - else { - // use case: star(Exp) - out = current; - } - out.setOut(true); - compile(); - } void compile(){ for (State state : table){ @@ -303,18 +257,6 @@ else if (exp.isStar()){ } - /** - * use case: - * (p1/p2)* - * exp = p1/p2 - * return true - * - * TODO: - * ((p1?/p2?)/p3)* - */ - boolean isStar(Regex exp, int n){ - return true; - } boolean isBound(Regex exp){ boolean b = exp.getMin() != -1 || exp.getMax() != -1; @@ -328,16 +270,6 @@ boolean isUpperBound(Regex exp){ } - /** - return starting properties of automaton - WARNING: - return null means all properties needed - */ - List getStart(){ - ArrayList evec = new ArrayList (); - Table svec = new Table(); - return getStart(getIn(), evec, svec); - } ArrayList getStart(State st, ArrayList evec, Table svec){ svec.add(st); diff --git a/src/main/java/fr/inria/corese/core/kgram/path/GraphPath.java b/src/main/java/fr/inria/corese/core/kgram/path/GraphPath.java index 18139418e..f7566bc08 100644 --- a/src/main/java/fr/inria/corese/core/kgram/path/GraphPath.java +++ b/src/main/java/fr/inria/corese/core/kgram/path/GraphPath.java @@ -40,7 +40,4 @@ void process(){ } - public void run(){ - process(); - } } diff --git a/src/main/java/fr/inria/corese/core/kgram/path/Path.java b/src/main/java/fr/inria/corese/core/kgram/path/Path.java index 1e1dbf571..de34ffaee 100644 --- a/src/main/java/fr/inria/corese/core/kgram/path/Path.java +++ b/src/main/java/fr/inria/corese/core/kgram/path/Path.java @@ -47,9 +47,6 @@ public Path(boolean b) { path = new ArrayList(n); } - public ArrayList getEdges() { - return path; - } @Override public Path getPathObject() { @@ -89,13 +86,6 @@ int getMax() { return max; } - void checkLoopNode(boolean b) { - loopNode = b; - } - - public void clear() { - path.clear(); - } public void add(Edge ent) { path.add(ent); @@ -111,18 +101,6 @@ public void remove(Edge ent, int w) { weight -= w; } - public void remove() { - path.remove(path.size() - 1); - } - - // after reverse path - public Node getSource() { - return getEdge(0).getNode(0); - } - - public Node getTarget() { - return getEdge(size() - 1).getNode(1); - } // before reverse path // edge may be EdgeInv in case of ^p @@ -157,28 +135,6 @@ public Edge getEdge(int n) { return ent.getEdge(); } - public Edge last() { - if (size() > 0) { - return get(size() - 1); - } else { - return null; - } - } - - public Path copy() { - Path path = new Path(size()); - for (Edge ent : this.path) { - // when r is reverse, add real target relation - if (ent instanceof EdgeInv) { - EdgeInv ee = (EdgeInv) ent; - path.add(ee.getEdgeEntity()); - } else { - path.add(ent); - } - } - path.setWeight(weight); - return path; - } public Path copy(Producer p) { Path path = new Path(size()); @@ -210,18 +166,6 @@ void setWeight(int w) { weight = w; } - // nb getResultValues() - public int nbValues() { - return 1 + 2 * path.size(); - } - - public void setRadius(int d) { - radius = d; - } - - public int radius() { - return radius; - } public Path reverse() { for (int i = 0; i < length() / 2; i++) { @@ -232,48 +176,6 @@ public Path reverse() { return this; } - public Iterator nodeIterator() { - - return new Iterator() { - private int i = 0; - private int j = 0; - private int ii; - private boolean hasNext = length() > 0; - - @Override - public boolean hasNext() { - return hasNext; - } - - @Override - public Node next() { - switch (j) { - case 0: - j = 1; - return path.get(i).getNode(0); - case 1: - ii = i; - if (i == path.size() - 1) { - j = 2; - } else { - j = 0; - i++; - } - return path.get(ii).getEdgeNode(); - case 2: - hasNext = false; - j = -1; - return path.get(i).getNode(1); - } - return null; - } - - @Override - public void remove() { - } - }; - - } @Override diff --git a/src/main/java/fr/inria/corese/core/kgram/path/PathFinder.java b/src/main/java/fr/inria/corese/core/kgram/path/PathFinder.java index 5d00dbf7b..087151095 100644 --- a/src/main/java/fr/inria/corese/core/kgram/path/PathFinder.java +++ b/src/main/java/fr/inria/corese/core/kgram/path/PathFinder.java @@ -137,12 +137,6 @@ public class PathFinder { public final static String INVERSE = "i"; private boolean isStorePath = true; - /** - * @return the isStorePath - */ - public boolean isStorePath() { - return isStorePath; - } /** * @param isStorePath the isStorePath to set @@ -167,18 +161,6 @@ public void setCache(boolean isCache) { class ITable extends Hashtable { - void setDistance(Node c, int i) { - put(c, i); //adistance[i]); - } - - int getDistance(Node c) { - Integer i = get(c); - if (i == null) { - return -1; - } else { - return i; - } - } } public PathFinder() { @@ -193,9 +175,6 @@ public PathFinder(Producer p, Matcher match, Evaluator eval, Query q) { store = new HashMap(); } - public static PathFinder create(Producer p, Matcher match, Evaluator eval, Query q) { - return new PathFinder(p, match, eval, q); - } public static PathFinder create(Eval eval, Producer p, Query q) { PathFinder pf = new PathFinder(p, eval.getMatcher(), eval.getEvaluator(), q); @@ -207,9 +186,6 @@ void setEval(Eval ev) { kgram = ev; } - public void setDefaultBreadth(boolean b) { - defaultBreadth = b; - } public void set(EventManager man) { manager = man; @@ -319,9 +295,6 @@ int index(Edge edge, Environment mem, List lVar) { return n; } - void setPathLength(int n) { - maxLength = n; - } /** * Enumerate all path, return a list of path 50% faster that thread but @@ -396,20 +369,11 @@ void mstart(Environment mem) { path.start(); } - public void run() { - Node cstart = get(memory, index); - process(cstart, memory); - } public void stop() { isStop = true; } - public void interrupt() { - if (path != null) { - path.interrupt(); - } - } /** * init at creation time, no need to change. pmax comes from pathLength() <= @@ -478,10 +442,6 @@ void start(int n) { } - // number of enumerated relations - public int getCount() { - return count; - } Node get(Environment memory, int i) { if (edge == null) { @@ -1088,20 +1048,6 @@ void eval(Record stack, Path path, Node start, Node src) { } - Regex test(Regex exp) { - - return exp; - } - - int reverse(int i) { - switch (i) { - case 0: - return 1; - case 1: - return 0; - } - return 0; - } boolean isDistinct(Record stack, Node start, Node target) { boolean b = stack.getVisit().isDistinct(start, target); @@ -1392,9 +1338,6 @@ else if (checkLoop) { } - Regex star(Regex exp) { - return exp; - } boolean hasMax(Regex exp) { return exp.getMax() != -1 && exp.getMax() != Integer.MAX_VALUE; diff --git a/src/main/java/fr/inria/corese/core/kgram/path/Stack.java b/src/main/java/fr/inria/corese/core/kgram/path/Stack.java index 160e23673..66bb3dacb 100644 --- a/src/main/java/fr/inria/corese/core/kgram/path/Stack.java +++ b/src/main/java/fr/inria/corese/core/kgram/path/Stack.java @@ -22,32 +22,6 @@ public class Stack { } - void clear(){ - steps.clear(); - sizes.clear(); - } - - void push(Step st, Path path){ - steps.add(st); - sizes.add(path.size()); - } - - void pop(Step st, Path path){ - steps.remove(steps.size()-1); - sizes.remove(sizes.size()-1); - } - - boolean loop(Step st, Path path){ - int index = steps.lastIndexOf(st); - if (index == -1) return false; - return sizes.get(index) == path.size(); - } - - int size(Step st){ - int index = steps.lastIndexOf(st); - if (index == -1) return -1; - return sizes.get(index); - } } diff --git a/src/main/java/fr/inria/corese/core/kgram/path/State.java b/src/main/java/fr/inria/corese/core/kgram/path/State.java index e92e0f645..4eb770e73 100644 --- a/src/main/java/fr/inria/corese/core/kgram/path/State.java +++ b/src/main/java/fr/inria/corese/core/kgram/path/State.java @@ -57,16 +57,6 @@ void setCount(int n){ count = n; } - void incCount(int n){ - count += n; - } - - boolean endLoop(){ - if (isBound()){ - return getCount() >= getMax(); - } - return false; - } int getMin(){ return getRegex().getMin(); @@ -92,9 +82,6 @@ void setFirst(boolean b){ first = b; } - boolean isFirst(){ - return first; - } /** * exp+ need check loop at once @@ -103,31 +90,11 @@ void setPlus(boolean b){ check = b; } - boolean isPlus(){ - // check = true for exp+ wich is compiled as exp{1,} - //return isFirst() ;//&& isCheckLoop(); - return check; - } - - /** - * This state implements a loop such as: - * exp* exp+ exp{} - * return true if we must prevent a loop on visited nodes - * in case of exp{2,} we do not need to check the loop for the first two steps - */ - boolean isCheckLoop(){ - return (! isBound() || // exp* - getCount() >= getMin() || // exp{2,} - check); // exp+ - } void setLoop(int n){ loop = n; } - public int getLoop(){ - return loop; - } void compile(){ steps = new Step[list.size()]; diff --git a/src/main/java/fr/inria/corese/core/kgram/path/Step.java b/src/main/java/fr/inria/corese/core/kgram/path/Step.java index c94dfe848..d4a2230c9 100644 --- a/src/main/java/fr/inria/corese/core/kgram/path/Step.java +++ b/src/main/java/fr/inria/corese/core/kgram/path/Step.java @@ -50,42 +50,22 @@ void setEnter(boolean b){ enter = b; } - public boolean isEnter(){ - return enter; - } void setLeave(boolean b){ leave = b; } - public boolean isLeave(){ - return leave; - } void setLoop(boolean b){ loop = b; } - public boolean isLoop(){ - return loop; - } - - void setCheck(boolean b){ - check = b; - } - - public boolean isCheck(){ - return check; - } void setWalk(boolean b){ walk = b; } - public boolean isWalk(){ - return walk; - } void setState(State state){ states.add(state); @@ -97,13 +77,6 @@ public Regex getProperty(){ return prop; } - public Regex getRegex(){ - return prop; - } - - public List getStates(){ - return states; - } public State getState(){ return state; diff --git a/src/main/java/fr/inria/corese/core/kgram/path/Visit.java b/src/main/java/fr/inria/corese/core/kgram/path/Visit.java index b5e8306c8..302c7277e 100644 --- a/src/main/java/fr/inria/corese/core/kgram/path/Visit.java +++ b/src/main/java/fr/inria/corese/core/kgram/path/Visit.java @@ -49,13 +49,6 @@ public class Visit { ltable = new LTable(); } - void setNode(Regex exp, Node n) { - startNode.put(exp, n); - } - - Node getNode(Regex exp) { - return startNode.get(exp); - } // class Table1 extends HashMap { // } @@ -103,9 +96,6 @@ boolean exist(Regex exp) { } - VisitedNode getTable(Regex exp) { - return visitedNode.get(exp); - } class VisitedNode { @@ -114,9 +104,6 @@ class VisitedNode { boolean isReverse = false; int n; - int getIndex() { - return n; - } VisitedNode(boolean b, int n) { this.n = n; @@ -128,9 +115,6 @@ int getIndex() { } } - int size() { - return table.size(); - } void clear() { if (table != null) table.clear(); @@ -145,9 +129,6 @@ public String toString() { return table.toString(); } - Collection values() { - return table.values(); - } void add(Node n) { if (isReverse) { @@ -224,9 +205,6 @@ static Visit create(boolean isReverse, boolean isCount) { return new Visit(isReverse, isCount); } - void clear() { - //table.clear(); - } /** * ************************************ @@ -293,9 +271,6 @@ void nset(Regex exp, VisitedNode t) { } } - VisitedNode cleanVisitedNode(Regex exp) { - return nunset(exp); - } VisitedNode nunset(Regex exp) { VisitedNode t = visitedNode.get(exp); @@ -457,14 +432,6 @@ void start(Node node) { } } - void clearLast() { - if (! regexList.isEmpty()) { - VisitedNode t = getVisitedNode(regexList.get(regexList.size()-1)); - if (t != null) { - t.clear(); - } - } - } /** * New start node: clean the table of visited nodes diff --git a/src/main/java/fr/inria/corese/core/kgram/sorter/core/QPGEdge.java b/src/main/java/fr/inria/corese/core/kgram/sorter/core/QPGEdge.java index a4863ff75..e43990369 100644 --- a/src/main/java/fr/inria/corese/core/kgram/sorter/core/QPGEdge.java +++ b/src/main/java/fr/inria/corese/core/kgram/sorter/core/QPGEdge.java @@ -76,17 +76,6 @@ public QPGNode get(QPGNode n) { return n1.equals(n) ? n2 : n1; } - /** - * Get the two nodes in a list - * - * @return - */ - public List getNodes() { - List l = new ArrayList(); - l.add(n1); - l.add(n2); - return l; - } @Override public String toString() { diff --git a/src/main/java/fr/inria/corese/core/kgram/sorter/core/QPGraph.java b/src/main/java/fr/inria/corese/core/kgram/sorter/core/QPGraph.java index 9f1ffe667..0f8a0ae8d 100644 --- a/src/main/java/fr/inria/corese/core/kgram/sorter/core/QPGraph.java +++ b/src/main/java/fr/inria/corese/core/kgram/sorter/core/QPGraph.java @@ -27,14 +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; @@ -107,13 +99,6 @@ private void createIndex(QPGEdge edge) { } } - /** - * Return all the edges contained in the graph - * - */ - public List getAllEdges() { - return this.edges; - } /** * Return all the edges with certain type contained in the graph @@ -252,12 +237,4 @@ public List getLinkedNodes(QPGNode n, boolean directed, boolean in) { return l; } - /** - * Get the list of vairable bound to constants - * - * @return - */ - public List getBindings() { - return this.bindings; - } } diff --git a/src/main/java/fr/inria/corese/core/kgram/tool/ApproximateSearchEnv.java b/src/main/java/fr/inria/corese/core/kgram/tool/ApproximateSearchEnv.java index 832f006c9..de9347d3b 100644 --- a/src/main/java/fr/inria/corese/core/kgram/tool/ApproximateSearchEnv.java +++ b/src/main/java/fr/inria/corese/core/kgram/tool/ApproximateSearchEnv.java @@ -27,28 +27,6 @@ public ApproximateSearchEnv() { this.all = new HashMap>(); } - public void add(Expr var, Node uri, Node node, String alg, double sim) { - Key key = new Key(var, uri); - - if (all.containsKey(key)) { - Map value = all.get(key); - if (!value.containsKey(node)) { - Value r = new Value(node, alg, sim); - value.put(node, r); - } - } else { - Map m = new HashMap(); - Value r = new Value(node, alg, sim); - m.put(node, r); - all.put(key, m); - } - } - - public Double getSimilarity(Expr var, Node node, String algs) { - Key key = new Key(var); - Value r = this.get(key, node); - return (r != null && r.getAlgorithms().equalsIgnoreCase(algs)) ? r.getSimilarity() : null; - } public Double getSimilarity(Expr var, Node node) { Key key = new Key(var); @@ -80,31 +58,6 @@ public String toString() { return sb.toString(); } - /** - * Aggregate and get value of similarity using all existing variables - * - * @param env - * @return - */ - public Double aggregate(Environment env) { - List lv = this.getVariables(); - return aggregate(env, lv); - } - - /** - * Aggreate with existing variables (excpet for the given variable) - * @param env - * @param var - * @param sim - * @return - */ - public Double aggregate(Environment env, Expr var, double sim) { - List lv = this.getVariables(); - lv.remove(var); - - Double cb = (lv.isEmpty()) ? 1 : aggregate(env, lv); - return cb * sim; - } private Double aggregate(Environment env, List lv) { if (lv.isEmpty()) { @@ -155,9 +108,6 @@ public Expr getVar() { return var; } - public Node getUri() { - return uri; - } @Override public int hashCode() { @@ -200,9 +150,6 @@ public Value(Node node, String algorithms) { this.algorithms = algorithms; } - public Node getNode() { - return node; - } public String getAlgorithms() { return algorithms; @@ -212,9 +159,6 @@ public double getSimilarity() { return similarity; } - public void setSimilarity(double similarity) { - this.similarity = similarity; - } @Override public String toString() { diff --git a/src/main/java/fr/inria/corese/core/kgram/tool/EnvironmentImpl.java b/src/main/java/fr/inria/corese/core/kgram/tool/EnvironmentImpl.java index 7bcccd24e..4a4028d40 100644 --- a/src/main/java/fr/inria/corese/core/kgram/tool/EnvironmentImpl.java +++ b/src/main/java/fr/inria/corese/core/kgram/tool/EnvironmentImpl.java @@ -28,9 +28,6 @@ public EnvironmentImpl(){ query = q; } - public static EnvironmentImpl create(Query q){ - return new EnvironmentImpl(q); - } @Override public int count() { diff --git a/src/main/java/fr/inria/corese/core/kgram/tool/MetaIteratorCast.java b/src/main/java/fr/inria/corese/core/kgram/tool/MetaIteratorCast.java index fddec9159..d77684c5b 100644 --- a/src/main/java/fr/inria/corese/core/kgram/tool/MetaIteratorCast.java +++ b/src/main/java/fr/inria/corese/core/kgram/tool/MetaIteratorCast.java @@ -24,9 +24,6 @@ public MetaIteratorCast(Iterable tt){ first = tt; } - public boolean isEmpty(){ - return first == null; - } public void next(MetaIteratorCast m){ set(m); diff --git a/src/main/java/fr/inria/corese/core/kgram/tool/NodeImpl.java b/src/main/java/fr/inria/corese/core/kgram/tool/NodeImpl.java index e60b10b73..fe75a1761 100644 --- a/src/main/java/fr/inria/corese/core/kgram/tool/NodeImpl.java +++ b/src/main/java/fr/inria/corese/core/kgram/tool/NodeImpl.java @@ -25,29 +25,6 @@ public NodeImpl(Atom at) { atom = at; } - public static NodeImpl createNode(Atom at) { - return new NodeImpl(at); - } - - public static NodeImpl createVariable(String name) { - return new NodeImpl(Variable.create(name)); - } - - public static NodeImpl createResource(String name) { - return new NodeImpl(Constant.create(name)); - } - - public static NodeImpl createConstant(String name) { - return new NodeImpl(Constant.create(name, RDFS.xsdstring)); - } - - public static NodeImpl createConstant(String name, String datatype) { - return new NodeImpl(Constant.create(name, datatype)); - } - - public static NodeImpl createConstant(String name, String datatype, String lang) { - return new NodeImpl(Constant.create(name, null, lang)); - } public Atom getAtom() { return atom;