Skip to content

add DeepCopy to ColumnVisibility #5217

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

Closed
wants to merge 5 commits into 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.

@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
* @param node Node object
* @since 2.1.4
*/
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.

Since Node is removed in newer versions of accumulo this constructor could be switched to private to avoid standardizing its usage

Suggested change
public Node(Node node) {
private Node(Node node) {

public ColumnVisibility(ColumnVisibility visibility) {
byte[] incomingExpression = visibility.expression;
this.expression = Arrays.copyOf(incomingExpression, incomingExpression.length);
this.node = new Node(visibility.node);
Copy link
Contributor

Choose a reason for hiding this comment

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

I made a comment in #5293 that is applicable here also. I think it's possible that another thread could be mutating the parse tree (visibility.node) while this thread is trying to make a copy of the ColumnVisibility because the parse tree is accessible and mutable.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am experimenting w/ adding an immutable parse tree to accumulo-access as a possible way to address this.

@jalphonso jalphonso closed this Feb 6, 2025
@jalphonso jalphonso deleted the task/deepcopy-columnvis branch February 6, 2025 15:28
@ctubbsii ctubbsii removed this from the 2.1.4 milestone Feb 14, 2025
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.

5 participants