question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Confusion over when to use linear/forked

See original GitHub issue

I am a little perplexed over when it is appropriate to call fork or linear.

I have called map2.forked before I then call map2.linear to create map3, however I see changes made to my map3 reflected in my map2. I had thought that forked would mean that changes to map3 don’t affect map2.

It may be that I have misunderstood the docs and this isn’t a bug after all. Some guidance would be appreciated please…

    @Test
    public void bifurcanImmutableRemoveThenRemove() {

        /*
          1. Create the initial map1: `map { 1: true(), 2: true() }`
         */
        IMap<Integer, Boolean> map1 = new LinearMap<>();
        map1.put(1, true);
        map1.put(2, true);
        map1 = map1.forked();  // make the map immutable
        checkMapIsForked(map1);

        /*
          2. Create map2 and remove the entry with key `2`
         */
        IMap<Integer, Boolean> map2 = map1.linear();  // create a transient map for modifications
        map2 = map2.remove(2);
        map2 = map2.forked();  // make the map immutable
        checkMapIsForked(map2);

        /*
          3. Check the entries in map2 with key `1` and `2`
         */
        final Boolean expected1 = map2.get(1, null);
        assertTrue(expected1);
        final Boolean expected2 = map2.get(2, null);
        assertNull(expected2);

        /*
         4. Create map3 and remove the entry in the with key `1`
         */
        IMap<Integer, Boolean> map3 = map2.linear();  // create a transient map for modifications
        map3 = map3.remove(1);
        map3 = map3.forked();  // make the map immutable
        checkMapIsForked(map3);

        /*
         I expect map2.get(1, null) to return true
        */
        assertEquals(expected1, map2.get(1, null));

        /*
         I expect map3.get(1, null) to return null
         */
        assertNotEquals(expected1, map3.get(1, null));
    }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
adamrettercommented, May 16, 2021

@ztellman Thanks for being so responsive as always Zach, it’s much appreciated. Also thanks for the prompt fix, I will upgrade our project to use it.

@line-o I believe that the code as I had it before is still correct, and that this fix resolves the issue we saw.

1reaction
ztellmancommented, May 15, 2021

This was an extremely indirect result of IntSet.isLinear always returning false due to it not being properly overridden. I’ve confirmed that your example now exhibits the correct behavior. Thanks for catching this, I need to give some thought as to properly expose these sorts of issues in my property-based testing.

I’ll update the issue once this fix is in a released version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dealing with forks · Issue #17 · semver/semver - GitHub
I maintain a local fork of BarPackage based on its state in 1.0. 0; I might do this because: its changes are either...
Read more >
Replication fork reversal and the maintenance of genome ...
(B) Fork regression would reposition the 3′ end of the blocked leading strand so that it would be paired with the nascent lagging...
Read more >
Hairy Forked Nail-wort (Paronychia fastigiata) - Wisconsin DNR
Most likely to be confused with tall forked chickweed (Paronychia ... Sepals are lance-like to linear, with the tip of the hooded apex...
Read more >
Fork and Join: Java Can Excel at Painless Parallel ... - Oracle
Cooperation among tasks happens through fork() and join() , as illustrated in Figure 2. Note that the fork() and join() method names should...
Read more >
Git Team Workflows Best Practices: Merge or Rebase?
You have not shared your work with anyone else. At this point, you should prefer rebasing over merging to keep history tidy. If...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found