Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing updates (yay!) #1250

Merged
merged 123 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
ba21971
Implement delete visit
Mar 14, 2023
3133a92
Implement simple delete visitor and expression class
Mar 14, 2023
9062cfe
Refactor common update locator grammar and visitor
Mar 14, 2023
fc4038e
Set up update expression classes and defaultAction method in Abstract…
Mar 14, 2023
ed5ea75
Implement simple rename expr class and make update classes public
Mar 14, 2023
93d962b
Return RenameExpression from visitRenameExpr
Mar 14, 2023
673a1a2
Fix stackoverflow bug on visit
Mar 15, 2023
794ccab
Update rename and replace to account for fix
Mar 18, 2023
a241b12
Refactor locator expressions to only be array or object lookups
Mar 19, 2023
7007221
Rename replace expr vars and implement append compile class
Mar 19, 2023
020b639
Implement simple transform expression parser
Mar 20, 2023
c7e9060
Update rename to only work with object lookups
Mar 20, 2023
8d8282c
Create ExpressionClassification enum to classify expression as BASIC_…
Mar 20, 2023
ff82e81
Add isUpdating method to Expression class
Mar 20, 2023
624764e
Implement simple InsertExpression node class and translation
Mar 20, 2023
2d834c3
Implement defaultAction and visitDescendants of ExpressionClassificat…
Mar 21, 2023
b6cf31a
Implement ExpressionClassificationVisitor and add visitor to module p…
Mar 21, 2023
3092fbf
Add expression classification to the iterator tree print of all expre…
Mar 21, 2023
622639f
Implement visit methods in StaticContextVisitor and VariableDependenc…
Mar 21, 2023
cac0712
Implement visit method in ExecutionModeVisitor for CopyDeclaration va…
Mar 21, 2023
7daaba1
Begin to implement static type inference for updating exprs
Mar 22, 2023
bd4aa8d
Add keywords to grammar
Mar 23, 2023
e7f7a2a
Refactor CopyDeclaration to not be a node and move visit responsibili…
Mar 23, 2023
5da00a5
Implement visit methods for updating exprs in InferTypeVisitor
Mar 23, 2023
8fc4877
Restrict ExpressionClassification attribute to Expressions
Mar 23, 2023
2e5fafc
Fix recursion bug for ExpressionClassificationVisitor
Mar 25, 2023
c1b0f0b
Implement FLWOR expression and clauses visit methods in ExpressionCla…
Mar 25, 2023
87c7b30
Implement TypeSwitch expression visit method in ExpressionClassificat…
Mar 25, 2023
c8c4c61
Implement Comma and Conditional expression visit methods in Expressio…
Mar 26, 2023
fba9ab9
Implement basic updating expression visit methods in ExpressionClassi…
Mar 26, 2023
28d8fcc
Ensure unaccounted for expression operands must not be updating
Mar 26, 2023
f3f2728
Add antlr updated files
Mar 26, 2023
64fa017
Maven spotless apply
Mar 26, 2023
a48d6ae
Merge branch 'dloughlin-grammar-extension' into 'master-dloughlin'
Mar 26, 2023
67107eb
Implement simple UpdatePrimitive class and interface, and implement I…
Mar 26, 2023
6a1631f
implement InsertIntoArrayPrimitive
Mar 26, 2023
3eea7e9
update ArrayItem to put multiple items in a position at once
Mar 26, 2023
daf9c39
Implement DeleteFromArrayPrimitive and DeleteFromObjectPrimitive
Mar 26, 2023
5a558e0
Implement ReplaceInArrayPrimitive and ReplaceInObjectPrimitive
Mar 26, 2023
e0093e8
Implement RenameInObjectPrimitive
Mar 26, 2023
e653596
Add getTarget method to UpdatePrimitive
Mar 26, 2023
082c8f0
Implement simple PUL class
Mar 26, 2023
358e15a
Add isUpdating and getPendingUpdateList methods to iterator hierarchy
Mar 26, 2023
df63d11
Refactor of primitives and attempt at more efficient merge
Mar 27, 2023
6c16a26
Refactor update primitives to follow Target, Selector, Source logical…
Mar 28, 2023
2f9c63c
Implement hashmap version of merge updates
Mar 28, 2023
4cdfef6
Begin to refactor to only use interfaces and finish merge in PUL
Apr 5, 2023
900ae6d
Refactor UpdatePrimitive classes to use interface and use Maps in PUL
Apr 10, 2023
7ce6e46
Implement ApplyUpdates in PendingUpdateList.java
Apr 21, 2023
d5e6096
Implement errors during merge and apply updates
Apr 27, 2023
162ab3a
Move item specific functions into interface
Apr 27, 2023
831bc4c
Create classes for Updating expression iterators
May 1, 2023
5e91d67
Add updating and puls to iterator hierarchy
May 1, 2023
ca883ff
Fix copy declaration variable typing
May 1, 2023
dc1f0ce
Fix indexing from 1 error in update prims
May 1, 2023
2d162fd
Create test for transform expression
May 1, 2023
a1668e9
Implement classes and visits for Append, Insert, Rename, and Replace …
May 1, 2023
d6e39a1
Implement a test for each update primitive
May 5, 2023
492ba6e
Remove locatorKind class
May 5, 2023
07a27d0
Remove locatorKind class file
May 5, 2023
4c1fb76
Implement updating commaexpressions and tests
May 6, 2023
8638154
Implement tests for multiple updates on same array
May 6, 2023
d3def15
Fix apply updates to apply array updates in reverse index order and e…
May 6, 2023
98bcb52
Create tests for multiple of same update primitive on objects
May 6, 2023
be0b720
Fix PUL merge to merge renames properly
May 6, 2023
43da2ae
Test multiple update primitives on objects
May 6, 2023
f619f47
Create simple tests for basic FLWOR exprs
May 8, 2023
4f2ce57
Remove storage of PUL
May 8, 2023
cc92a9f
Update transform expr to copy, have scoped context, and not be updati…
May 8, 2023
5cb6e40
Create simple test for updating type switch
May 8, 2023
b14ae11
Implement getPUL for typeswitch
May 8, 2023
61b1298
Create simple test for If expr
May 8, 2023
7644fef
Implement getPUL for IfRuntimeIterator
May 8, 2023
6263367
Refactor updating FLWOR tests
May 19, 2023
80e25db
Add original hashing to object hashcode
May 19, 2023
724dbc1
Refactor object hashcode to not use original hash and implement custo…
May 19, 2023
7f26805
Add errorcodes and exception classes for unhandled exceptions
May 22, 2023
7dcf8e6
Add error tests for XUST0001
May 22, 2023
7dd0cce
Remove redundant error codes and exceptions
May 22, 2023
7398da9
Add tests for XUST0002
May 22, 2023
26be43a
Add tests for XUDY0027
May 22, 2023
b5d6eaa
Implement exception throws for XUDY0027
May 22, 2023
8b1aa14
Create test for JNUP0005
May 22, 2023
a6f204b
Implement error throw for JNUP0005
May 22, 2023
315efaf
Create tests for JNUP0009
May 22, 2023
730bc3a
Implement metadata for JNUP0009
May 22, 2023
8422cef
Create test for JNUP0010
May 22, 2023
93e405b
Create tests for JNUP0008
May 22, 2023
d6c740e
Implement check and throw for JNUP0008
May 22, 2023
a58f2a3
Create tests for JNUP0007
May 22, 2023
0e286cb
Implement checks and throws for JNUP0007
May 22, 2023
832d38b
Create tests for JNUP0016
May 22, 2023
eb2b21f
Implement checks, throws, and metadata for JNUP0016
May 22, 2023
cc96b95
Create tests for JNUP0019
May 22, 2023
bac7acf
Implement check and throws for JNUP0019
May 22, 2023
8ca1fe6
Create tests for JNDY0003
May 22, 2023
7554da1
Add content copy semantics
May 22, 2023
c6100f1
Create tests for replace with empty sequence and more than one value …
May 22, 2023
ddb741d
Implement semantics for replace with empty sequence and more than one…
May 22, 2023
55bf850
Add test to check selector of insert into array is not null
May 23, 2023
d3b2d6c
Implement null check for selector of insert into array
May 23, 2023
bb7f982
Create updates use case test with small datasets
May 23, 2023
80b13d5
Add tests for transform with multiple copy vars
May 25, 2023
9d79899
Add tests for referencing copy vars outside their scope
May 25, 2023
24406a5
Implement semantics for scoping copy vars outside of modify and retur…
May 25, 2023
d3e965d
Create tests for XUDY0014
May 27, 2023
2d281f5
Implement semantics for XUDY0014 with currentMutabilityLevel and gett…
May 27, 2023
9895c7c
Fix test to coincide with changes for XUDY0014
May 27, 2023
248ecd6
Apply spotless
May 28, 2023
90655e2
Merge master back.
Feb 27, 2024
cf3d8d1
Spotless.
Feb 27, 2024
c6d2e68
Fix javadoc.
Feb 27, 2024
a1f99c1
Fix javadoc.
Feb 27, 2024
ff2fe42
Fix javadoc.
Feb 27, 2024
9c8b84c
Fix javadoc.
Feb 27, 2024
963106d
Set copy variable execution mode to local.
Feb 27, 2024
c24e6c4
Remove unused method.
Feb 27, 2024
ed8abc5
Merge branch 'master' of github.com:RumbleDB/rumble into updates
Feb 27, 2024
fae8f32
Merge master back.
Feb 27, 2024
86f51f9
Fix build.
Feb 27, 2024
67853a1
Fix warnings.
Feb 27, 2024
97cbc78
Spotless.
Feb 27, 2024
626631a
Merge branch 'master' into updates
ghislainfourny Feb 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/main/java/org/rumbledb/api/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,35 @@ default void putItem(Item item) {
throw new UnsupportedOperationException("Operation not defined for type " + this.getDynamicType());
}

/**
* Add an item at index i, if it is an array.
*
* @param item an item.
* @param i an integer.
*/
default void putItemAt(Item item, int i) {
throw new UnsupportedOperationException("Operation not defined for type " + this.getDynamicType());
}

/**
* Add all items in items at index i, if it is an array.
*
* @param items a list of items.
* @param i an integer.
*/
default void putItemsAt(List<Item> items, int i) {
throw new UnsupportedOperationException("Operation not defined for type " + this.getDynamicType());
}

/**
* Remove the item at index i, if it is an array.
*
* @param i an integer.
*/
default void removeItemAt(int i) {
throw new UnsupportedOperationException("Operation not defined for type " + this.getDynamicType());
}

/**
* Adds a value pair, if it is an array item.
*
Expand All @@ -577,6 +606,15 @@ default void putItemByKey(String key, Item value) {
throw new UnsupportedOperationException("Operation not defined for type " + this.getDynamicType());
}

/**
* Removes a key-value pair, if it is an object item.
*
* @param key a key.
*/
default void removeItemByKey(String key) {
throw new UnsupportedOperationException("Operation not defined for type " + this.getDynamicType());
}

/**
* Adds a key-value pair, if it is an object item. The value is lazily computed.
*
Expand Down Expand Up @@ -648,6 +686,23 @@ default boolean isNaN() {
throw new UnsupportedOperationException("Operation not defined for type " + this.getDynamicType());
}

/**
* Returns the mutability level of the item.
*
* @return an int representing nestedness of the item inside transform expressions.
*/
default int getMutabilityLevel() {
return 0;
}

/**
* Sets the mutability level of the item.
*
* @param mutabilityLevel the new mutability level.
*/
default void setMutabilityLevel(int mutabilityLevel) {
}

/**
* Tests for logical equality. The semantics are that of the eq operator.
*
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/org/rumbledb/api/Rumble.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.rumbledb.context.DynamicContext;
import org.rumbledb.expressions.module.MainModule;
import org.rumbledb.runtime.RuntimeIterator;
import org.rumbledb.runtime.update.PendingUpdateList;
import sparksoniq.spark.SparkSessionManager;

/**
Expand Down Expand Up @@ -50,6 +51,14 @@ public SequenceOfItems runQuery(String query) {
mainModule,
this.configuration
);

if (iterator.isUpdating()) {
PendingUpdateList pul = iterator.getPendingUpdateList(dynamicContext);
pul.applyUpdates(iterator.getMetadata());
}

System.err.println("final iterator is: " + iterator.isUpdating());

return new SequenceOfItems(iterator, dynamicContext, this.configuration);
}

Expand All @@ -70,6 +79,14 @@ public SequenceOfItems runQuery(URI location) throws IOException {
mainModule,
this.configuration
);

if (iterator.isUpdating()) {
PendingUpdateList pul = iterator.getPendingUpdateList(dynamicContext);
pul.applyUpdates(iterator.getMetadata());
}

System.err.println("final iterator is: " + iterator.isUpdating());

return new SequenceOfItems(iterator, dynamicContext, this.configuration);
}

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,23 @@ 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 visitVariableDeclaration(VariableDeclaration variableDeclaration, DynamicContext argument) {
Name name = variableDeclaration.getVariableName();
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/org/rumbledb/compiler/ExecutionModeVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
import org.rumbledb.expressions.primary.VariableReferenceExpression;
import org.rumbledb.expressions.typing.TreatExpression;
import org.rumbledb.expressions.typing.ValidateTypeExpression;
import org.rumbledb.expressions.update.CopyDeclaration;
import org.rumbledb.expressions.update.TransformExpression;
import org.rumbledb.items.ItemFactory;
import org.rumbledb.runtime.misc.RangeOperationIterator;
import org.rumbledb.types.BuiltinTypesCatalogue;
Expand Down Expand Up @@ -611,6 +613,25 @@ public StaticContext visitVariableDeclaration(VariableDeclaration variableDeclar
return argument;
}

@Override
public StaticContext visitTransformExpression(TransformExpression expression, StaticContext argument) {
StaticContext innerContext = expression.getStaticContext();
for (CopyDeclaration copyDecl : expression.getCopyDeclarations()) {
this.visit(copyDecl.getSourceExpression(), copyDecl.getSourceExpression().getStaticContext());
// first pass.
innerContext.setVariableStorageMode(
copyDecl.getVariableName(),
ExecutionMode.LOCAL
);
}
expression.setHighestExecutionMode(ExecutionMode.LOCAL);

this.visit(expression.getModifyExpression(), innerContext);
this.visit(expression.getReturnExpression(), innerContext);

return argument;
}

@Override
public StaticContext visitProlog(Prolog prolog, StaticContext argument) {
visitDescendants(prolog, argument);
Expand Down
Loading
Loading