Commit a871d66e authored by Vitaly Arbuzov's avatar Vitaly Arbuzov
Browse files

Rename and move slot mask related constants

parent 42b10b44
......@@ -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 */
......
......@@ -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;
}
......
......@@ -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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment