Skip to content

Commit

Permalink
Apply spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
dloughlin committed May 28, 2023
1 parent 9895c7c commit 248ecd6
Show file tree
Hide file tree
Showing 26 changed files with 306 additions and 133 deletions.
35 changes: 16 additions & 19 deletions src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@
import org.rumbledb.expressions.AbstractNodeVisitor;
import org.rumbledb.expressions.Expression;
import org.rumbledb.expressions.Node;
import org.rumbledb.expressions.flowr.ReturnClause;
import org.rumbledb.expressions.module.FunctionDeclaration;
import org.rumbledb.expressions.module.LibraryModule;
import org.rumbledb.expressions.module.Prolog;
import org.rumbledb.expressions.module.TypeDeclaration;
import org.rumbledb.expressions.module.VariableDeclaration;
import org.rumbledb.expressions.primary.InlineFunctionExpression;
import org.rumbledb.expressions.update.CopyDeclaration;
import org.rumbledb.expressions.update.TransformExpression;
import org.rumbledb.items.ItemFactory;
import org.rumbledb.items.parsing.ItemParser;
import org.rumbledb.runtime.RuntimeIterator;
Expand Down Expand Up @@ -116,22 +113,22 @@ public DynamicContext visitFunctionDeclaration(FunctionDeclaration declaration,
return defaultAction(expression, argument);
}

// @Override
// public DynamicContext visitTransformExpression(TransformExpression expression, DynamicContext argument) {
//
// for (CopyDeclaration copyDecl : expression.getCopyDeclarations()) {
// Expression child = copyDecl.getSourceExpression();
// this.visit(child, argument);
// RuntimeIterator iterator = VisitorHelpers.generateRuntimeIterator(child, this.configuration);
// iterator.bindToVariableInDynamicContext(argument, copyDecl.getVariableName(), argument);
// }
//
// this.visit(expression.getModifyExpression(), argument);
//
// this.visit(expression.getReturnExpression(), argument);
//
// return argument;
// }
// @Override
// public DynamicContext visitTransformExpression(TransformExpression expression, DynamicContext argument) {
//
// for (CopyDeclaration copyDecl : expression.getCopyDeclarations()) {
// Expression child = copyDecl.getSourceExpression();
// this.visit(child, argument);
// RuntimeIterator iterator = VisitorHelpers.generateRuntimeIterator(child, this.configuration);
// iterator.bindToVariableInDynamicContext(argument, copyDecl.getVariableName(), argument);
// }
//
// this.visit(expression.getModifyExpression(), argument);
//
// this.visit(expression.getReturnExpression(), argument);
//
// return argument;
// }

@Override
public DynamicContext visitVariableDeclaration(VariableDeclaration variableDeclaration, DynamicContext argument) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
import org.rumbledb.runtime.primary.ObjectConstructorRuntimeIterator;
import org.rumbledb.runtime.primary.StringRuntimeIterator;
import org.rumbledb.runtime.primary.VariableReferenceIterator;
import org.rumbledb.runtime.update.PendingUpdateList;
import org.rumbledb.runtime.update.expression.*;
import org.rumbledb.types.BuiltinTypesCatalogue;
import org.rumbledb.types.SequenceType;
Expand Down Expand Up @@ -401,7 +400,9 @@ public RuntimeIterator visitInsertExpression(InsertExpression expression, Runtim

RuntimeIterator mainIterator = this.visit(expression.getMainExpression(), argument);
RuntimeIterator toInsertIterator = this.visit(expression.getToInsertExpression(), argument);
RuntimeIterator positionIterator = expression.hasPositionExpression() ? this.visit(expression.getPositionExpression(), argument) : null;
RuntimeIterator positionIterator = expression.hasPositionExpression()
? this.visit(expression.getPositionExpression(), argument)
: null;

RuntimeIterator runtimeIterator = new InsertExpressionIterator(
mainIterator,
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/org/rumbledb/compiler/StaticContextVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,16 +348,21 @@ public StaticContext visitTransformExpression(TransformExpression expression, St
return argument;
}

private StaticContext visitCopyDecl(CopyDeclaration copyDeclaration, StaticContext argument, StaticContext copyContext) {
private StaticContext visitCopyDecl(
CopyDeclaration copyDeclaration,
StaticContext argument,
StaticContext copyContext
) {
this.visit(copyDeclaration.getSourceExpression(), copyContext);

StaticContext result = new StaticContext(argument);
result.addVariable(
copyDeclaration.getVariableName(),
copyDeclaration.getSourceSequenceType(),
copyDeclaration.getSourceExpression().getMetadata()
copyDeclaration.getVariableName(),
copyDeclaration.getSourceSequenceType(),
copyDeclaration.getSourceExpression().getMetadata()
);
copyDeclaration.getSourceSequenceType().resolve(copyContext, copyDeclaration.getSourceExpression().getMetadata());
copyDeclaration.getSourceSequenceType()
.resolve(copyContext, copyDeclaration.getSourceExpression().getMetadata());

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ public class DuplicateKeyOnUpdateApplyException extends RumbleException {

public DuplicateKeyOnUpdateApplyException(String keyInfo, ExceptionMetadata metadata) {
super(
"Dynamic Updating error; Duplicate keys inserted into target object during update application: " + keyInfo + ".",
ErrorCode.DuplicateKeyOnUpdateApplyErrorCode,
metadata
"Dynamic Updating error; Duplicate keys inserted into target object during update application: "
+ keyInfo
+ ".",
ErrorCode.DuplicateKeyOnUpdateApplyErrorCode,
metadata
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public class DuplicateObjectInsertSourceException extends RumbleException {

public DuplicateObjectInsertSourceException(String keyInfo, ExceptionMetadata metadata) {
super(
"Dynamic Updating error; Duplicate keys to insert into object: " + keyInfo + ".",
ErrorCode.DuplicateObjectInsertSourceErrorCode,
metadata
"Dynamic Updating error; Duplicate keys to insert into object: " + keyInfo + ".",
ErrorCode.DuplicateObjectInsertSourceErrorCode,
metadata
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public class TooManyRenamesOnSameTargetSelectorException extends RumbleException

public TooManyRenamesOnSameTargetSelectorException(String keyInfo, ExceptionMetadata metadata) {
super(
"Dynamic Updating error; Too many renames on same object at key: " + keyInfo + ".",
ErrorCode.TooManyRenamesOnSameTargetSelectorErrorCode,
metadata
"Dynamic Updating error; Too many renames on same object at key: " + keyInfo + ".",
ErrorCode.TooManyRenamesOnSameTargetSelectorErrorCode,
metadata
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ public class TooManyReplacesOnSameTargetSelectorException extends RumbleExceptio

private static final long serialVersionUID = 1L;

public TooManyReplacesOnSameTargetSelectorException(String targetInfo, String selectorInfo, ExceptionMetadata metadata) {
public TooManyReplacesOnSameTargetSelectorException(
String targetInfo,
String selectorInfo,
ExceptionMetadata metadata
) {
super(
"Dynamic Updating error; Too many replaces on " + targetInfo + " at: " + selectorInfo + ".",
ErrorCode.TooManyReplacesOnSameTargetSelectorErrorCode,
metadata
"Dynamic Updating error; Too many replaces on " + targetInfo + " at: " + selectorInfo + ".",
ErrorCode.TooManyReplacesOnSameTargetSelectorErrorCode,
metadata
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class DeleteExpression extends Expression {

private Expression mainExpression;
private Expression locatorExpression;

public DeleteExpression(
Expression mainExpression,
Expression locatorExpression,
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/rumbledb/items/ObjectItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,12 @@ public boolean getEffectiveBooleanValue() {
public int getMutabilityLevel() {
return this.mutabilityLevel;
}

@Override
public void setMutabilityLevel(int mutabilityLevel) {
this.mutabilityLevel = mutabilityLevel;
for (Item item : values) {
item.setMutabilityLevel(mutabilityLevel);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ public PendingUpdateList getPendingUpdateList(DynamicContext context) {
if (localMatchingIterator != null) {
if (typeSwitchCase.getVariableName() != null) {
context.getVariableValues()
.addVariableValue(
typeSwitchCase.getVariableName(),
Collections.singletonList(this.testValue)
);
.addVariableValue(
typeSwitchCase.getVariableName(),
Collections.singletonList(this.testValue)
);
}

return localMatchingIterator.getPendingUpdateList(context);
Expand All @@ -215,10 +215,10 @@ public PendingUpdateList getPendingUpdateList(DynamicContext context) {

if (this.defaultCase.getVariableName() != null) {
context.getVariableValues()
.addVariableValue(
this.defaultCase.getVariableName(),
Collections.singletonList(this.testValue)
);
.addVariableValue(
this.defaultCase.getVariableName(),
Collections.singletonList(this.testValue)
);
}

return this.defaultCase.getReturnIterator().getPendingUpdateList(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

package org.rumbledb.runtime.flwor.clauses;

import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
import org.apache.log4j.LogManager;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.sql.Dataset;
Expand Down Expand Up @@ -399,10 +398,15 @@ public PendingUpdateList getPendingUpdateList(DynamicContext context) {
while (this.child.hasNext()) {
FlworTuple tuple = this.child.next();
this.tupleContext.getVariableValues().removeAllVariables(); // clear the previous variables
this.tupleContext.getVariableValues().setBindingsFromTuple(tuple, getMetadata()); // assign new variables
this.tupleContext.getVariableValues().setBindingsFromTuple(tuple, getMetadata()); // assign new
// variables
// from new tuple

result = PendingUpdateList.mergeUpdates(result, this.expression.getPendingUpdateList(this.tupleContext), this.getMetadata());
result = PendingUpdateList.mergeUpdates(
result,
this.expression.getPendingUpdateList(this.tupleContext),
this.getMetadata()
);

}
this.child.close();
Expand Down
Loading

0 comments on commit 248ecd6

Please sign in to comment.