From 727256081107cdc323d8f0cd5b786db929211956 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Wed, 2 Jun 2021 15:54:50 +0200 Subject: [PATCH 01/11] Allow for DF execution of DFCs. --- .../DynamicFunctionCallExpression.java | 11 ++++ .../DynamicFunctionCallIterator.java | 52 ++++++++++++++----- 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java b/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java index d2aa9cf11e..c9cde94503 100644 --- a/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java +++ b/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java @@ -20,9 +20,11 @@ package org.rumbledb.expressions.postfix; +import org.rumbledb.compiler.VisitorConfig; import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.OurBadException; import org.rumbledb.expressions.AbstractNodeVisitor; +import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.expressions.Expression; import org.rumbledb.expressions.Node; import java.util.ArrayList; @@ -115,4 +117,13 @@ public void serializeToJSONiq(StringBuffer sb, int indent) { } sb.append(")\n"); } + + @Override + public void initHighestExecutionMode(VisitorConfig visitorConfig) { + if (this.arguments.size() == 0) { + this.highestExecutionMode = ExecutionMode.LOCAL; + return; + } + this.highestExecutionMode = this.arguments.get(0).getHighestExecutionMode(visitorConfig); + } } diff --git a/src/main/java/org/rumbledb/runtime/functions/DynamicFunctionCallIterator.java b/src/main/java/org/rumbledb/runtime/functions/DynamicFunctionCallIterator.java index ec07f74a5e..bb1e3f6b93 100644 --- a/src/main/java/org/rumbledb/runtime/functions/DynamicFunctionCallIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/DynamicFunctionCallIterator.java @@ -20,20 +20,23 @@ package org.rumbledb.runtime.functions; +import org.apache.spark.api.java.JavaRDD; import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; import org.rumbledb.context.NamedFunctions; import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.MoreThanOneItemException; +import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.ExecutionMode; -import org.rumbledb.runtime.LocalRuntimeIterator; +import org.rumbledb.items.structured.JSoundDataFrame; +import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import java.util.List; -public class DynamicFunctionCallIterator extends LocalRuntimeIterator { +public class DynamicFunctionCallIterator extends HybridRuntimeIterator { // dynamic: functionIdentifier is not known at compile time // it is known only after evaluating postfix expression at runtime @@ -67,15 +70,20 @@ public DynamicFunctionCallIterator( } @Override - public void open(DynamicContext context) { - super.open(context); - setFunctionItemAndIteratorWithCurrentContext(); + public void openLocal() { + super.open(this.currentDynamicContextForLocalExecution); + setFunctionItemAndIteratorWithCurrentContext(this.currentDynamicContextForLocalExecution); this.functionCallIterator.open(this.currentDynamicContextForLocalExecution); setNextResult(); } @Override - public Item next() { + protected boolean hasNextLocal() { + return this.hasNext; + } + + @Override + public Item nextLocal() { if (this.hasNext) { Item result = this.nextResult; setNextResult(); @@ -103,11 +111,9 @@ public void setNextResult() { } } - private void setFunctionItemAndIteratorWithCurrentContext() { + private void setFunctionItemAndIteratorWithCurrentContext(DynamicContext context) { try { - this.functionItem = this.functionItemIterator.materializeAtMostOneItemOrNull( - this.currentDynamicContextForLocalExecution - ); + this.functionItem = this.functionItemIterator.materializeAtMostOneItemOrNull(context); } catch (MoreThanOneItemException e) { throw new UnexpectedTypeException( "A dynamic function call can not be performed on a sequence of more than one item.", @@ -120,6 +126,14 @@ private void setFunctionItemAndIteratorWithCurrentContext() { getMetadata() ); } + if (!this.functionItem.getBodyIterator().getHighestExecutionMode().equals(this.getHighestExecutionMode())) { + throw new OurBadException( + "Execution mode mismatch in dynamic function call: expression expects " + + this.getHighestExecutionMode() + + " but function item expects " + + this.functionItem.getBodyIterator().getHighestExecutionMode() + ); + } this.functionCallIterator = NamedFunctions.buildUserDefinedFunctionCallIterator( this.functionItem, this.functionItem.getBodyIterator().getHighestExecutionMode(), @@ -129,14 +143,14 @@ private void setFunctionItemAndIteratorWithCurrentContext() { } @Override - public void reset(DynamicContext context) { - super.reset(context); + public void resetLocal() { + super.reset(this.currentDynamicContextForLocalExecution); this.functionCallIterator.reset(this.currentDynamicContextForLocalExecution); setNextResult(); } @Override - public void close() { + public void closeLocal() { // ensure that recursive function calls terminate gracefully // the function call in the body of the deepest recursion call is never visited, never opened and never closed if (this.isOpen) { @@ -144,4 +158,16 @@ public void close() { } super.close(); } + + @Override + public JavaRDD getRDDAux(DynamicContext dynamicContext) { + setFunctionItemAndIteratorWithCurrentContext(dynamicContext); + return this.functionCallIterator.getRDD(dynamicContext); + } + + @Override + public JSoundDataFrame getDataFrame(DynamicContext dynamicContext) { + setFunctionItemAndIteratorWithCurrentContext(dynamicContext); + return this.functionCallIterator.getDataFrame(dynamicContext); + } } From f95a21b9a9fddc10c22946a762195523713264ad Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Wed, 2 Jun 2021 17:18:14 +0200 Subject: [PATCH 02/11] Fix. --- .../rumbledb/compiler/InferTypeVisitor.java | 4 +- .../compiler/RuntimeIteratorVisitor.java | 6 +- .../compiler/StaticContextVisitor.java | 70 ++++++++++++++++--- .../compiler/VariableDependenciesVisitor.java | 4 +- .../java/org/rumbledb/expressions/Node.java | 3 +- .../module/FunctionDeclaration.java | 2 +- .../primary/InlineFunctionExpression.java | 29 +++++--- .../java/org/rumbledb/items/FunctionItem.java | 8 ++- .../functions/FunctionRuntimeIterator.java | 8 +++ .../ml/ApplyEstimatorRuntimeIterator.java | 2 + .../ml/GetEstimatorFunctionIterator.java | 2 + .../ml/GetTransformerFunctionIterator.java | 2 + 12 files changed, 113 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 08c165e191..31e8092420 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -345,7 +345,7 @@ public StaticContext visitInlineFunctionExpr(InlineFunctionExpression expression visitDescendants(expression, argument); SequenceType returnType = expression.getActualReturnType(); if (returnType == null) { - returnType = expression.getBody().getInferredSequenceType(); + returnType = expression.getLocalBody().getInferredSequenceType(); } List params = new ArrayList<>(expression.getParams().values()); FunctionSignature signature = new FunctionSignature(params, returnType); @@ -1945,7 +1945,7 @@ public StaticContext visitFunctionDeclaration(FunctionDeclaration expression, St visitDescendants(expression, argument); InlineFunctionExpression inlineExpression = (InlineFunctionExpression) expression.getExpression(); - SequenceType inferredType = inlineExpression.getBody().getInferredSequenceType(); + SequenceType inferredType = inlineExpression.getLocalBody().getInferredSequenceType(); SequenceType expectedType = inlineExpression.getActualReturnType(); if (expectedType == null) { diff --git a/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java b/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java index 35417fd49d..3a8365bc16 100644 --- a/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java +++ b/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java @@ -497,12 +497,16 @@ public RuntimeIterator visitInlineFunctionExpr(InlineFunctionExpression expressi paramNameToSequenceTypes.put(paramEntry.getKey(), paramEntry.getValue()); } SequenceType returnType = expression.getReturnType(); - RuntimeIterator bodyIterator = this.visit(expression.getBody(), argument); + RuntimeIterator bodyIterator = this.visit(expression.getLocalBody(), argument); + RuntimeIterator bodyRDDIterator = this.visit(expression.getRDDBody(), argument); + RuntimeIterator bodyDFIterator = this.visit(expression.getDFBody(), argument); RuntimeIterator runtimeIterator = new FunctionRuntimeIterator( expression.getName(), paramNameToSequenceTypes, returnType, bodyIterator, + bodyRDDIterator, + bodyDFIterator, expression.getHighestExecutionMode(this.visitorConfig), expression.getMetadata() ); diff --git a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java index 3d95657546..095e6d12f5 100644 --- a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import org.rumbledb.context.BuiltinFunctionCatalogue; import org.rumbledb.context.FunctionIdentifier; @@ -179,7 +180,7 @@ public StaticContext visitFunctionDeclaration(FunctionDeclaration declaration, S expression.setStaticContext(argument); populateFunctionDeclarationStaticContext(functionDeclarationContext, modes, expression); // visit the body first to make its execution mode available while adding the function to the catalog - this.visit(expression.getBody(), functionDeclarationContext); + this.visit(expression.getLocalBody(), functionDeclarationContext); expression.initHighestExecutionMode(this.visitorConfig); declaration.initHighestExecutionMode(this.visitorConfig); expression.registerUserDefinedFunctionExecutionMode( @@ -191,23 +192,70 @@ public StaticContext visitFunctionDeclaration(FunctionDeclaration declaration, S @Override public StaticContext visitInlineFunctionExpr(InlineFunctionExpression expression, StaticContext argument) { // define a static context for the function body, add params to the context and visit the body expression - StaticContext functionDeclarationContext = new StaticContext(argument); - expression.getParams() - .forEach( - (paramName, sequenceType) -> functionDeclarationContext.addVariable( - paramName, - sequenceType, + StaticContext functionDeclarationContextLocal = new StaticContext(argument); + for (Entry entry : expression.getParams().entrySet()) + { + functionDeclarationContextLocal.addVariable( + entry.getKey(), + entry.getValue(), expression.getMetadata(), ExecutionMode.LOCAL - ) - ); + ); + } // visit the body first to make its execution mode available while adding the function to the catalog - this.visit(expression.getBody(), functionDeclarationContext); + this.visit(expression.getLocalBody(), functionDeclarationContextLocal); + + StaticContext functionDeclarationContextRDD = new StaticContext(argument); + boolean first = true; + for (Entry entry : expression.getParams().entrySet()) + { + if(first) + { + functionDeclarationContextRDD.addVariable( + entry.getKey(), + entry.getValue(), + expression.getMetadata(), + ExecutionMode.RDD + ); + first = false; + } else { + functionDeclarationContextRDD.addVariable( + entry.getKey(), + entry.getValue(), + expression.getMetadata(), + ExecutionMode.LOCAL + ); + } + } + StaticContext functionDeclarationContextDF = new StaticContext(argument); + this.visit(expression.getRDDBody(), functionDeclarationContextRDD); + first = true; + for (Entry entry : expression.getParams().entrySet()) + { + if(first) + { + functionDeclarationContextDF.addVariable( + entry.getKey(), + entry.getValue(), + expression.getMetadata(), + ExecutionMode.DATAFRAME + ); + first = false; + } else { + functionDeclarationContextDF.addVariable( + entry.getKey(), + entry.getValue(), + expression.getMetadata(), + ExecutionMode.LOCAL + ); + } + } + this.visit(expression.getDFBody(), functionDeclarationContextDF); expression.initHighestExecutionMode(this.visitorConfig); expression.registerUserDefinedFunctionExecutionMode( this.visitorConfig ); - return functionDeclarationContext; + return argument; } @Override diff --git a/src/main/java/org/rumbledb/compiler/VariableDependenciesVisitor.java b/src/main/java/org/rumbledb/compiler/VariableDependenciesVisitor.java index 5b3cf524b5..bf9378fcc8 100644 --- a/src/main/java/org/rumbledb/compiler/VariableDependenciesVisitor.java +++ b/src/main/java/org/rumbledb/compiler/VariableDependenciesVisitor.java @@ -352,8 +352,8 @@ public Void visitContextExpr(ContextItemExpression expression, Void argument) { @Override public Void visitInlineFunctionExpr(InlineFunctionExpression expression, Void argument) { - visit(expression.getBody(), null); - addInputVariableDependencies(expression, getInputVariableDependencies(expression.getBody())); + visit(expression.getLocalBody(), null); + addInputVariableDependencies(expression, getInputVariableDependencies(expression.getLocalBody())); removeInputVariableDependencies(expression, expression.getParams().keySet()); return null; } diff --git a/src/main/java/org/rumbledb/expressions/Node.java b/src/main/java/org/rumbledb/expressions/Node.java index 4105b8b561..cc5831392f 100644 --- a/src/main/java/org/rumbledb/expressions/Node.java +++ b/src/main/java/org/rumbledb/expressions/Node.java @@ -24,6 +24,7 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.OurBadException; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; @@ -32,7 +33,7 @@ * This is the top-level class for nodes in the intermediate representation of a * JSONiq query. Nodes include expressions, clauses, function declarations, etc. */ -public abstract class Node { +public abstract class Node implements Serializable { private ExceptionMetadata metadata; diff --git a/src/main/java/org/rumbledb/expressions/module/FunctionDeclaration.java b/src/main/java/org/rumbledb/expressions/module/FunctionDeclaration.java index 0eace7ff8d..d861276adc 100644 --- a/src/main/java/org/rumbledb/expressions/module/FunctionDeclaration.java +++ b/src/main/java/org/rumbledb/expressions/module/FunctionDeclaration.java @@ -64,7 +64,7 @@ public T accept(AbstractNodeVisitor visitor, T argument) { @Override public void initHighestExecutionMode(VisitorConfig visitorConfig) { - this.highestExecutionMode = this.functionExpression.getBody().getHighestExecutionMode(visitorConfig); + this.highestExecutionMode = this.functionExpression.getLocalBody().getHighestExecutionMode(visitorConfig); } /** diff --git a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java index e37f19c9dc..9f63e64a2d 100644 --- a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java @@ -21,6 +21,7 @@ package org.rumbledb.expressions.primary; +import org.apache.commons.lang.SerializationUtils; import org.rumbledb.compiler.VisitorConfig; import org.rumbledb.context.FunctionIdentifier; import org.rumbledb.context.Name; @@ -40,7 +41,9 @@ public class InlineFunctionExpression extends Expression { private final FunctionIdentifier functionIdentifier; private final Map params; private final SequenceType returnType; - private final Expression body; + private final Expression bodyLocal; + private final Expression bodyRDD; + private final Expression bodyDF; public InlineFunctionExpression( Name name, @@ -53,7 +56,9 @@ public InlineFunctionExpression( this.name = name; this.params = params; this.returnType = returnType; - this.body = body; + this.bodyLocal = body; + this.bodyRDD = (Expression) SerializationUtils.clone(body); + this.bodyDF = (Expression) SerializationUtils.clone(body); this.functionIdentifier = new FunctionIdentifier(name, params.size()); } @@ -77,13 +82,21 @@ public SequenceType getActualReturnType() { return this.returnType; } - public Expression getBody() { - return this.body; + public Expression getLocalBody() { + return this.bodyLocal; + } + + public Expression getRDDBody() { + return this.bodyRDD; + } + + public Expression getDFBody() { + return this.bodyDF; } @Override public List getChildren() { - return Arrays.asList(this.body); + return Arrays.asList(this.bodyLocal, this.bodyRDD, this.bodyDF); } public void registerUserDefinedFunctionExecutionMode( @@ -95,7 +108,7 @@ public void registerUserDefinedFunctionExecutionMode( getStaticContext().getUserDefinedFunctionsExecutionModes() .setExecutionMode( identifier, - this.body.getHighestExecutionMode(visitorConfig), + this.bodyLocal.getHighestExecutionMode(visitorConfig), visitorConfig.suppressErrorsForFunctionSignatureCollision(), this.getMetadata() ); @@ -128,7 +141,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(" "); } buffer.append("Body:\n"); - this.body.print(buffer, indent + 2); + this.bodyLocal.print(buffer, indent + 2); } @Override @@ -157,7 +170,7 @@ public void serializeToJSONiq(StringBuffer sb, int indent) { sb.append("\n"); indentIt(sb, indent); sb.append("{\n"); - this.body.serializeToJSONiq(sb, indent + 1); + this.bodyLocal.serializeToJSONiq(sb, indent + 1); indentIt(sb, indent); sb.append("}\n"); } diff --git a/src/main/java/org/rumbledb/items/FunctionItem.java b/src/main/java/org/rumbledb/items/FunctionItem.java index 5a219b04c6..ebc8762cda 100644 --- a/src/main/java/org/rumbledb/items/FunctionItem.java +++ b/src/main/java/org/rumbledb/items/FunctionItem.java @@ -59,6 +59,8 @@ public class FunctionItem implements Item { // signature contains type information for all parameters and the return value private FunctionSignature signature; private RuntimeIterator bodyIterator; + private RuntimeIterator bodyRDDIterator; + private RuntimeIterator bodyDFIterator; private DynamicContext dynamicModuleContext; private Map> localVariablesInClosure; private Map> RDDVariablesInClosure; @@ -73,12 +75,16 @@ public FunctionItem( List parameterNames, FunctionSignature signature, DynamicContext dynamicModuleContext, - RuntimeIterator bodyIterator + RuntimeIterator bodyIterator, + RuntimeIterator bodyRDDIterator, + RuntimeIterator bodyDFIterator ) { this.identifier = identifier; this.parameterNames = parameterNames; this.signature = signature; this.bodyIterator = bodyIterator; + this.bodyRDDIterator = bodyRDDIterator; + this.bodyDFIterator = bodyDFIterator; this.dynamicModuleContext = dynamicModuleContext; this.localVariablesInClosure = new HashMap<>(); this.RDDVariablesInClosure = new HashMap<>(); diff --git a/src/main/java/org/rumbledb/runtime/functions/FunctionRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/functions/FunctionRuntimeIterator.java index f57ad0206a..1bbeef9fbc 100644 --- a/src/main/java/org/rumbledb/runtime/functions/FunctionRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/FunctionRuntimeIterator.java @@ -39,12 +39,16 @@ public class FunctionRuntimeIterator extends AtMostOneItemLocalRuntimeIterator { private Map paramNameToSequenceTypes; SequenceType returnType; RuntimeIterator bodyIterator; + RuntimeIterator bodyRDDIterator; + RuntimeIterator bodyDFIterator; public FunctionRuntimeIterator( Name functionName, Map paramNameToSequenceTypes, SequenceType returnType, RuntimeIterator bodyIterator, + RuntimeIterator bodyRDDIterator, + RuntimeIterator bodyDFIterator, ExecutionMode executionMode, ExceptionMetadata iteratorMetadata ) { @@ -53,11 +57,15 @@ public FunctionRuntimeIterator( this.paramNameToSequenceTypes = paramNameToSequenceTypes; this.returnType = returnType; this.bodyIterator = bodyIterator; + this.bodyRDDIterator = bodyRDDIterator; + this.bodyDFIterator = bodyDFIterator; } @Override public Item materializeFirstItemOrNull(DynamicContext dynamicContext) { RuntimeIterator bodyIteratorCopy = ((RuntimeIterator) this.bodyIterator).deepCopy(); + RuntimeIterator bodyRDDIteratorCopy = ((RuntimeIterator) this.bodyRDDIterator).deepCopy(); + RuntimeIterator bodyDFIteratorCopy = ((RuntimeIterator) this.bodyDFIterator).deepCopy(); FunctionItem function = new FunctionItem( this.functionName, this.paramNameToSequenceTypes, diff --git a/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java b/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java index 7df04db024..4beb33eefc 100644 --- a/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java +++ b/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java @@ -266,6 +266,8 @@ private Item generateTransformerFunctionItem(Transformer fittedModel) { returnType ), new DynamicContext(this.currentDynamicContextForLocalExecution.getRumbleRuntimeConfiguration()), + bodyIterator, + bodyIterator, bodyIterator ); } diff --git a/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java b/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java index 011ba47834..a15c113d96 100644 --- a/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java +++ b/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java @@ -143,6 +143,8 @@ public Item next() { returnType ), new DynamicContext(this.currentDynamicContextForLocalExecution.getRumbleRuntimeConfiguration()), + bodyIterator, + bodyIterator, bodyIterator ); diff --git a/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java b/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java index c12ab7b965..c715ec4c9b 100644 --- a/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java +++ b/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java @@ -143,6 +143,8 @@ public Item next() { returnType ), new DynamicContext(this.currentDynamicContextForLocalExecution.getRumbleRuntimeConfiguration()), + bodyIterator, + bodyIterator, bodyIterator ); From 67ecc66793d0b4d669da5e4a1019aac50d9bf69d Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Thu, 3 Jun 2021 11:14:03 +0200 Subject: [PATCH 03/11] Fix. --- .../rumbledb/runtime/functions/FunctionRuntimeIterator.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/runtime/functions/FunctionRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/functions/FunctionRuntimeIterator.java index 1bbeef9fbc..e78e201c67 100644 --- a/src/main/java/org/rumbledb/runtime/functions/FunctionRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/FunctionRuntimeIterator.java @@ -71,7 +71,9 @@ public Item materializeFirstItemOrNull(DynamicContext dynamicContext) { this.paramNameToSequenceTypes, this.returnType, dynamicContext.getModuleContext(), - bodyIteratorCopy + bodyIteratorCopy, + bodyRDDIteratorCopy, + bodyDFIteratorCopy ); function.populateClosureFromDynamicContext(dynamicContext, getMetadata()); return function; From ce7f811163b8a1bb76d08ffe459b22a633e1a8c7 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Thu, 3 Jun 2021 11:19:03 +0200 Subject: [PATCH 04/11] Spotless. --- src/main/java/org/rumbledb/api/Item.java | 18 +++++++++++++ .../compiler/StaticContextVisitor.java | 25 ++++++++----------- .../java/org/rumbledb/items/FunctionItem.java | 18 ++++++++++++- .../functions/FunctionItemCallIterator.java | 2 ++ 4 files changed, 47 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/rumbledb/api/Item.java b/src/main/java/org/rumbledb/api/Item.java index 01d5f3f270..30549eff9a 100644 --- a/src/main/java/org/rumbledb/api/Item.java +++ b/src/main/java/org/rumbledb/api/Item.java @@ -439,6 +439,24 @@ default public RuntimeIterator getBodyIterator() { throw new UnsupportedOperationException("Operation not defined for type " + this.getDynamicType()); } + /** + * Returns the body RDD iterator, if it is a function item. + * + * @return the function signature. + */ + default public RuntimeIterator getBodyRDDIterator() { + throw new UnsupportedOperationException("Operation not defined for type " + this.getDynamicType()); + } + + /** + * Returns the body DF iterator, if it is a function item. + * + * @return the function signature. + */ + default public RuntimeIterator getBodyDFIterator() { + throw new UnsupportedOperationException("Operation not defined for type " + this.getDynamicType()); + } + /** * Returns the local variable bindings, if it is a function item. * diff --git a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java index 095e6d12f5..b95be1d237 100644 --- a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java @@ -193,24 +193,21 @@ public StaticContext visitFunctionDeclaration(FunctionDeclaration declaration, S public StaticContext visitInlineFunctionExpr(InlineFunctionExpression expression, StaticContext argument) { // define a static context for the function body, add params to the context and visit the body expression StaticContext functionDeclarationContextLocal = new StaticContext(argument); - for (Entry entry : expression.getParams().entrySet()) - { + for (Entry entry : expression.getParams().entrySet()) { functionDeclarationContextLocal.addVariable( - entry.getKey(), - entry.getValue(), - expression.getMetadata(), - ExecutionMode.LOCAL - ); + entry.getKey(), + entry.getValue(), + expression.getMetadata(), + ExecutionMode.LOCAL + ); } // visit the body first to make its execution mode available while adding the function to the catalog this.visit(expression.getLocalBody(), functionDeclarationContextLocal); StaticContext functionDeclarationContextRDD = new StaticContext(argument); boolean first = true; - for (Entry entry : expression.getParams().entrySet()) - { - if(first) - { + for (Entry entry : expression.getParams().entrySet()) { + if (first) { functionDeclarationContextRDD.addVariable( entry.getKey(), entry.getValue(), @@ -230,10 +227,8 @@ public StaticContext visitInlineFunctionExpr(InlineFunctionExpression expression StaticContext functionDeclarationContextDF = new StaticContext(argument); this.visit(expression.getRDDBody(), functionDeclarationContextRDD); first = true; - for (Entry entry : expression.getParams().entrySet()) - { - if(first) - { + for (Entry entry : expression.getParams().entrySet()) { + if (first) { functionDeclarationContextDF.addVariable( entry.getKey(), entry.getValue(), diff --git a/src/main/java/org/rumbledb/items/FunctionItem.java b/src/main/java/org/rumbledb/items/FunctionItem.java index ebc8762cda..90618c2829 100644 --- a/src/main/java/org/rumbledb/items/FunctionItem.java +++ b/src/main/java/org/rumbledb/items/FunctionItem.java @@ -97,6 +97,8 @@ public FunctionItem( FunctionSignature signature, DynamicContext dynamicModuleContext, RuntimeIterator bodyIterator, + RuntimeIterator bodyRDDIterator, + RuntimeIterator bodyDFIterator, Map> localVariablesInClosure, Map> RDDVariablesInClosure, Map DFVariablesInClosure @@ -105,6 +107,8 @@ public FunctionItem( this.parameterNames = parameterNames; this.signature = signature; this.bodyIterator = bodyIterator; + this.bodyRDDIterator = bodyRDDIterator; + this.bodyDFIterator = bodyDFIterator; this.dynamicModuleContext = dynamicModuleContext; this.localVariablesInClosure = localVariablesInClosure; this.RDDVariablesInClosure = RDDVariablesInClosure; @@ -116,7 +120,9 @@ public FunctionItem( Map paramNameToSequenceTypes, SequenceType returnType, DynamicContext dynamicModuleContext, - RuntimeIterator bodyIterator + RuntimeIterator bodyIterator, + RuntimeIterator bodyRDDIterator, + RuntimeIterator bodyDFIterator ) { List paramNames = new ArrayList<>(); List parameters = new ArrayList<>(); @@ -129,6 +135,8 @@ public FunctionItem( this.parameterNames = paramNames; this.signature = new FunctionSignature(parameters, returnType); this.bodyIterator = bodyIterator; + this.bodyRDDIterator = bodyRDDIterator; + this.bodyDFIterator = bodyDFIterator; this.dynamicModuleContext = dynamicModuleContext; this.localVariablesInClosure = new HashMap<>(); this.RDDVariablesInClosure = new HashMap<>(); @@ -158,6 +166,14 @@ public RuntimeIterator getBodyIterator() { return this.bodyIterator; } + public RuntimeIterator getBodyRDDIterator() { + return this.bodyRDDIterator; + } + + public RuntimeIterator getDFBodyIterator() { + return this.bodyDFIterator; + } + public Map> getLocalVariablesInClosure() { return this.localVariablesInClosure; } diff --git a/src/main/java/org/rumbledb/runtime/functions/FunctionItemCallIterator.java b/src/main/java/org/rumbledb/runtime/functions/FunctionItemCallIterator.java index 88241894dd..c431da32fa 100644 --- a/src/main/java/org/rumbledb/runtime/functions/FunctionItemCallIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/FunctionItemCallIterator.java @@ -233,6 +233,8 @@ private RuntimeIterator generatePartiallyAppliedFunction(DynamicContext context) ), this.functionItem.getModuleDynamicContext(), this.functionItem.getBodyIterator(), + this.functionItem.getBodyRDDIterator(), + this.functionItem.getBodyDFIterator(), localArgumentValues, RDDArgumentValues, DFArgumentValues From e4d85338ce89e26c104327f74ff7dda64840848d Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Thu, 3 Jun 2021 11:40:43 +0200 Subject: [PATCH 05/11] Fix. --- src/main/java/org/rumbledb/api/Item.java | 13 +----- .../rumbledb/compiler/InferTypeVisitor.java | 4 +- .../compiler/RuntimeIteratorVisitor.java | 12 ++--- .../compiler/StaticContextVisitor.java | 28 ++--------- .../compiler/VariableDependenciesVisitor.java | 6 ++- .../module/FunctionDeclaration.java | 2 +- .../primary/InlineFunctionExpression.java | 39 ++++++++-------- .../java/org/rumbledb/items/FunctionItem.java | 46 ++++++------------- .../functions/FunctionItemCallIterator.java | 4 +- .../functions/FunctionRuntimeIterator.java | 24 ++++------ .../ml/ApplyEstimatorRuntimeIterator.java | 29 ++++++++---- .../ml/GetEstimatorFunctionIterator.java | 29 ++++++++---- .../ml/GetTransformerFunctionIterator.java | 29 ++++++++---- 13 files changed, 125 insertions(+), 140 deletions(-) diff --git a/src/main/java/org/rumbledb/api/Item.java b/src/main/java/org/rumbledb/api/Item.java index 30549eff9a..c1e790e7be 100644 --- a/src/main/java/org/rumbledb/api/Item.java +++ b/src/main/java/org/rumbledb/api/Item.java @@ -440,20 +440,11 @@ default public RuntimeIterator getBodyIterator() { } /** - * Returns the body RDD iterator, if it is a function item. - * - * @return the function signature. - */ - default public RuntimeIterator getBodyRDDIterator() { - throw new UnsupportedOperationException("Operation not defined for type " + this.getDynamicType()); - } - - /** - * Returns the body DF iterator, if it is a function item. + * Returns the body iterator, if it is a function item. * * @return the function signature. */ - default public RuntimeIterator getBodyDFIterator() { + default public Map getBodyIterators() { throw new UnsupportedOperationException("Operation not defined for type " + this.getDynamicType()); } diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 31e8092420..08c165e191 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -345,7 +345,7 @@ public StaticContext visitInlineFunctionExpr(InlineFunctionExpression expression visitDescendants(expression, argument); SequenceType returnType = expression.getActualReturnType(); if (returnType == null) { - returnType = expression.getLocalBody().getInferredSequenceType(); + returnType = expression.getBody().getInferredSequenceType(); } List params = new ArrayList<>(expression.getParams().values()); FunctionSignature signature = new FunctionSignature(params, returnType); @@ -1945,7 +1945,7 @@ public StaticContext visitFunctionDeclaration(FunctionDeclaration expression, St visitDescendants(expression, argument); InlineFunctionExpression inlineExpression = (InlineFunctionExpression) expression.getExpression(); - SequenceType inferredType = inlineExpression.getLocalBody().getInferredSequenceType(); + SequenceType inferredType = inlineExpression.getBody().getInferredSequenceType(); SequenceType expectedType = inlineExpression.getActualReturnType(); if (expectedType == null) { diff --git a/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java b/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java index 3a8365bc16..876d9f6c2f 100644 --- a/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java +++ b/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java @@ -142,6 +142,7 @@ import org.rumbledb.types.SequenceType; import java.util.ArrayList; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -497,16 +498,15 @@ public RuntimeIterator visitInlineFunctionExpr(InlineFunctionExpression expressi paramNameToSequenceTypes.put(paramEntry.getKey(), paramEntry.getValue()); } SequenceType returnType = expression.getReturnType(); - RuntimeIterator bodyIterator = this.visit(expression.getLocalBody(), argument); - RuntimeIterator bodyRDDIterator = this.visit(expression.getRDDBody(), argument); - RuntimeIterator bodyDFIterator = this.visit(expression.getDFBody(), argument); + Map bodyIterators = new HashMap<>(); + for (long l : expression.getBodies().keySet()) { + bodyIterators.put(l, this.visit(expression.getBodies().get(l), argument)); + } RuntimeIterator runtimeIterator = new FunctionRuntimeIterator( expression.getName(), paramNameToSequenceTypes, returnType, - bodyIterator, - bodyRDDIterator, - bodyDFIterator, + bodyIterators, expression.getHighestExecutionMode(this.visitorConfig), expression.getMetadata() ); diff --git a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java index b95be1d237..17a47517ce 100644 --- a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java @@ -180,7 +180,7 @@ public StaticContext visitFunctionDeclaration(FunctionDeclaration declaration, S expression.setStaticContext(argument); populateFunctionDeclarationStaticContext(functionDeclarationContext, modes, expression); // visit the body first to make its execution mode available while adding the function to the catalog - this.visit(expression.getLocalBody(), functionDeclarationContext); + this.visit(expression.getBody(), functionDeclarationContext); expression.initHighestExecutionMode(this.visitorConfig); declaration.initHighestExecutionMode(this.visitorConfig); expression.registerUserDefinedFunctionExecutionMode( @@ -202,7 +202,7 @@ public StaticContext visitInlineFunctionExpr(InlineFunctionExpression expression ); } // visit the body first to make its execution mode available while adding the function to the catalog - this.visit(expression.getLocalBody(), functionDeclarationContextLocal); + this.visit(expression.getBodies().get(0), functionDeclarationContextLocal); StaticContext functionDeclarationContextRDD = new StaticContext(argument); boolean first = true; @@ -212,7 +212,7 @@ public StaticContext visitInlineFunctionExpr(InlineFunctionExpression expression entry.getKey(), entry.getValue(), expression.getMetadata(), - ExecutionMode.RDD + ExecutionMode.DATAFRAME ); first = false; } else { @@ -225,27 +225,7 @@ public StaticContext visitInlineFunctionExpr(InlineFunctionExpression expression } } StaticContext functionDeclarationContextDF = new StaticContext(argument); - this.visit(expression.getRDDBody(), functionDeclarationContextRDD); - first = true; - for (Entry entry : expression.getParams().entrySet()) { - if (first) { - functionDeclarationContextDF.addVariable( - entry.getKey(), - entry.getValue(), - expression.getMetadata(), - ExecutionMode.DATAFRAME - ); - first = false; - } else { - functionDeclarationContextDF.addVariable( - entry.getKey(), - entry.getValue(), - expression.getMetadata(), - ExecutionMode.LOCAL - ); - } - } - this.visit(expression.getDFBody(), functionDeclarationContextDF); + this.visit(expression.getBodies().get(1L), functionDeclarationContextDF); expression.initHighestExecutionMode(this.visitorConfig); expression.registerUserDefinedFunctionExecutionMode( this.visitorConfig diff --git a/src/main/java/org/rumbledb/compiler/VariableDependenciesVisitor.java b/src/main/java/org/rumbledb/compiler/VariableDependenciesVisitor.java index bf9378fcc8..e0dd59a8d7 100644 --- a/src/main/java/org/rumbledb/compiler/VariableDependenciesVisitor.java +++ b/src/main/java/org/rumbledb/compiler/VariableDependenciesVisitor.java @@ -352,8 +352,10 @@ public Void visitContextExpr(ContextItemExpression expression, Void argument) { @Override public Void visitInlineFunctionExpr(InlineFunctionExpression expression, Void argument) { - visit(expression.getLocalBody(), null); - addInputVariableDependencies(expression, getInputVariableDependencies(expression.getLocalBody())); + for (long l : expression.getBodies().keySet()) { + visit(expression.getBodies().get(l), null); + } + addInputVariableDependencies(expression, getInputVariableDependencies(expression.getBody())); removeInputVariableDependencies(expression, expression.getParams().keySet()); return null; } diff --git a/src/main/java/org/rumbledb/expressions/module/FunctionDeclaration.java b/src/main/java/org/rumbledb/expressions/module/FunctionDeclaration.java index d861276adc..0eace7ff8d 100644 --- a/src/main/java/org/rumbledb/expressions/module/FunctionDeclaration.java +++ b/src/main/java/org/rumbledb/expressions/module/FunctionDeclaration.java @@ -64,7 +64,7 @@ public T accept(AbstractNodeVisitor visitor, T argument) { @Override public void initHighestExecutionMode(VisitorConfig visitorConfig) { - this.highestExecutionMode = this.functionExpression.getLocalBody().getHighestExecutionMode(visitorConfig); + this.highestExecutionMode = this.functionExpression.getBody().getHighestExecutionMode(visitorConfig); } /** diff --git a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java index 9f63e64a2d..6ab540108e 100644 --- a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java @@ -31,7 +31,8 @@ import org.rumbledb.expressions.Node; import org.rumbledb.types.SequenceType; -import java.util.Arrays; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -41,9 +42,7 @@ public class InlineFunctionExpression extends Expression { private final FunctionIdentifier functionIdentifier; private final Map params; private final SequenceType returnType; - private final Expression bodyLocal; - private final Expression bodyRDD; - private final Expression bodyDF; + private final Map bodies; public InlineFunctionExpression( Name name, @@ -56,9 +55,9 @@ public InlineFunctionExpression( this.name = name; this.params = params; this.returnType = returnType; - this.bodyLocal = body; - this.bodyRDD = (Expression) SerializationUtils.clone(body); - this.bodyDF = (Expression) SerializationUtils.clone(body); + this.bodies = new HashMap<>(); + this.bodies.put(0L, body); + this.bodies.put(1L, (Expression) SerializationUtils.clone(body)); this.functionIdentifier = new FunctionIdentifier(name, params.size()); } @@ -82,21 +81,13 @@ public SequenceType getActualReturnType() { return this.returnType; } - public Expression getLocalBody() { - return this.bodyLocal; - } - - public Expression getRDDBody() { - return this.bodyRDD; - } - - public Expression getDFBody() { - return this.bodyDF; + public Expression getBody() { + return this.bodies.get(0L); } @Override public List getChildren() { - return Arrays.asList(this.bodyLocal, this.bodyRDD, this.bodyDF); + return new ArrayList<>(bodies.values()); } public void registerUserDefinedFunctionExecutionMode( @@ -108,7 +99,7 @@ public void registerUserDefinedFunctionExecutionMode( getStaticContext().getUserDefinedFunctionsExecutionModes() .setExecutionMode( identifier, - this.bodyLocal.getHighestExecutionMode(visitorConfig), + this.bodies.get(0).getHighestExecutionMode(visitorConfig), visitorConfig.suppressErrorsForFunctionSignatureCollision(), this.getMetadata() ); @@ -140,8 +131,10 @@ public void print(StringBuffer buffer, int indent) { for (int i = 0; i < indent + 2; ++i) { buffer.append(" "); } + for (long l : this.bodies.keySet()) { + this.bodies.get(l).print(buffer, indent + 2); + } buffer.append("Body:\n"); - this.bodyLocal.print(buffer, indent + 2); } @Override @@ -170,10 +163,14 @@ public void serializeToJSONiq(StringBuffer sb, int indent) { sb.append("\n"); indentIt(sb, indent); sb.append("{\n"); - this.bodyLocal.serializeToJSONiq(sb, indent + 1); + this.bodies.get(0).serializeToJSONiq(sb, indent + 1); indentIt(sb, indent); sb.append("}\n"); } } + + public Map getBodies() { + return this.bodies; + } } diff --git a/src/main/java/org/rumbledb/items/FunctionItem.java b/src/main/java/org/rumbledb/items/FunctionItem.java index 90618c2829..140ebd173e 100644 --- a/src/main/java/org/rumbledb/items/FunctionItem.java +++ b/src/main/java/org/rumbledb/items/FunctionItem.java @@ -58,9 +58,7 @@ public class FunctionItem implements Item { // signature contains type information for all parameters and the return value private FunctionSignature signature; - private RuntimeIterator bodyIterator; - private RuntimeIterator bodyRDDIterator; - private RuntimeIterator bodyDFIterator; + private Map bodyIterators; private DynamicContext dynamicModuleContext; private Map> localVariablesInClosure; private Map> RDDVariablesInClosure; @@ -75,16 +73,12 @@ public FunctionItem( List parameterNames, FunctionSignature signature, DynamicContext dynamicModuleContext, - RuntimeIterator bodyIterator, - RuntimeIterator bodyRDDIterator, - RuntimeIterator bodyDFIterator + Map bodyIterators ) { this.identifier = identifier; this.parameterNames = parameterNames; this.signature = signature; - this.bodyIterator = bodyIterator; - this.bodyRDDIterator = bodyRDDIterator; - this.bodyDFIterator = bodyDFIterator; + this.bodyIterators = bodyIterators; this.dynamicModuleContext = dynamicModuleContext; this.localVariablesInClosure = new HashMap<>(); this.RDDVariablesInClosure = new HashMap<>(); @@ -96,9 +90,7 @@ public FunctionItem( List parameterNames, FunctionSignature signature, DynamicContext dynamicModuleContext, - RuntimeIterator bodyIterator, - RuntimeIterator bodyRDDIterator, - RuntimeIterator bodyDFIterator, + Map bodyIterators, Map> localVariablesInClosure, Map> RDDVariablesInClosure, Map DFVariablesInClosure @@ -106,9 +98,7 @@ public FunctionItem( this.identifier = identifier; this.parameterNames = parameterNames; this.signature = signature; - this.bodyIterator = bodyIterator; - this.bodyRDDIterator = bodyRDDIterator; - this.bodyDFIterator = bodyDFIterator; + this.bodyIterators = bodyIterators; this.dynamicModuleContext = dynamicModuleContext; this.localVariablesInClosure = localVariablesInClosure; this.RDDVariablesInClosure = RDDVariablesInClosure; @@ -120,9 +110,7 @@ public FunctionItem( Map paramNameToSequenceTypes, SequenceType returnType, DynamicContext dynamicModuleContext, - RuntimeIterator bodyIterator, - RuntimeIterator bodyRDDIterator, - RuntimeIterator bodyDFIterator + Map bodyIterators ) { List paramNames = new ArrayList<>(); List parameters = new ArrayList<>(); @@ -134,9 +122,7 @@ public FunctionItem( this.identifier = new FunctionIdentifier(name, paramNames.size()); this.parameterNames = paramNames; this.signature = new FunctionSignature(parameters, returnType); - this.bodyIterator = bodyIterator; - this.bodyRDDIterator = bodyRDDIterator; - this.bodyDFIterator = bodyDFIterator; + this.bodyIterators = bodyIterators; this.dynamicModuleContext = dynamicModuleContext; this.localVariablesInClosure = new HashMap<>(); this.RDDVariablesInClosure = new HashMap<>(); @@ -163,15 +149,11 @@ public DynamicContext getModuleDynamicContext() { } public RuntimeIterator getBodyIterator() { - return this.bodyIterator; + return this.bodyIterators.get(0); } - public RuntimeIterator getBodyRDDIterator() { - return this.bodyRDDIterator; - } - - public RuntimeIterator getDFBodyIterator() { - return this.bodyDFIterator; + public Map getBodyIterators() { + return this.bodyIterators; } public Map> getLocalVariablesInClosure() { @@ -222,7 +204,9 @@ public String toString() { sb.append(param + " "); } sb.append("Signature: " + this.signature + "\n"); - sb.append("Body:\n" + this.bodyIterator + "\n"); + for (long l : this.bodyIterators.keySet()) { + sb.append("Body " + l + ":\n" + this.bodyIterators.get(l) + "\n"); + } sb.append("Closure:\n"); sb.append(" Local:\n"); for (Name name : this.localVariablesInClosure.keySet()) { @@ -265,7 +249,7 @@ public void write(Kryo kryo, Output output) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); - oos.writeObject(this.bodyIterator); + oos.writeObject(this.bodyIterators); oos.flush(); byte[] data = bos.toByteArray(); output.writeInt(data.length); @@ -296,7 +280,7 @@ public void read(Kryo kryo, Input input) { byte[] data = input.readBytes(dataLength); ByteArrayInputStream bis = new ByteArrayInputStream(data); ObjectInputStream ois = new ObjectInputStream(bis); - this.bodyIterator = (RuntimeIterator) ois.readObject(); + this.bodyIterators = (Map) ois.readObject(); } catch (Exception e) { throw new OurBadException( "Error converting functionItem-bodyRuntimeIterator to functionItem:" + e.getMessage() diff --git a/src/main/java/org/rumbledb/runtime/functions/FunctionItemCallIterator.java b/src/main/java/org/rumbledb/runtime/functions/FunctionItemCallIterator.java index c431da32fa..92d348079d 100644 --- a/src/main/java/org/rumbledb/runtime/functions/FunctionItemCallIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/FunctionItemCallIterator.java @@ -232,9 +232,7 @@ private RuntimeIterator generatePartiallyAppliedFunction(DynamicContext context) this.functionItem.getSignature().getReturnType() ), this.functionItem.getModuleDynamicContext(), - this.functionItem.getBodyIterator(), - this.functionItem.getBodyRDDIterator(), - this.functionItem.getBodyDFIterator(), + this.functionItem.getBodyIterators(), localArgumentValues, RDDArgumentValues, DFArgumentValues diff --git a/src/main/java/org/rumbledb/runtime/functions/FunctionRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/functions/FunctionRuntimeIterator.java index e78e201c67..6d5c60fcdc 100644 --- a/src/main/java/org/rumbledb/runtime/functions/FunctionRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/FunctionRuntimeIterator.java @@ -20,6 +20,7 @@ package org.rumbledb.runtime.functions; +import java.util.HashMap; import java.util.Map; import org.rumbledb.api.Item; @@ -38,17 +39,13 @@ public class FunctionRuntimeIterator extends AtMostOneItemLocalRuntimeIterator { private Name functionName; private Map paramNameToSequenceTypes; SequenceType returnType; - RuntimeIterator bodyIterator; - RuntimeIterator bodyRDDIterator; - RuntimeIterator bodyDFIterator; + Map bodyIterators; public FunctionRuntimeIterator( Name functionName, Map paramNameToSequenceTypes, SequenceType returnType, - RuntimeIterator bodyIterator, - RuntimeIterator bodyRDDIterator, - RuntimeIterator bodyDFIterator, + Map bodyIterators, ExecutionMode executionMode, ExceptionMetadata iteratorMetadata ) { @@ -56,24 +53,21 @@ public FunctionRuntimeIterator( this.functionName = functionName; this.paramNameToSequenceTypes = paramNameToSequenceTypes; this.returnType = returnType; - this.bodyIterator = bodyIterator; - this.bodyRDDIterator = bodyRDDIterator; - this.bodyDFIterator = bodyDFIterator; + this.bodyIterators = bodyIterators; } @Override public Item materializeFirstItemOrNull(DynamicContext dynamicContext) { - RuntimeIterator bodyIteratorCopy = ((RuntimeIterator) this.bodyIterator).deepCopy(); - RuntimeIterator bodyRDDIteratorCopy = ((RuntimeIterator) this.bodyRDDIterator).deepCopy(); - RuntimeIterator bodyDFIteratorCopy = ((RuntimeIterator) this.bodyDFIterator).deepCopy(); + Map bodyIteratorsCopy = new HashMap<>(); + for (long l : this.bodyIterators.keySet()) { + bodyIteratorsCopy.put(l, (RuntimeIterator) this.bodyIterators.get(l).deepCopy()); + } FunctionItem function = new FunctionItem( this.functionName, this.paramNameToSequenceTypes, this.returnType, dynamicContext.getModuleContext(), - bodyIteratorCopy, - bodyRDDIteratorCopy, - bodyDFIteratorCopy + bodyIteratorsCopy ); function.populateClosureFromDynamicContext(dynamicContext, getMetadata()); return function; diff --git a/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java b/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java index 4beb33eefc..91b37fc8cd 100644 --- a/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java +++ b/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java @@ -27,7 +27,9 @@ import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.NoSuchElementException; import static sparksoniq.spark.ml.RumbleMLUtils.convertRumbleObjectItemToSparkMLParamMap; @@ -232,11 +234,24 @@ private void setSparkMLEstimatorParamToValue(String paramName, String value) { } private Item generateTransformerFunctionItem(Transformer fittedModel) { - RuntimeIterator bodyIterator = new ApplyTransformerRuntimeIterator( - RumbleMLCatalog.getRumbleMLShortName(fittedModel.getClass().getName()), - fittedModel, - ExecutionMode.DATAFRAME, - getMetadata() + Map bodyIterators = new HashMap<>(); + bodyIterators.put( + 0L, + new ApplyTransformerRuntimeIterator( + RumbleMLCatalog.getRumbleMLShortName(fittedModel.getClass().getName()), + fittedModel, + ExecutionMode.LOCAL, + getMetadata() + ) + ); + bodyIterators.put( + 1L, + new ApplyTransformerRuntimeIterator( + RumbleMLCatalog.getRumbleMLShortName(fittedModel.getClass().getName()), + fittedModel, + ExecutionMode.DATAFRAME, + getMetadata() + ) ); List paramTypes = Collections.unmodifiableList( Arrays.asList( @@ -266,9 +281,7 @@ private Item generateTransformerFunctionItem(Transformer fittedModel) { returnType ), new DynamicContext(this.currentDynamicContextForLocalExecution.getRumbleRuntimeConfiguration()), - bodyIterator, - bodyIterator, - bodyIterator + bodyIterators ); } } diff --git a/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java b/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java index a15c113d96..33c25dc2aa 100644 --- a/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java +++ b/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java @@ -40,7 +40,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class GetEstimatorFunctionIterator extends LocalFunctionCallIterator { @@ -107,11 +109,24 @@ public Item next() { this.hasNext = false; try { Estimator estimator = (Estimator) this.estimatorSparkMLClass.newInstance(); - RuntimeIterator bodyIterator = new ApplyEstimatorRuntimeIterator( - this.estimatorShortName, - estimator, - ExecutionMode.LOCAL, - getMetadata() + Map bodyIterators = new HashMap<>(); + bodyIterators.put( + 0L, + new ApplyEstimatorRuntimeIterator( + this.estimatorShortName, + estimator, + ExecutionMode.LOCAL, + getMetadata() + ) + ); + bodyIterators.put( + 1L, + new ApplyEstimatorRuntimeIterator( + this.estimatorShortName, + estimator, + ExecutionMode.DATAFRAME, + getMetadata() + ) ); List paramTypes = Collections.unmodifiableList( Arrays.asList( @@ -143,9 +158,7 @@ public Item next() { returnType ), new DynamicContext(this.currentDynamicContextForLocalExecution.getRumbleRuntimeConfiguration()), - bodyIterator, - bodyIterator, - bodyIterator + bodyIterators ); } catch (InstantiationException | IllegalAccessException e) { diff --git a/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java b/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java index c715ec4c9b..7adb46f784 100644 --- a/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java +++ b/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java @@ -40,7 +40,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class GetTransformerFunctionIterator extends LocalFunctionCallIterator { @@ -107,11 +109,24 @@ public Item next() { this.hasNext = false; try { Transformer transformer = (Transformer) this.transformerSparkMLClass.newInstance(); - RuntimeIterator bodyIterator = new ApplyTransformerRuntimeIterator( - this.transformerShortName, - transformer, - ExecutionMode.DATAFRAME, - getMetadata() + Map bodyIterators = new HashMap<>(); + bodyIterators.put( + 0L, + new ApplyTransformerRuntimeIterator( + this.transformerShortName, + transformer, + ExecutionMode.LOCAL, + getMetadata() + ) + ); + bodyIterators.put( + 1L, + new ApplyTransformerRuntimeIterator( + this.transformerShortName, + transformer, + ExecutionMode.DATAFRAME, + getMetadata() + ) ); List paramTypes = Collections.unmodifiableList( Arrays.asList( @@ -143,9 +158,7 @@ public Item next() { returnType ), new DynamicContext(this.currentDynamicContextForLocalExecution.getRumbleRuntimeConfiguration()), - bodyIterator, - bodyIterator, - bodyIterator + bodyIterators ); } catch (InstantiationException | IllegalAccessException e) { From 5bb9b0edd527de38a7cf56ad3f5978710a05f5d2 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Thu, 3 Jun 2021 11:45:54 +0200 Subject: [PATCH 06/11] Fix tests. --- src/main/java/org/rumbledb/compiler/TranslationVisitor.java | 4 ++-- .../java/org/rumbledb/compiler/XQueryTranslationVisitor.java | 4 ++-- src/main/java/org/rumbledb/expressions/CommaExpression.java | 2 ++ .../rumbledb/expressions/arithmetic/AdditiveExpression.java | 2 ++ .../expressions/comparison/ComparisonExpression.java | 2 ++ src/main/java/org/rumbledb/expressions/flowr/Clause.java | 2 ++ .../java/org/rumbledb/expressions/logic/AndExpression.java | 2 ++ .../rumbledb/expressions/postfix/ArrayLookupExpression.java | 2 ++ .../expressions/postfix/ArrayUnboxingExpression.java | 2 ++ .../expressions/primary/ArrayConstructorExpression.java | 2 ++ .../expressions/primary/BooleanLiteralExpression.java | 2 ++ .../expressions/primary/InlineFunctionExpression.java | 5 +++-- .../java/org/rumbledb/expressions/typing/CastExpression.java | 2 ++ .../org/rumbledb/expressions/typing/CastableExpression.java | 2 ++ 14 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index f39e9e2ed7..b7037fbcd6 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -396,7 +396,7 @@ public Name parseName(JsoniqParser.QnameContext ctx, boolean isFunction, boolean @Override public Node visitFunctionDecl(JsoniqParser.FunctionDeclContext ctx) { Name name = parseName(ctx.qname(), true, false); - Map fnParams = new LinkedHashMap<>(); + LinkedHashMap fnParams = new LinkedHashMap<>(); SequenceType fnReturnType = null; Name paramName; SequenceType paramType; @@ -1371,7 +1371,7 @@ public Node visitNamedFunctionRef(JsoniqParser.NamedFunctionRefContext ctx) { @Override public Node visitInlineFunctionExpr(JsoniqParser.InlineFunctionExprContext ctx) { - Map fnParams = new LinkedHashMap<>(); + LinkedHashMap fnParams = new LinkedHashMap<>(); SequenceType fnReturnType = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; Name paramName; SequenceType paramType; diff --git a/src/main/java/org/rumbledb/compiler/XQueryTranslationVisitor.java b/src/main/java/org/rumbledb/compiler/XQueryTranslationVisitor.java index 37b20ce65d..c76066b4c4 100644 --- a/src/main/java/org/rumbledb/compiler/XQueryTranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/XQueryTranslationVisitor.java @@ -371,7 +371,7 @@ private void processAnnotations(XQueryParser.AnnotationsContext annotations) { @Override public Node visitFunctionDecl(XQueryParser.FunctionDeclContext ctx) { Name name = parseName(ctx.eqName(), true, false); - Map fnParams = new LinkedHashMap<>(); + LinkedHashMap fnParams = new LinkedHashMap<>(); SequenceType fnReturnType = MOST_GENERAL_SEQUENCE_TYPE; Name paramName; SequenceType paramType; @@ -1279,7 +1279,7 @@ public Node visitNamedFunctionRef(XQueryParser.NamedFunctionRefContext ctx) { @Override public Node visitInlineFunctionRef(XQueryParser.InlineFunctionRefContext ctx) { - Map fnParams = new LinkedHashMap<>(); + LinkedHashMap fnParams = new LinkedHashMap<>(); SequenceType fnReturnType = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; Name paramName; SequenceType paramType; diff --git a/src/main/java/org/rumbledb/expressions/CommaExpression.java b/src/main/java/org/rumbledb/expressions/CommaExpression.java index 8bebe5e981..8143244050 100644 --- a/src/main/java/org/rumbledb/expressions/CommaExpression.java +++ b/src/main/java/org/rumbledb/expressions/CommaExpression.java @@ -29,6 +29,8 @@ public class CommaExpression extends Expression { + private static final long serialVersionUID = 1L; + private final List expressions; public CommaExpression(List expressions, ExceptionMetadata metadata) { diff --git a/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java b/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java index c99b7c2f85..babb758e19 100644 --- a/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java +++ b/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java @@ -30,6 +30,8 @@ import java.util.List; public class AdditiveExpression extends Expression { + private static final long serialVersionUID = 1L; + private Expression leftExpression; private Expression rightExpression; private boolean isMinus; diff --git a/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java b/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java index 4525c5d4a0..b507ba8c2e 100644 --- a/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java +++ b/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java @@ -31,6 +31,8 @@ public class ComparisonExpression extends Expression { + private static final long serialVersionUID = 1L; + public static enum ComparisonOperator { VC_EQ("eq"), VC_NE("ne"), diff --git a/src/main/java/org/rumbledb/expressions/flowr/Clause.java b/src/main/java/org/rumbledb/expressions/flowr/Clause.java index 6a35d1d897..12014636eb 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/Clause.java +++ b/src/main/java/org/rumbledb/expressions/flowr/Clause.java @@ -34,6 +34,8 @@ public abstract class Clause extends Node { /* Clauses are organized in doubly-linked lists */ + private static final long serialVersionUID = 1L; + protected Clause previousClause; protected Clause nextClause; protected FLWOR_CLAUSES clauseType; diff --git a/src/main/java/org/rumbledb/expressions/logic/AndExpression.java b/src/main/java/org/rumbledb/expressions/logic/AndExpression.java index 82e8759ea9..74999d6960 100644 --- a/src/main/java/org/rumbledb/expressions/logic/AndExpression.java +++ b/src/main/java/org/rumbledb/expressions/logic/AndExpression.java @@ -29,6 +29,8 @@ import java.util.List; public class AndExpression extends Expression { + private static final long serialVersionUID = 1L; + private Expression leftExpression; private Expression rightExpression; diff --git a/src/main/java/org/rumbledb/expressions/postfix/ArrayLookupExpression.java b/src/main/java/org/rumbledb/expressions/postfix/ArrayLookupExpression.java index 64257cbf2d..9cf5a2e1fd 100644 --- a/src/main/java/org/rumbledb/expressions/postfix/ArrayLookupExpression.java +++ b/src/main/java/org/rumbledb/expressions/postfix/ArrayLookupExpression.java @@ -33,6 +33,8 @@ public class ArrayLookupExpression extends Expression { + private static final long serialVersionUID = 1L; + private Expression mainExpression; private Expression lookupExpression; diff --git a/src/main/java/org/rumbledb/expressions/postfix/ArrayUnboxingExpression.java b/src/main/java/org/rumbledb/expressions/postfix/ArrayUnboxingExpression.java index 1997befd7e..f71b499c82 100644 --- a/src/main/java/org/rumbledb/expressions/postfix/ArrayUnboxingExpression.java +++ b/src/main/java/org/rumbledb/expressions/postfix/ArrayUnboxingExpression.java @@ -33,6 +33,8 @@ public class ArrayUnboxingExpression extends Expression { + private static final long serialVersionUID = 1L; + private Expression mainExpression; public ArrayUnboxingExpression(Expression mainExpression, ExceptionMetadata metadata) { diff --git a/src/main/java/org/rumbledb/expressions/primary/ArrayConstructorExpression.java b/src/main/java/org/rumbledb/expressions/primary/ArrayConstructorExpression.java index b6da96d490..51eb88cdf0 100644 --- a/src/main/java/org/rumbledb/expressions/primary/ArrayConstructorExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/ArrayConstructorExpression.java @@ -31,6 +31,8 @@ public class ArrayConstructorExpression extends Expression { + private static final long serialVersionUID = 1L; + private Expression expression; public ArrayConstructorExpression(Expression expression, ExceptionMetadata metadata) { diff --git a/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java index b276978f98..5e23d7e15f 100644 --- a/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java @@ -31,6 +31,8 @@ public class BooleanLiteralExpression extends Expression { + private static final long serialVersionUID = 1L; + private boolean value; public BooleanLiteralExpression(boolean value, ExceptionMetadata metadata) { diff --git a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java index 6ab540108e..759522cbc1 100644 --- a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -40,13 +41,13 @@ public class InlineFunctionExpression extends Expression { private final Name name; private final FunctionIdentifier functionIdentifier; - private final Map params; + private final LinkedHashMap params; private final SequenceType returnType; private final Map bodies; public InlineFunctionExpression( Name name, - Map params, + LinkedHashMap params, SequenceType returnType, Expression body, ExceptionMetadata metadata diff --git a/src/main/java/org/rumbledb/expressions/typing/CastExpression.java b/src/main/java/org/rumbledb/expressions/typing/CastExpression.java index 6dd9e10bbe..5fea4a2e06 100644 --- a/src/main/java/org/rumbledb/expressions/typing/CastExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/CastExpression.java @@ -13,6 +13,8 @@ public class CastExpression extends Expression { + private static final long serialVersionUID = 1L; + private Expression mainExpression; private SequenceType sequenceType; diff --git a/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java b/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java index d790fa91cf..8b3fe0303c 100644 --- a/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java @@ -13,6 +13,8 @@ public class CastableExpression extends Expression { + private static final long serialVersionUID = 1L; + protected Expression mainExpression; private SequenceType sequenceType; From 4c33f658e9d8e47c75bebe2fa90eaeeaf254740f Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Thu, 3 Jun 2021 11:53:03 +0200 Subject: [PATCH 07/11] Fix tests. --- src/main/java/org/rumbledb/expressions/Expression.java | 3 ++- src/main/java/org/rumbledb/expressions/Node.java | 1 + .../arithmetic/MultiplicativeExpression.java | 1 + .../expressions/control/ConditionalExpression.java | 1 + .../org/rumbledb/expressions/flowr/CountClause.java | 1 + .../rumbledb/expressions/flowr/FlworExpression.java | 1 + .../java/org/rumbledb/expressions/flowr/ForClause.java | 1 + .../org/rumbledb/expressions/flowr/GroupByClause.java | 1 + .../java/org/rumbledb/expressions/flowr/LetClause.java | 1 + .../org/rumbledb/expressions/flowr/OrderByClause.java | 1 + .../org/rumbledb/expressions/logic/NotExpression.java | 1 + .../org/rumbledb/expressions/logic/OrExpression.java | 1 + .../expressions/module/FunctionDeclaration.java | 1 + .../org/rumbledb/expressions/module/LibraryModule.java | 1 + .../org/rumbledb/expressions/module/MainModule.java | 1 + .../java/org/rumbledb/expressions/module/Module.java | 2 ++ .../postfix/DynamicFunctionCallExpression.java | 1 + .../rumbledb/expressions/postfix/FilterExpression.java | 1 + .../expressions/postfix/ObjectLookupExpression.java | 1 + .../expressions/primary/ContextItemExpression.java | 2 ++ .../expressions/primary/DecimalLiteralExpression.java | 1 + .../expressions/primary/DoubleLiteralExpression.java | 1 + .../expressions/primary/FunctionCallExpression.java | 1 + .../expressions/primary/InlineFunctionExpression.java | 10 +++++++--- .../expressions/primary/IntegerLiteralExpression.java | 1 + .../primary/NamedFunctionReferenceExpression.java | 1 + .../expressions/primary/NullLiteralExpression.java | 2 ++ .../primary/ObjectConstructorExpression.java | 1 + .../expressions/typing/InstanceOfExpression.java | 1 + .../expressions/typing/IsStaticallyExpression.java | 1 + src/main/java/org/rumbledb/items/FunctionItem.java | 2 +- 31 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/rumbledb/expressions/Expression.java b/src/main/java/org/rumbledb/expressions/Expression.java index 9cc6c5529d..c4d5d2700e 100644 --- a/src/main/java/org/rumbledb/expressions/Expression.java +++ b/src/main/java/org/rumbledb/expressions/Expression.java @@ -36,7 +36,8 @@ */ public abstract class Expression extends Node { - protected StaticContext staticContext; + private static final long serialVersionUID = 1L; + protected transient StaticContext staticContext; protected SequenceType inferredSequenceType; diff --git a/src/main/java/org/rumbledb/expressions/Node.java b/src/main/java/org/rumbledb/expressions/Node.java index cc5831392f..6a1d5f839f 100644 --- a/src/main/java/org/rumbledb/expressions/Node.java +++ b/src/main/java/org/rumbledb/expressions/Node.java @@ -35,6 +35,7 @@ */ public abstract class Node implements Serializable { + private static final long serialVersionUID = 1L; private ExceptionMetadata metadata; protected ExecutionMode highestExecutionMode = ExecutionMode.UNSET; diff --git a/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java b/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java index 16423c5a59..50ea315305 100644 --- a/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java +++ b/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java @@ -31,6 +31,7 @@ import java.util.List; public class MultiplicativeExpression extends Expression { + private static final long serialVersionUID = 1L; public static enum MultiplicativeOperator { MUL("*"), diff --git a/src/main/java/org/rumbledb/expressions/control/ConditionalExpression.java b/src/main/java/org/rumbledb/expressions/control/ConditionalExpression.java index 81247b76ac..58fab4c5ac 100644 --- a/src/main/java/org/rumbledb/expressions/control/ConditionalExpression.java +++ b/src/main/java/org/rumbledb/expressions/control/ConditionalExpression.java @@ -33,6 +33,7 @@ public class ConditionalExpression extends Expression { + private static final long serialVersionUID = 1L; private final Expression conditionExpression; private final Expression thenExpression; private final Expression elseExpression; diff --git a/src/main/java/org/rumbledb/expressions/flowr/CountClause.java b/src/main/java/org/rumbledb/expressions/flowr/CountClause.java index 3392464788..3edd67d359 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/CountClause.java +++ b/src/main/java/org/rumbledb/expressions/flowr/CountClause.java @@ -30,6 +30,7 @@ public class CountClause extends Clause { + private static final long serialVersionUID = 1L; private VariableReferenceExpression countClauseVar; public CountClause(VariableReferenceExpression countClauseVar, ExceptionMetadata metadata) { diff --git a/src/main/java/org/rumbledb/expressions/flowr/FlworExpression.java b/src/main/java/org/rumbledb/expressions/flowr/FlworExpression.java index f728b0a023..73c930e8d6 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/FlworExpression.java +++ b/src/main/java/org/rumbledb/expressions/flowr/FlworExpression.java @@ -32,6 +32,7 @@ public class FlworExpression extends Expression { + private static final long serialVersionUID = 1L; private ReturnClause returnClause; public FlworExpression( diff --git a/src/main/java/org/rumbledb/expressions/flowr/ForClause.java b/src/main/java/org/rumbledb/expressions/flowr/ForClause.java index 31a3373a17..bc686114af 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/ForClause.java +++ b/src/main/java/org/rumbledb/expressions/flowr/ForClause.java @@ -36,6 +36,7 @@ public class ForClause extends Clause { + private static final long serialVersionUID = 1L; private final Name variableName; private final boolean allowingEmpty; private final Name positionalVariableName; diff --git a/src/main/java/org/rumbledb/expressions/flowr/GroupByClause.java b/src/main/java/org/rumbledb/expressions/flowr/GroupByClause.java index d4fb0ccd63..3eb1cb3ee7 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/GroupByClause.java +++ b/src/main/java/org/rumbledb/expressions/flowr/GroupByClause.java @@ -32,6 +32,7 @@ public class GroupByClause extends Clause { + private static final long serialVersionUID = 1L; private final List variables; public GroupByClause(List variables, ExceptionMetadata metadata) { diff --git a/src/main/java/org/rumbledb/expressions/flowr/LetClause.java b/src/main/java/org/rumbledb/expressions/flowr/LetClause.java index 8be7d8545d..ec8eebff98 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/LetClause.java +++ b/src/main/java/org/rumbledb/expressions/flowr/LetClause.java @@ -36,6 +36,7 @@ public class LetClause extends Clause { + private static final long serialVersionUID = 1L; private final Name variableName; protected SequenceType sequenceType; protected Expression expression; diff --git a/src/main/java/org/rumbledb/expressions/flowr/OrderByClause.java b/src/main/java/org/rumbledb/expressions/flowr/OrderByClause.java index 5d892a177f..b5bb218af1 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/OrderByClause.java +++ b/src/main/java/org/rumbledb/expressions/flowr/OrderByClause.java @@ -31,6 +31,7 @@ public class OrderByClause extends Clause { + private static final long serialVersionUID = 1L; private final List sortingKeys; private final boolean isStable; diff --git a/src/main/java/org/rumbledb/expressions/logic/NotExpression.java b/src/main/java/org/rumbledb/expressions/logic/NotExpression.java index 89a1d3a849..bea2dfe51e 100644 --- a/src/main/java/org/rumbledb/expressions/logic/NotExpression.java +++ b/src/main/java/org/rumbledb/expressions/logic/NotExpression.java @@ -32,6 +32,7 @@ public class NotExpression extends Expression { + private static final long serialVersionUID = 1L; private Expression mainExpression; public NotExpression(Expression mainExpression, ExceptionMetadata metadata) { diff --git a/src/main/java/org/rumbledb/expressions/logic/OrExpression.java b/src/main/java/org/rumbledb/expressions/logic/OrExpression.java index 253815c7e5..28bc1340f6 100644 --- a/src/main/java/org/rumbledb/expressions/logic/OrExpression.java +++ b/src/main/java/org/rumbledb/expressions/logic/OrExpression.java @@ -29,6 +29,7 @@ import java.util.List; public class OrExpression extends Expression { + private static final long serialVersionUID = 1L; private Expression leftExpression; private Expression rightExpression; diff --git a/src/main/java/org/rumbledb/expressions/module/FunctionDeclaration.java b/src/main/java/org/rumbledb/expressions/module/FunctionDeclaration.java index 0eace7ff8d..851ea75f9f 100644 --- a/src/main/java/org/rumbledb/expressions/module/FunctionDeclaration.java +++ b/src/main/java/org/rumbledb/expressions/module/FunctionDeclaration.java @@ -34,6 +34,7 @@ public class FunctionDeclaration extends Node { + private static final long serialVersionUID = 1L; private final InlineFunctionExpression functionExpression; public FunctionDeclaration( diff --git a/src/main/java/org/rumbledb/expressions/module/LibraryModule.java b/src/main/java/org/rumbledb/expressions/module/LibraryModule.java index 08c4ca62e2..3c4c12bf89 100644 --- a/src/main/java/org/rumbledb/expressions/module/LibraryModule.java +++ b/src/main/java/org/rumbledb/expressions/module/LibraryModule.java @@ -31,6 +31,7 @@ public class LibraryModule extends Module { + private static final long serialVersionUID = 1L; protected StaticContext staticContext; private String namespace; private final Prolog prolog; diff --git a/src/main/java/org/rumbledb/expressions/module/MainModule.java b/src/main/java/org/rumbledb/expressions/module/MainModule.java index 5e1904ad39..892a8aed4f 100644 --- a/src/main/java/org/rumbledb/expressions/module/MainModule.java +++ b/src/main/java/org/rumbledb/expressions/module/MainModule.java @@ -33,6 +33,7 @@ public class MainModule extends Module { + private static final long serialVersionUID = 1L; protected StaticContext staticContext; private final Prolog prolog; private final Expression expression; diff --git a/src/main/java/org/rumbledb/expressions/module/Module.java b/src/main/java/org/rumbledb/expressions/module/Module.java index c35d1ae1a4..3213f21ebb 100644 --- a/src/main/java/org/rumbledb/expressions/module/Module.java +++ b/src/main/java/org/rumbledb/expressions/module/Module.java @@ -5,6 +5,8 @@ import org.rumbledb.expressions.Node; public abstract class Module extends Node { + private static final long serialVersionUID = 1L; + public Module(ExceptionMetadata metadata) { super(metadata); } diff --git a/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java b/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java index c9cde94503..a36afa3132 100644 --- a/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java +++ b/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java @@ -33,6 +33,7 @@ public class DynamicFunctionCallExpression extends Expression { + private static final long serialVersionUID = 1L; private Expression mainExpression; private List arguments; diff --git a/src/main/java/org/rumbledb/expressions/postfix/FilterExpression.java b/src/main/java/org/rumbledb/expressions/postfix/FilterExpression.java index 0c700186d2..52b72abe36 100644 --- a/src/main/java/org/rumbledb/expressions/postfix/FilterExpression.java +++ b/src/main/java/org/rumbledb/expressions/postfix/FilterExpression.java @@ -37,6 +37,7 @@ public class FilterExpression extends Expression { + private static final long serialVersionUID = 1L; private Expression mainExpression; private Expression predicateExpression; diff --git a/src/main/java/org/rumbledb/expressions/postfix/ObjectLookupExpression.java b/src/main/java/org/rumbledb/expressions/postfix/ObjectLookupExpression.java index 6e17c5eaec..02cc16461c 100644 --- a/src/main/java/org/rumbledb/expressions/postfix/ObjectLookupExpression.java +++ b/src/main/java/org/rumbledb/expressions/postfix/ObjectLookupExpression.java @@ -33,6 +33,7 @@ public class ObjectLookupExpression extends Expression { + private static final long serialVersionUID = 1L; private Expression mainExpression; private Expression lookupExpression; diff --git a/src/main/java/org/rumbledb/expressions/primary/ContextItemExpression.java b/src/main/java/org/rumbledb/expressions/primary/ContextItemExpression.java index 65e0119283..04a55e54c0 100644 --- a/src/main/java/org/rumbledb/expressions/primary/ContextItemExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/ContextItemExpression.java @@ -30,6 +30,8 @@ public class ContextItemExpression extends Expression { + private static final long serialVersionUID = 1L; + public ContextItemExpression(ExceptionMetadata metadataFromContext) { super(metadataFromContext); } diff --git a/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java index b1c7e35589..94ffdf141a 100644 --- a/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java @@ -32,6 +32,7 @@ public class DecimalLiteralExpression extends Expression { + private static final long serialVersionUID = 1L; private BigDecimal value; public DecimalLiteralExpression(BigDecimal value, ExceptionMetadata metadata) { diff --git a/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java index 3db15cc36a..4f0c24ec2e 100644 --- a/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java @@ -31,6 +31,7 @@ public class DoubleLiteralExpression extends Expression { + private static final long serialVersionUID = 1L; private double value; public DoubleLiteralExpression(double value, ExceptionMetadata metadata) { diff --git a/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java b/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java index ceb14792fc..e7a15e3401 100644 --- a/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java @@ -40,6 +40,7 @@ public class FunctionCallExpression extends Expression { + private static final long serialVersionUID = 1L; private final FunctionIdentifier identifier; private final List arguments; // null for placeholder private final boolean isPartialApplication; diff --git a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java index 759522cbc1..c932087eb9 100644 --- a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java @@ -38,6 +38,7 @@ import java.util.Map; public class InlineFunctionExpression extends Expression { + private static final long serialVersionUID = 1L; private final Name name; private final FunctionIdentifier functionIdentifier; @@ -58,7 +59,10 @@ public InlineFunctionExpression( this.returnType = returnType; this.bodies = new HashMap<>(); this.bodies.put(0L, body); - this.bodies.put(1L, (Expression) SerializationUtils.clone(body)); + // for inline functions, we maintain another version for ML models + if (this.name == null) { + this.bodies.put(1L, (Expression) SerializationUtils.clone(body)); + } this.functionIdentifier = new FunctionIdentifier(name, params.size()); } @@ -100,7 +104,7 @@ public void registerUserDefinedFunctionExecutionMode( getStaticContext().getUserDefinedFunctionsExecutionModes() .setExecutionMode( identifier, - this.bodies.get(0).getHighestExecutionMode(visitorConfig), + this.bodies.get(0L).getHighestExecutionMode(visitorConfig), visitorConfig.suppressErrorsForFunctionSignatureCollision(), this.getMetadata() ); @@ -164,7 +168,7 @@ public void serializeToJSONiq(StringBuffer sb, int indent) { sb.append("\n"); indentIt(sb, indent); sb.append("{\n"); - this.bodies.get(0).serializeToJSONiq(sb, indent + 1); + this.bodies.get(0L).serializeToJSONiq(sb, indent + 1); indentIt(sb, indent); sb.append("}\n"); } diff --git a/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java index fcbf9a639f..1c507d88d0 100644 --- a/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java @@ -31,6 +31,7 @@ public class IntegerLiteralExpression extends Expression { + private static final long serialVersionUID = 1L; private String lexicalValue; public IntegerLiteralExpression(String lexicalValue, ExceptionMetadata metadata) { diff --git a/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java b/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java index b3342992c3..8dae35fb7a 100644 --- a/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java @@ -32,6 +32,7 @@ public class NamedFunctionReferenceExpression extends Expression { + private static final long serialVersionUID = 1L; private final FunctionIdentifier identifier; public NamedFunctionReferenceExpression(FunctionIdentifier identifier, ExceptionMetadata metadata) { diff --git a/src/main/java/org/rumbledb/expressions/primary/NullLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/NullLiteralExpression.java index 0b7a52808e..e508119600 100644 --- a/src/main/java/org/rumbledb/expressions/primary/NullLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/NullLiteralExpression.java @@ -32,6 +32,8 @@ public class NullLiteralExpression extends Expression { + private static final long serialVersionUID = 1L; + public NullLiteralExpression(ExceptionMetadata metadata) { super(metadata); } diff --git a/src/main/java/org/rumbledb/expressions/primary/ObjectConstructorExpression.java b/src/main/java/org/rumbledb/expressions/primary/ObjectConstructorExpression.java index 429baf5a63..c148267d47 100644 --- a/src/main/java/org/rumbledb/expressions/primary/ObjectConstructorExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/ObjectConstructorExpression.java @@ -31,6 +31,7 @@ public class ObjectConstructorExpression extends Expression { + private static final long serialVersionUID = 1L; private boolean isMergedConstructor = false; private List values; private List keys; diff --git a/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java b/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java index ef730359a8..30545cc0a8 100644 --- a/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java @@ -33,6 +33,7 @@ public class InstanceOfExpression extends Expression { + private static final long serialVersionUID = 1L; private Expression mainExpression; private SequenceType sequenceType; diff --git a/src/main/java/org/rumbledb/expressions/typing/IsStaticallyExpression.java b/src/main/java/org/rumbledb/expressions/typing/IsStaticallyExpression.java index cad37ad1d1..449bcbdb03 100644 --- a/src/main/java/org/rumbledb/expressions/typing/IsStaticallyExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/IsStaticallyExpression.java @@ -11,6 +11,7 @@ import java.util.List; public class IsStaticallyExpression extends Expression { + private static final long serialVersionUID = 1L; private Expression mainExpression; private SequenceType sequenceType; diff --git a/src/main/java/org/rumbledb/items/FunctionItem.java b/src/main/java/org/rumbledb/items/FunctionItem.java index 140ebd173e..2d6a9cd652 100644 --- a/src/main/java/org/rumbledb/items/FunctionItem.java +++ b/src/main/java/org/rumbledb/items/FunctionItem.java @@ -149,7 +149,7 @@ public DynamicContext getModuleDynamicContext() { } public RuntimeIterator getBodyIterator() { - return this.bodyIterators.get(0); + return this.bodyIterators.get(0L); } public Map getBodyIterators() { From bff5782dcd57e3f1a34f59aadb56411500bfb167 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Thu, 3 Jun 2021 13:02:49 +0200 Subject: [PATCH 08/11] Fix printed iterators. --- .../expressions/primary/InlineFunctionExpression.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java index c932087eb9..bf7047d671 100644 --- a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java @@ -133,13 +133,13 @@ public void print(StringBuffer buffer, int indent) { buffer.append(" | " + this.highestExecutionMode); buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); - for (int i = 0; i < indent + 2; ++i) { - buffer.append(" "); - } for (long l : this.bodies.keySet()) { + for (int i = 0; i < indent; ++i) { + buffer.append(" "); + } + buffer.append("Body " + l + ":\n"); this.bodies.get(l).print(buffer, indent + 2); } - buffer.append("Body:\n"); } @Override From 3cd0f1830a451a7b4524799305307e90de9786af Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Thu, 3 Jun 2021 13:18:50 +0200 Subject: [PATCH 09/11] Fix test. --- src/main/java/org/rumbledb/compiler/StaticContextVisitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java index 17a47517ce..bb87b2ea12 100644 --- a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java @@ -202,7 +202,7 @@ public StaticContext visitInlineFunctionExpr(InlineFunctionExpression expression ); } // visit the body first to make its execution mode available while adding the function to the catalog - this.visit(expression.getBodies().get(0), functionDeclarationContextLocal); + this.visit(expression.getBodies().get(0L), functionDeclarationContextLocal); StaticContext functionDeclarationContextRDD = new StaticContext(argument); boolean first = true; From 316a6783f2b14b4b6875d1c37801909fb98d81a6 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Thu, 3 Jun 2021 13:19:21 +0200 Subject: [PATCH 10/11] Fix print. --- .../rumbledb/expressions/primary/InlineFunctionExpression.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java index bf7047d671..efdd592093 100644 --- a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java @@ -134,7 +134,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (long l : this.bodies.keySet()) { - for (int i = 0; i < indent; ++i) { + for (int i = 0; i < indent + 1; ++i) { buffer.append(" "); } buffer.append("Body " + l + ":\n"); From 69ca03e3d1d38e9ebf36ef5f9a2c40d506d56e66 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Thu, 3 Jun 2021 13:45:31 +0200 Subject: [PATCH 11/11] Fix tests. --- .../java/org/rumbledb/expressions/flowr/ReturnClause.java | 1 + .../org/rumbledb/expressions/flowr/SimpleMapExpression.java | 1 + .../rumbledb/expressions/miscellaneous/RangeExpression.java | 1 + .../expressions/miscellaneous/StringConcatExpression.java | 1 + src/main/java/org/rumbledb/expressions/module/Prolog.java | 1 + .../expressions/primary/InlineFunctionExpression.java | 4 ++-- .../runtime/functions/DynamicFunctionCallIterator.java | 3 --- src/test/java/iq/base/AnnotationsTestsBase.java | 3 ++- 8 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/rumbledb/expressions/flowr/ReturnClause.java b/src/main/java/org/rumbledb/expressions/flowr/ReturnClause.java index 5753a05840..f03e2420b9 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/ReturnClause.java +++ b/src/main/java/org/rumbledb/expressions/flowr/ReturnClause.java @@ -32,6 +32,7 @@ public class ReturnClause extends Clause { + private static final long serialVersionUID = 1L; private final Expression returnExpr; diff --git a/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java b/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java index 91ef9bc425..9d5a6ffc2f 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java +++ b/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java @@ -31,6 +31,7 @@ import java.util.List; public class SimpleMapExpression extends Expression { + private static final long serialVersionUID = 1L; private Expression leftExpression; private Expression rightExpression; diff --git a/src/main/java/org/rumbledb/expressions/miscellaneous/RangeExpression.java b/src/main/java/org/rumbledb/expressions/miscellaneous/RangeExpression.java index c8b0a71ee4..d22ac08070 100644 --- a/src/main/java/org/rumbledb/expressions/miscellaneous/RangeExpression.java +++ b/src/main/java/org/rumbledb/expressions/miscellaneous/RangeExpression.java @@ -31,6 +31,7 @@ public class RangeExpression extends Expression { + private static final long serialVersionUID = 1L; private Expression leftExpression; private Expression rightExpression; diff --git a/src/main/java/org/rumbledb/expressions/miscellaneous/StringConcatExpression.java b/src/main/java/org/rumbledb/expressions/miscellaneous/StringConcatExpression.java index e9b19573c0..ae23b440e6 100644 --- a/src/main/java/org/rumbledb/expressions/miscellaneous/StringConcatExpression.java +++ b/src/main/java/org/rumbledb/expressions/miscellaneous/StringConcatExpression.java @@ -30,6 +30,7 @@ import java.util.List; public class StringConcatExpression extends Expression { + private static final long serialVersionUID = 1L; private Expression leftExpression; private Expression rightExpression; diff --git a/src/main/java/org/rumbledb/expressions/module/Prolog.java b/src/main/java/org/rumbledb/expressions/module/Prolog.java index 1004b1367e..81331be346 100644 --- a/src/main/java/org/rumbledb/expressions/module/Prolog.java +++ b/src/main/java/org/rumbledb/expressions/module/Prolog.java @@ -31,6 +31,7 @@ public class Prolog extends Node { + private static final long serialVersionUID = 1L; private List declarations; private List importedModules; diff --git a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java index efdd592093..384ae1ac5d 100644 --- a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java @@ -21,7 +21,7 @@ package org.rumbledb.expressions.primary; -import org.apache.commons.lang.SerializationUtils; +import org.apache.commons.lang3.SerializationUtils; import org.rumbledb.compiler.VisitorConfig; import org.rumbledb.context.FunctionIdentifier; import org.rumbledb.context.Name; @@ -92,7 +92,7 @@ public Expression getBody() { @Override public List getChildren() { - return new ArrayList<>(bodies.values()); + return new ArrayList<>(this.bodies.values()); } public void registerUserDefinedFunctionExecutionMode( diff --git a/src/main/java/org/rumbledb/runtime/functions/DynamicFunctionCallIterator.java b/src/main/java/org/rumbledb/runtime/functions/DynamicFunctionCallIterator.java index bb1e3f6b93..4b5043e945 100644 --- a/src/main/java/org/rumbledb/runtime/functions/DynamicFunctionCallIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/DynamicFunctionCallIterator.java @@ -71,7 +71,6 @@ public DynamicFunctionCallIterator( @Override public void openLocal() { - super.open(this.currentDynamicContextForLocalExecution); setFunctionItemAndIteratorWithCurrentContext(this.currentDynamicContextForLocalExecution); this.functionCallIterator.open(this.currentDynamicContextForLocalExecution); setNextResult(); @@ -144,7 +143,6 @@ private void setFunctionItemAndIteratorWithCurrentContext(DynamicContext context @Override public void resetLocal() { - super.reset(this.currentDynamicContextForLocalExecution); this.functionCallIterator.reset(this.currentDynamicContextForLocalExecution); setNextResult(); } @@ -156,7 +154,6 @@ public void closeLocal() { if (this.isOpen) { this.functionCallIterator.close(); } - super.close(); } @Override diff --git a/src/test/java/iq/base/AnnotationsTestsBase.java b/src/test/java/iq/base/AnnotationsTestsBase.java index b0447c30c5..9cdc860e15 100644 --- a/src/test/java/iq/base/AnnotationsTestsBase.java +++ b/src/test/java/iq/base/AnnotationsTestsBase.java @@ -20,6 +20,7 @@ package iq.base; +import org.apache.commons.lang.exception.ExceptionUtils; import org.junit.Assert; import org.rumbledb.api.Item; import org.rumbledb.api.Rumble; @@ -175,7 +176,7 @@ protected void testAnnotations(String path, RumbleRuntimeConfiguration configura checkExpectedOutput(this.currentAnnotation.getOutput(), sequence); } catch (RumbleException exception) { String errorOutput = exception.getMessage(); - exception.printStackTrace(); + errorOutput += "\n" + ExceptionUtils.getStackTrace(exception); Assert.fail("Program did not run when expected to.\nError output: " + errorOutput + "\n"); } } else {