Skip to content
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

GH-82 TransportContext: merge and key iterator #85

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

szysas
Copy link
Collaborator

@szysas szysas commented Apr 23, 2024

No description provided.

@szysas szysas requested a review from sbernard31 April 23, 2024 12:09
@sbernard31
Copy link
Collaborator

sbernard31 commented Apr 23, 2024

It's take me few minutes to get how "merge with override" works. 🤔
Actually, when you merge if there is 2 value with same key both are kept in the chained list but only the first one will be returned by the get(), correct ?

That's surprising me but if it works why not. I guess one drawback is that merged context takes probably a bit more memory than necessary.

I didn't test it but reading the code I guess that :

TransportContext ctx1 = TransportContext.of(DUMMY_KEY, "111").with(DUMMY_KEY2, "222");
TransportContext ctx2 = TransportContext.of(DUMMY_KEY, "aaa");
TransportContext ctx1Ctx2 = ctx1.with(ctx2);

TransportContext ctx3 = TransportContext.of(DUMMY_KEY, "aaa").with(DUMMY_KEY2, "222");   
// OR TransportContext ctx3 = TransportContext.of(DUMMY_KEY2, "222").with(DUMMY_KEY, "aaa");  
// not sure about the merge order : this makes me think 
// that maybe a better name would be addFirst() or addLast() (instead of with())
// Just because order seems relevant for equals()

assertEquals(ctx1Ctx2, ctx3); 
// From user point of view, I guess this should be equal, but is it ? 
// reading the code I'm not sure. 

and also if I iterate over ctx1Ctx2 and print all key, I will get DUMMY_KEY twice correct ?

(I maybe totally missed something, sorry I didn't take time to execute code)

@szysas
Copy link
Collaborator Author

szysas commented Apr 24, 2024

and also if I iterate over ctx1Ctx2 and print all key, I will get DUMMY_KEY twice correct ?

Yes, that is correct.

@szysas
Copy link
Collaborator Author

szysas commented Jul 10, 2024

and also if I iterate over ctx1Ctx2 and print all key, I will get DUMMY_KEY twice correct ?

@sbernard31 Now that it is fixed by returning Set with keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants