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

[Compatibility] Added BZMPOP, BZPOPMAX and BZPOPMIN commands #884

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Vijay-Nirmal
Copy link
Contributor

Adding the BZMPOP, BZPOPMAX and BZPOPMIN commands to garnet

  • Add BZMPOP, BZPOPMAX and BZPOPMIN commands
  • Add Integration Test cases and ACL Test
  • Add documentation

@Vijay-Nirmal Vijay-Nirmal changed the title Added BZMPOP, BZPOPMAX and BZPOPMIN commands [Compatibility] Added BZMPOP, BZPOPMAX and BZPOPMIN commands Dec 16, 2024
Copy link
Contributor

@TalZaccai TalZaccai left a comment

Choose a reason for hiding this comment

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

Very nice PR! Thanks for the contribution. Added a few comments.

@@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Intrinsics.X86;
Copy link
Contributor

Choose a reason for hiding this comment

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

Mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -886,6 +887,19 @@ private void SortedSetRank(ref ObjectInput input, ref SpanByteAndMemory output,
}
}

public (double Score, byte[] Element) Pop(bool popMaxScoreElement = false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add an XML comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -886,6 +887,19 @@ private void SortedSetRank(ref ObjectInput input, ref SpanByteAndMemory output,
}
}

public (double Score, byte[] Element) Pop(bool popMaxScoreElement = false)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should rename this to PopMinOrMax for clarity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -2,6 +2,7 @@
// Licensed under the MIT license.

using System;
using System.Linq;
Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary using

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

keysBytes[i] = parseState.GetArgSliceByRef(i).SpanByte.ToByteArray();
}

if (!parseState.TryGetDouble(parseState.Count - 1, out var timeout))
Copy link
Contributor

Choose a reason for hiding this comment

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

Could do this verification (as well as the itemBroker one) before the keysBytes allocation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}
else
{
_ = EXPIRE(destinationKey, TimeSpan.Zero, out _, StoreType.Object, ExpireOption.None,
ref lockableContext, ref objectContext);
}

itemBroker.HandleCollectionUpdate(destinationKeyBty);
Copy link
Contributor

Choose a reason for hiding this comment

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

What about SortedSetUnionStore & SortedSetIntersectStore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -10,7 +10,7 @@

namespace Garnet.test
{
public class RespBlockingListTests
public class RespBlockingTests
Copy link
Contributor

Choose a reason for hiding this comment

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

naming: RespBlockingCollectionTests might be a bit more informative

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

libs/server/Objects/ItemBroker/CollectionItemResult.cs Outdated Show resolved Hide resolved
/// <summary>
/// Scored items retrieved from collection, where each item has an associated score.
/// </summary>
internal (double Score, byte[] Element)[] ScoredItems { get; }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think instead of doing this we should re-use the Item & Items properties to store the elements & have matching double Score and double[] Scores properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -389,14 +389,154 @@ public void BlmpopBlockingWithCountTest()
var pushingTask = taskFactory.StartNew(() =>
{
using var lcr = TestUtils.CreateRequest();
Task.Delay(TimeSpan.FromSeconds(2)).Wait();
Task.Delay(TimeSpan.FromSeconds(5)).Wait();
Copy link
Contributor

Choose a reason for hiding this comment

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

Might want to choose smaller time constants here, as this affects the CI runtime

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@Vijay-Nirmal
Copy link
Contributor Author

Fixed all review commands

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.

2 participants