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
a871d66e
Commit
a871d66e
authored
Jan 17, 2023
by
Vitaly Arbuzov
Browse files
Rename and move slot mask related constants
parent
42b10b44
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/cluster.h
View file @
a871d66e
...
...
@@ -5,7 +5,9 @@
* Redis cluster data structures, defines, exported API.
*----------------------------------------------------------------------------*/
#define CLUSTER_SLOTS 16384
#define CLUSTER_SLOT_MASK_BITS 14
/* Number of bits used for slot id.*/
#define CLUSTER_SLOTS (1<<CLUSTER_SLOT_MASK_BITS)
/* Total number of slots in cluster mode. */
#define CLUSTER_SLOT_MASK ((unsigned long long)(CLUSTER_SLOTS - 1))
/* Bit mask for slot id stored in LSB. */
#define CLUSTER_OK 0
/* Everything looks ok */
#define CLUSTER_FAIL 1
/* The cluster can't work */
#define CLUSTER_NAMELEN 40
/* sha1 hex length */
...
...
src/db.c
View file @
a871d66e
...
...
@@ -1125,13 +1125,13 @@ cleanup:
void
addSlotIdToCursor
(
int
slot
,
unsigned
long
long
int
*
cursor
)
{
if
(
slot
>=
0
)
{
*
cursor
=
(
*
cursor
<<
SLOT_MASK_
SHIFT
)
|
slot
;
*
cursor
=
(
*
cursor
<<
CLUSTER_
SLOT_MASK_
BITS
)
|
slot
;
}
}
int
getAndClearSlotIdFromCursor
(
unsigned
long
long
int
*
cursor
)
{
int
slot
=
(
int
)
(
*
cursor
&
SLOT_MASK
);
*
cursor
=
((
*
cursor
)
&
~
SLOT_MASK
)
>>
SLOT_MASK_
SHIFT
;
int
slot
=
(
int
)
(
*
cursor
&
CLUSTER_
SLOT_MASK
);
*
cursor
=
((
*
cursor
)
&
~
CLUSTER_
SLOT_MASK
)
>>
CLUSTER_
SLOT_MASK_
BITS
;
return
slot
;
}
...
...
src/server.h
View file @
a871d66e
...
...
@@ -3113,8 +3113,6 @@ sds keyspaceEventsFlagsToString(int flags);
#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 OCTAL_CONFIG (1<<2)
/* This value uses octal representation */
#define SLOT_MASK_SHIFT 14
/* 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))
/* Enum Configs contain an array of configEnum objects that match a string with an integer. */
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