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

add DeepCopy to ColumnVisibility #5217

Open
wants to merge 3 commits into
base: 2.1
Choose a base branch
from

Conversation

jalphonso
Copy link

Added in DeepCopy methods for ColumnVisibility and the related Node class to save processing time in datawave.

@dlmarion dlmarion requested a review from keith-turner January 2, 2025 13:19
@dlmarion dlmarion added this to the 2.1.4 milestone Jan 2, 2025
@dlmarion
Copy link
Contributor

dlmarion commented Jan 2, 2025

I think this looks ok, but have added @keith-turner as a reviewer. He has recently modified newer versions of this code. The Node and parse tree are deprecated in 3.1 and will be removed in 4.0 and has been replaced by the AccessExpression in github.com/apache/accumulo-access. I also reviewed the commit history to see if there was a clone or deepCopy method that used to exist, but was removed for some reason, and did not see anything.

@keith-turner
Copy link
Contributor

keith-turner commented Jan 7, 2025

Looked at 3.1 and 4.0 version of Accumulo to see how this change would merge forward. While doing that I realized the deprecated code could be removed in 4.0 in ColumnVisibility. Removing that would influence how this would merge forward which would help thinking through these changes. I will try to remove the deprecated code soon to see how that may influence these changes.

@keith-turner
Copy link
Contributor

Opened #5232 to remove the deprecated column visibility code in 4.0

@jalphonso jalphonso force-pushed the task/deepcopy-columnvis branch from d73a47d to 93942d0 Compare January 17, 2025 15:59
@jalphonso
Copy link
Author

Opened #5232 to remove the deprecated column visibility code in 4.0

nice

@jalphonso
Copy link
Author

I think this looks ok, but have added @keith-turner as a reviewer. He has recently modified newer versions of this code. The Node and parse tree are deprecated in 3.1 and will be removed in 4.0 and has been replaced by the AccessExpression in github.com/apache/accumulo-access. I also reviewed the commit history to see if there was a clone or deepCopy method that used to exist, but was removed for some reason, and did not see anything.

Thanks Dave

@jalphonso
Copy link
Author

Looked at 3.1 and 4.0 version of Accumulo to see how this change would merge forward. While doing that I realized the deprecated code could be removed in 4.0 in ColumnVisibility. Removing that would influence how this would merge forward which would help thinking through these changes. I will try to remove the deprecated code soon to see how that may influence these changes.

Thanks Keith. I refactored the code to use the copy constructor instead of deepCopy to keep in line with the API. I do agree it looks cleaner this way and keeps the guarantee that the expression has been previously validated.

@@ -505,6 +516,12 @@ public ColumnVisibility(byte[] expression) {
validate(expression);
}

public ColumnVisibility(ColumnVisibility visibility) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs javadoc with a @since 2.1.4 tag. Would also be nice to mention in the javadoc that deep copy is done.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added javadoc

@@ -125,6 +125,17 @@ public Node(int start, int end) {
this.end = end;
}

public Node(Node node) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs the javadoc since tag and could document that a deep copy is done.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added javadoc

@dlmarion dlmarion added the blocker This issue blocks any release version labeled on it. label Jan 17, 2025
@dlmarion dlmarion requested a review from keith-turner January 17, 2025 16:13
@jalphonso jalphonso force-pushed the task/deepcopy-columnvis branch from d6765f1 to a53da7d Compare January 17, 2025 16:49
Comment on lines +135 to +138
List<Node> childrenNew = new ArrayList<>(node.children.size());
for (Node child : node.children) {
childrenNew.add(new Node(child));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked over the existing code and noticed it had some handling to avoid allocating empty list in the nodes. Can do that here also.

Suggested change
List<Node> childrenNew = new ArrayList<>(node.children.size());
for (Node child : node.children) {
childrenNew.add(new Node(child));
}
List<Node> childrenNew = node.children.isEmpty() ? EMPTY : new ArrayList<>(node.children.size());
for (Node child : node.children) {
childrenNew.add(new Node(child));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker This issue blocks any release version labeled on it.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants