-
Notifications
You must be signed in to change notification settings - Fork 453
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
API Coverage - Implement SINTER and SINTERSTORE #180
Comments
I'm interested in taking a stab at this! |
Go ahead! LMK if you have any questions! |
@TalZaccai , can you please update the assignees? This will help others easily find the unpicked items. |
If more than one person wants to attempt an open work item, please go ahead. If a PR comes in quicker and meets the requirements, then we would be happy to merge it. |
Someone else can take this. I don't think I have time to tackle this in a timely manner right now. |
@MojtabaTajik Let me know if you'd like to try and tackle this one! |
@TalZaccai yes, pls assign it to me. |
Done! :) |
@MojtabaTajik - any update on this? |
I just started working on it this week. Since it's my first contribution to Garnet, it's taking me more time to understand everything. I've completed all the steps, but in step 7, there's a partial class called "SetObject" which contains a HashSet<byte[]> field named "set". Am I proceeding correctly here? private void SetIntersect(byte* input, int length, ref SpanByteAndMemory output)
{
var _input = (ObjectInputHeader*)input;
int numSets = _input->count;
bool isMemory = false;
MemoryHandle ptrHandle = default;
// Parse the input to get the sets you want to intersect
List<HashSet<byte[]>> setsToIntersect = new List<HashSet<byte[]>>();
byte* inputCurrPtr = input + sizeof(ObjectInputHeader);
for (int i = 0; i < numSets; i++)
{
if (!RespReadUtils.ReadByteArrayWithLengthHeader(out var setBytes, ref inputCurrPtr, input + length))
return; // Handle parsing error
var tempSect = new HashSet<byte[]>() { setBytes };
setsToIntersect.Add(tempSect);
}
// Perform the intersection
var currentSet = set;
} |
Hey @MojtabaTajik! I understand your confusion, I think originally when I wrote these instructions they were meant for adding a single-object operation, so given your input I might update those for future work items :) To your question, your parsing logic should go into SetCommands.cs and the main command logic would go into SetOps.cs, where you can obtain the appropriate locks on the relevant keys and you could call the StorageSession's GET and SET operations to read & write to & from the object store. I would recommend that you review some similar commands that were implemented recently, such as LMOVE, SDIFF, SDIFFSTORE & SUNION for reference. Thanks again for your question, Tal. |
@TalZaccai |
Sounds good, I'll have a look at that new PR. Didn't know that someone else was working on it... |
Here's your opportunity to implement a couple of RESP commands in Garnet!
SINTER
Syntax:
SINTER key [key ...]
Command description:
Returns the members of the set resulting from the intersection of all the given sets.
For example:
Keys that do not exist are considered to be empty sets. With one of the keys being an empty set, the resulting set is also empty (since set intersection with an empty set always results in an empty set).
Response:
Array reply: a list with members of the resulting set.
SINTERSTORE
Syntax:
SINTERSTORE destination key [key ...]
Command description:
This command is equal to
SINTER
, but instead of returning the resulting set, it is stored indestination
.If
destination
already exists, it is overwritten.Response:
Integer reply: the number of elements in the resulting set.
How to approach this task:
Tip: First add a simple test that calls the new command and use it to debug as you develop, it will make your life much easier!
If you have any questions, the Garnet team is here to help!
The text was updated successfully, but these errors were encountered: