-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
Can list changes be more intelligent #97
Comments
well, this is the issue concerning nested lists? The problem is that I don't know how to model these nested changes in the terms of Change.class I think that the better way to solving this problem is to alter the data model and get rid of nested lists. I know that it could be painfull but honestly I don't have good idea how to model this kind of Changes. Take a look at Change.class hierarchy and maybe you come up with some solution. |
I don't think altering the data model would help. I put together another Gist which I track changes on a List to get the nesting out of the test. The results were the same. https://gist.github.com/ctmay4/1a328c800b459101d1c4 I basically create list of 100 Strings. Then I remove the 5th element and add new new elements at the 90th position. For JaVers, I get the following output:
It is still listing almost every row since it doesn't "detect" a deletion. My gist also includes an example from java-object-diff. Here is the output:
It returns the entire before/after for the table, but also detects I added 2 rows and deleted one. Interestingly, it doesn't track which rows were added/deleted, just the values of those rows. I believe that library is comparing the values of the rows and assuming they are unique. I just wanted to point out that this is not only an issue with complicated nested structures. A simple List exhibits the same behavior. |
interesting, I'll investigate this issue shortly. Now we are in the middle of huge development in Javers, we are working on SQL repository, so our response times are bit slower, please be patient. |
Think I got it. The reason why you get such big change list is:
Since we remove 5'th row, the rows with index 5 and higher are shifted |
You are right, that JaVers could detect such shift and handle it in a more intelligent way |
as a quick win solution, I can implement Smart list comparing (including shift detection) requires more work. So would this |
It would possibly help, but I have not seen how Sets are handled. I assume this would be based on element equality? What if I have a Set with values
How would it report the second "1" being removed? For my personal use-case there may be duplicates. Once I get back to my office I will take a list at Set handling and let you know. Thanks again. |
Yes, this simple I'm working on more intelligent algorithm for comparing lists, but it may take a while. |
I'll add an implementation based on finding the min Levenshtein distance. I've got an POC algorithm ready which is both space and running time O(nm), where n and m is the length of list1 and list2 respectively. This can be optimised to be O(n) space and O(nm) time, will do a PR soon. |
- Added a smart comparison for lists based on the Levenshtein edit distance problem, see package-info for brief description
@ctmay4, we have created smart list compara algorithm, based on Levenshtein distance. |
The tables are usually really small (< 50 rows). We have a few tables that get as high as 4000 rows. |
great, so the new algorithm will be fine for you, i'am doing the release ... |
JaVers 1.1.1 is released, use the new Levenshtein algorithm for comparing lists, |
I have a class Node and it has list of devices. For example class Device { I am comparing two Node objects using LEVENSHTEIN_DISTANCE algorithm and scenarios are mentioned below : Senario - 1. Remove device1:
Output:
Senario - 2. Add device2:
Output:
Senario - 3. Remove device1 from the position 0 in device list:
Output:
3rd scenario is giving wrong output because I removed device1 from the 0th position in the list but it is giving removed from the 1st position in the device list. I want 3rd scenario output like:
Is JaVers having limitations for list of custom object? I missed 3rd scenario in my prototype. I went and integrated into my project and changes are moved to stage. This is blocked me to release. Could you please provide your thought on this? Thanks a lot |
@shivusajjan this issue was closed 5 years ago, why are you commenting it? |
LEVENSHTEIN_DISTANCE algorithm did not work for custom object list. For example |
I have a an entity with a List<List> that I am tracking changes on. I just tested an Object which has 837 List object
So removing a single line from the List causes an audit trail of 800+ entries. Instead, wouldn't it be better to have this be the result:
For example, if I put the raw JSON out and delete the line, a command-line diff looks like this:
Not sure how easy this would be to accomplish, but I do worry that if small changes are producing so much noise, what if I had a table with a very large list. The growth of the changelog would be too quick.
The text was updated successfully, but these errors were encountered: