Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
383737a9
Commit
383737a9
authored
Jan 12, 2023
by
Vitaly Arbuzov
Browse files
Use LSB for saving slot in SCAN cursor
parent
6fbafbe9
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/db.c
View file @
383737a9
...
@@ -1016,7 +1016,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long long cursor) {
...
@@ -1016,7 +1016,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long long cursor) {
if
(
o
==
NULL
&&
!
cursor
)
{
if
(
o
==
NULL
&&
!
cursor
)
{
ht
=
dbGetNextUnvisitedSlot
(
c
->
db
,
&
slot
);
ht
=
dbGetNextUnvisitedSlot
(
c
->
db
,
&
slot
);
}
}
}
while
((
cursor
||
slot
>
0
)
&&
}
while
((
cursor
||
slot
>
0
)
&&
/* Continue iteration if there are more slots to visit, or cursor hasn't reached the end of dict yet. */
maxiterations
--
&&
maxiterations
--
&&
listLength
(
keys
)
<
(
unsigned
long
)
count
);
listLength
(
keys
)
<
(
unsigned
long
)
count
);
addSlotIdToCursor
(
slot
,
&
cursor
);
addSlotIdToCursor
(
slot
,
&
cursor
);
...
@@ -1124,14 +1124,14 @@ cleanup:
...
@@ -1124,14 +1124,14 @@ cleanup:
}
}
void
addSlotIdToCursor
(
int
slot
,
unsigned
long
long
int
*
cursor
)
{
void
addSlotIdToCursor
(
int
slot
,
unsigned
long
long
int
*
cursor
)
{
if
(
slot
>
0
)
{
if
(
slot
>
=
0
)
{
(
*
cursor
)
|=
((
unsigned
long
long
)
slot
)
<<
SLOT_MASK_SHIFT
;
*
cursor
=
(
*
cursor
<<
SLOT_MASK_SHIFT
)
|
slot
;
}
}
}
}
int
getAndClearSlotIdFromCursor
(
unsigned
long
long
int
*
cursor
)
{
int
getAndClearSlotIdFromCursor
(
unsigned
long
long
int
*
cursor
)
{
int
slot
=
(
int
)
(
(
*
cursor
&
SLOT_MASK
)
>>
SLOT_MASK_SHIFT
)
;
int
slot
=
(
int
)
(
*
cursor
&
SLOT_MASK
);
(
*
cursor
)
=
(
*
cursor
)
&
~
SLOT_MASK
;
*
cursor
=
(
(
*
cursor
)
&
~
SLOT_MASK
)
>>
SLOT_MASK_SHIFT
;
return
slot
;
return
slot
;
}
}
...
...
src/server.h
View file @
383737a9
...
@@ -3113,8 +3113,8 @@ sds keyspaceEventsFlagsToString(int flags);
...
@@ -3113,8 +3113,8 @@ sds keyspaceEventsFlagsToString(int flags);
#define MEMORY_CONFIG (1<<0)
/* Indicates if this value can be loaded as a memory value */
#define MEMORY_CONFIG (1<<0)
/* Indicates if this value can be loaded as a memory value */
#define PERCENT_CONFIG (1<<1)
/* Indicates if this value can be loaded as a percent (and stored as a negative int) */
#define PERCENT_CONFIG (1<<1)
/* Indicates if this value can be loaded as a percent (and stored as a negative int) */
#define OCTAL_CONFIG (1<<2)
/* This value uses octal representation */
#define OCTAL_CONFIG (1<<2)
/* This value uses octal representation */
#define SLOT_MASK_SHIFT 4
8
/* Slot id is stored in
high
bits of the Scan API cursor, this number defines by how many bits it's shifted. */
#define SLOT_MASK_SHIFT
1
4
/* Slot id is stored in
low
bits of the Scan API cursor, this number defines by how many bits it's shifted. */
#define SLOT_MASK ((unsigned long long)(CLUSTER_SLOTS - 1)
<< SLOT_MASK_SHIFT
)
#define SLOT_MASK ((unsigned long long)(CLUSTER_SLOTS - 1))
/* Enum Configs contain an array of configEnum objects that match a string with an integer. */
/* Enum Configs contain an array of configEnum objects that match a string with an integer. */
typedef
struct
configEnum
{
typedef
struct
configEnum
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment