-
Notifications
You must be signed in to change notification settings - Fork 16
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 checks to make sure Update Operators do not use conflicting/overlapping paths #267
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dcbf346
First part: refactor operator path checking to use PathMatchLocator
tatu-at-datastax 1d61025
Add testing for PatchMatchLocator sorting
tatu-at-datastax 881e7f6
Merge branch 'main' into tatu/232-overlapping-path-check
tatu-at-datastax ac622c8
Implement actual overlapping path check, simple unit test to verify
tatu-at-datastax d82507c
Minor refactoring of IT (naming, grouping)
tatu-at-datastax 3f2abf8
Add an IT to verify path conflict
tatu-at-datastax 69d2ac7
Add another IT as per code review suggestion
tatu-at-datastax 1472087
Remove unnecessary statement
tatu-at-datastax c49d761
Fix PathMatchLocator sorting to be segment-aware to find overlap reli…
tatu-at-datastax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember off the top of my head which characters we allow in field names, but I don't think this will work if we allow spaces,
$
, or+
in field names. Because "path.x$foo" comes before "path.x.foo" in lexicographical order.Is there any way we can use a different approach here? I'd rather not add code that blocks us from supporting "$" in field names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why dollar sign or other characters would change logic here:
.
is separator character and nothing else? Or are you saying pathspath.x$foo
andpath.x.foo
conflict? (I wouldn't think they do if "$" is part of path segment?)That is, sorting for purpose of finding parent/child paths seems to work as far as I can see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tatu-at-datastax the issue is your alphabetical sorting assumption. The assumption here is that
path.x.some.more
would immediately followpath.x
in the sort order, unless there's some other conflicting path. But in ASCII,$
is less than.
. So conventional string sorting would put fields with dollar paths before conflicting paths. Below is an example in JavaScriptNot sure if that applies here, just figured I'd call that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vkarpov15 Ah. Ok, let me think this over. Good catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can make sorting work with some more work. Two obvious extensions:
.
is sorted likenull
byte (value 0)both would work; I may go with (2).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added segment-aware sorting, testing to verify functioning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks. It looks like the reason why this works though is because you've included a loop over path segments in the
compare()
method - any worries about this being potentially slow? You'll have to iterate over path segments O(nlogn) times, creating a map of all parent paths will likely be faster but more memory intensive. I don't think this is a big deal either way, just food for thought.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vkarpov15 that's a reasonable question. I guess it all depends on depth of document. My thinking was that for deeper documents most differences are at first segment(s) anyway so that it evens out, compared to String comparison. But my main consideration was, I guess, between straight String comparison (just changing sort value of
.
) vs segmented, where I think performance is similar. I did not consider possibility of building lookup for covered paths: in that case it does come back to both memory usage added and (more importantly), construction of new String instances to reconstruct parent paths. I guess it can go either way wrt overall performance, in the end.Fundamentally I guess it also comes down to how many updates do we usually have: I suspect differences are not meaningful until into thousands of operations.
Since this logic is fairly isolated, I think I'll keep the question in mind and can reconsider re-implementation if we find a hotspot.