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

Replaced temp dicts with hashtable in hrandfieldWithCountCommand. #1793

Open
wants to merge 4 commits into
base: unstable
Choose a base branch
from

Conversation

zarkash-aws
Copy link
Contributor

This PR resolves #1550 by replacing the use of temporary dict structures with hashtable in hrandfieldWithCountCommand.

Notes:
CASE 3: Replaced sdsReplyDictType with hashHashtableType to efficiently store field-value pairs using hashTypeEntry.
CASE 4: Replaced hashDictType with setHashtableType, as only the field needs to be stored.

@zarkash-aws zarkash-aws marked this pull request as draft February 27, 2025 13:43
@zarkash-aws zarkash-aws force-pushed the replace_temp_dicts_with_hashtable branch from da5d9a1 to d0bf28c Compare March 19, 2025 13:53
Copy link

codecov bot commented Mar 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.05%. Comparing base (d56a1f7) to head (4c2d2f0).

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1793      +/-   ##
============================================
- Coverage     71.06%   71.05%   -0.02%     
============================================
  Files           123      123              
  Lines         65671    65665       -6     
============================================
- Hits          46669    46655      -14     
- Misses        19002    19010       +8     
Files with missing lines Coverage Δ
src/t_hash.c 96.34% <100.00%> (+0.10%) ⬆️

... and 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zarkash-aws
Copy link
Contributor Author

zarkash-aws commented Mar 23, 2025

update -
In CASE 3: Changed hashtable type from hashHashtableType to sdsReplyHashtableType. Updated hashtable to store a pointer to the hashtype entries instead of storing entries directly. This simplifies handling of the 'withvalue' case, as it no longer requires explicitly providing a value to create an entry.

@zarkash-aws zarkash-aws marked this pull request as ready for review March 23, 2025 10:38
Signed-off-by: Shai Zarka <[email protected]>
/* Add all the elements into the temporary hashtable. */
while (hashTypeNext(&hi) != C_ERR) {
int ret = 0;
ret = hashtableAdd(ht, (&hi)->next);
Copy link
Member

Choose a reason for hiding this comment

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

why not
ret = hashtableAdd(ht, hi.entry);
?

This code can be reduce to:

        while (hashTypeNext(&hi) != C_ERR) {
            serverAssert(hashtableAdd(ht, hi.next));
        }

if (withvalues && c->resp > 2) addWritePreparedReplyArrayLen(wpc, 2);
addWritePreparedReplyBulkSds(wpc, field);
if (withvalues) addWritePreparedReplyBulkSds(wpc, value);
addWritePreparedReplyBulkSds(wpc, sdsdup(field));
Copy link
Member

Choose a reason for hiding this comment

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

Consider removing addWritePreparedReplyBulkSds and use addReplyBulkCBuffer instead, no sdsdup is needed

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.

Follow-up of #1502: Replace temp dicts with hashtable
2 participants