Skip to content

Conversation

@line-o
Copy link
Member

@line-o line-o commented Feb 4, 2021

Description:

This PR now only adds tests that extend the previous test for the immutability of maps

fork maps before mutating them

Reference:

refs #3724

Map implementation (bifurcan) documentation of the forked() method
https://lacuna.io/docs/bifurcan/io/lacuna/bifurcan/IMap.html#forked--

Type of tests:

Extended XQsuite tests in exist-core/src/test/xquery/maps/maps.xql

@line-o
Copy link
Member Author

line-o commented Feb 4, 2021

So, in SingleKeyMapType#put a different method is used to create the copy of the map.
return new MapType(context, map.forked(), keyType);
I have not enough knowledge yet which one is the better in the instances changed here.

.forked() or .clone() - this will likely have effects on memory usage and maybe performance.

@line-o
Copy link
Member Author

line-o commented Feb 4, 2021

I do not understand the underlying implementation of "forked", though:

    default IMap<K, V> forked() {
        return this;
    }

@line-o
Copy link
Member Author

line-o commented Feb 4, 2021

using .forked() also works, so we can choose whichever is best. I tend to go with the forked method.

@line-o line-o requested a review from a team February 4, 2021 17:57
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 4, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@line-o
Copy link
Member Author

line-o commented Feb 4, 2021

Ready to be merged from my point of view. Tests fail until the fix is applied.

Copy link
Member

@joewiz joewiz left a comment

Choose a reason for hiding this comment

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

I can confirm that when building eXist from this PR's branch, the tests that @PieterLamers and I developed in #3724 all return the expected results.

@dizzzz dizzzz added the bug issue confirmed as bug label Feb 5, 2021
@line-o line-o changed the title [hotfix] clone maps before performing mutations [hotfix] fork maps before performing mutations Feb 5, 2021
@line-o
Copy link
Member Author

line-o commented Feb 5, 2021

@joewiz great!

Do you think the test cases I added are covering every combination we need to check?
https://github.com/eXist-db/exist/pull/3725/files#diff-6cbf91fe2ed15b2f66e0c96ba43b21e94f3be9075de054b215a1cb0b5a88cfd7

@joewiz
Copy link
Member

joewiz commented Feb 5, 2021

@line-o Yes, I think you've got the ones in the issue covered with mt:immutable-put-after-merge, mt:immutable-remove-after-merge, and mt:immutable-merge-after-merge, and the other variations were a great idea too.

@adamretter
Copy link
Contributor

@line-o I just built the HEAD of Bifurcan and checked against that too. I wanted to do so, as it has some fixes that are not released yet. Unfortunately there was no change, still 6 failing tests. I will dig a little deeper...

@adamretter
Copy link
Contributor

@line-o I just expanded on some of your tests, and it caused me to find another bug in maps. The XQuery F+O specs says that default behaviour for map:merge when there are duplicates keys is to use-first, however eXist-db does use-last and some of your tests were relying on that - I will fix that too...

@line-o line-o added high prio xquery issue is related to xquery implementation labels Feb 27, 2021
@dizzzz
Copy link
Member

dizzzz commented Mar 30, 2021

Is there any new info on this?

@dizzzz dizzzz marked this pull request as draft April 11, 2021 12:02
@dizzzz
Copy link
Member

dizzzz commented Apr 11, 2021

what is the state of the PR? @line-o @adamretter
I marked it as draft to prevent accidental pulling in

@line-o
Copy link
Member Author

line-o commented Apr 11, 2021

I am waiting for this to either a) be merged as it is or for a review that tells what needs to change (I expect this to be "remove the surplus calls to forked()")
What I will definitely do is fix the minor issue in one the tests.

@line-o
Copy link
Member Author

line-o commented May 17, 2021

I can confirm that #3724 is fixed by the new release of bifurcan.

@joewiz
Copy link
Member

joewiz commented May 17, 2021

@line-o That's great news! Thank you for all of your efforts on the maps issue, Juri! When you have the chance, could you please approve #3886?

@line-o
Copy link
Member Author

line-o commented May 17, 2021

Oh wait. I was under the impression that this PR was already applied!
This needs to be retested.

@line-o
Copy link
Member Author

line-o commented May 18, 2021

Rebase and with improved test cases.
I still see odd behaviour and fear that there is a) still issues in the map implementation or b) issues in how this library is used.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@line-o line-o marked this pull request as ready for review May 20, 2021 08:26
@line-o line-o removed the high prio label May 27, 2021
@line-o line-o marked this pull request as draft May 27, 2021 21:22
@adamretter
Copy link
Contributor

adamretter commented Jun 28, 2021

This is no longer needed, as the bug was indeed in Bifurcan and was fixed as lacuna/bifurcan#35 (comment); upgraded in eXist-db as #3886

The tests from this PR were incorporated and expanded upon in #3738

@line-o are you happy to close this one now?

@line-o
Copy link
Member Author

line-o commented Jun 30, 2021

@adamretter I actually re-incorporated the tests here and added a final improvement to them. What about we make this PR the one adding the tests and #3738 can then be solely about map:merge#2.
That is also nicer later when we compile the changelog.

@line-o
Copy link
Member Author

line-o commented Jun 30, 2021

I will take responsibility in changing the PR description and title as well as the commit history assuming you do so for #3738 as well.

@adamretter
Copy link
Contributor

adamretter commented Jun 30, 2021

@line-o I don't think that makes sense, you would also need to remove all your Java changes in this PR;
As they were an early attempt to fix the Maps problem that was reported in eXist-db's code, but the real problem wasn't in eXist-db's code... it was in Bifurcan which I worked on to diagnose and get it resolved at its source. Wouldn't this PR then solely end up just being tests most of which were created/expanded/refactored in my other PR?

If you want my PR split into two, with and without the change to merge-order to match the spec, I have previously already offered to do that...

@line-o
Copy link
Member Author

line-o commented Jun 30, 2021

Of course I will remove the no longer needed commits.

@line-o
Copy link
Member Author

line-o commented Jun 30, 2021

I would also rather squash all the back and forth in the tests into a single commit.

@line-o line-o changed the title [hotfix] fork maps before performing mutations [test] extend tests for immutability of maps Jul 7, 2021
@line-o line-o added ci issues related to continuous integration and removed bug issue confirmed as bug labels Jul 7, 2021
@line-o line-o marked this pull request as ready for review July 7, 2021 11:47
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 7, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@dizzzz dizzzz closed this in #4000 Aug 3, 2021
@line-o line-o deleted the fix/3724 branch July 21, 2023 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci issues related to continuous integration xquery issue is related to xquery implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants