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
7fe71894
Commit
7fe71894
authored
Apr 05, 2023
by
Vitaly Arbuzov
Browse files
Rename binary_index to slot_size_index
parent
4b5cecc7
Changes
3
Show whitespace changes
Inline
Side-by-side
src/db.c
View file @
7fe71894
...
@@ -402,7 +402,7 @@ void cumulativeKeyCountAdd(redisDb *db, int slot, long delta) {
...
@@ -402,7 +402,7 @@ void cumulativeKeyCountAdd(redisDb *db, int slot, long delta) {
if
(
!
server
.
cluster_enabled
)
return
;
if
(
!
server
.
cluster_enabled
)
return
;
int
idx
=
slot
+
1
;
/* Unlike slots, BIT is 1-based, so we need to add 1. */
int
idx
=
slot
+
1
;
/* Unlike slots, BIT is 1-based, so we need to add 1. */
while
(
idx
<=
CLUSTER_SLOTS
)
{
while
(
idx
<=
CLUSTER_SLOTS
)
{
db
->
binary
_index
[
idx
]
+=
delta
;
db
->
slot_size
_index
[
idx
]
+=
delta
;
idx
+=
(
idx
&
-
idx
);
idx
+=
(
idx
&
-
idx
);
}
}
}
}
...
@@ -417,7 +417,7 @@ unsigned long long cumulativeKeyCountRead(redisDb *db, int slot) {
...
@@ -417,7 +417,7 @@ unsigned long long cumulativeKeyCountRead(redisDb *db, int slot) {
int
idx
=
slot
+
1
;
int
idx
=
slot
+
1
;
unsigned
long
long
sum
=
0
;
unsigned
long
long
sum
=
0
;
while
(
idx
>
0
)
{
while
(
idx
>
0
)
{
sum
+=
db
->
binary
_index
[
idx
];
sum
+=
db
->
slot_size
_index
[
idx
];
idx
-=
(
idx
&
-
idx
);
idx
-=
(
idx
&
-
idx
);
}
}
return
sum
;
return
sum
;
...
@@ -590,8 +590,8 @@ long long emptyDbStructure(redisDb *dbarray, int dbnum, int async,
...
@@ -590,8 +590,8 @@ long long emptyDbStructure(redisDb *dbarray, int dbnum, int async,
dbarray
[
j
].
resize_cursor
=
0
;
dbarray
[
j
].
resize_cursor
=
0
;
dbarray
[
j
].
key_count
=
0
;
dbarray
[
j
].
key_count
=
0
;
if
(
server
.
cluster_enabled
)
{
if
(
server
.
cluster_enabled
)
{
zfree
(
dbarray
[
j
].
binary
_index
);
zfree
(
dbarray
[
j
].
slot_size
_index
);
dbarray
[
j
].
binary
_index
=
zcalloc
(
sizeof
(
unsigned
long
long
)
*
(
CLUSTER_SLOTS
+
1
));
dbarray
[
j
].
slot_size
_index
=
zcalloc
(
sizeof
(
unsigned
long
long
)
*
(
CLUSTER_SLOTS
+
1
));
}
}
}
}
...
@@ -660,7 +660,7 @@ redisDb *initTempDb(void) {
...
@@ -660,7 +660,7 @@ redisDb *initTempDb(void) {
tempDb
[
i
].
dict_count
=
(
server
.
cluster_enabled
)
?
CLUSTER_SLOTS
:
1
;
tempDb
[
i
].
dict_count
=
(
server
.
cluster_enabled
)
?
CLUSTER_SLOTS
:
1
;
tempDb
[
i
].
dict
=
dictCreateMultiple
(
&
dbDictType
,
tempDb
[
i
].
dict_count
);
tempDb
[
i
].
dict
=
dictCreateMultiple
(
&
dbDictType
,
tempDb
[
i
].
dict_count
);
tempDb
[
i
].
expires
=
dictCreate
(
&
dbExpiresDictType
);
tempDb
[
i
].
expires
=
dictCreate
(
&
dbExpiresDictType
);
tempDb
[
i
].
binary
_index
=
server
.
cluster_enabled
?
zcalloc
(
sizeof
(
unsigned
long
long
)
*
(
CLUSTER_SLOTS
+
1
))
:
NULL
;
tempDb
[
i
].
slot_size
_index
=
server
.
cluster_enabled
?
zcalloc
(
sizeof
(
unsigned
long
long
)
*
(
CLUSTER_SLOTS
+
1
))
:
NULL
;
}
}
return
tempDb
;
return
tempDb
;
...
@@ -679,7 +679,7 @@ void discardTempDb(redisDb *tempDb, void(callback)(dict*)) {
...
@@ -679,7 +679,7 @@ void discardTempDb(redisDb *tempDb, void(callback)(dict*)) {
zfree
(
tempDb
[
i
].
dict
);
zfree
(
tempDb
[
i
].
dict
);
dictRelease
(
tempDb
[
i
].
expires
);
dictRelease
(
tempDb
[
i
].
expires
);
if
(
server
.
cluster_enabled
)
{
if
(
server
.
cluster_enabled
)
{
zfree
(
tempDb
[
i
].
binary
_index
);
zfree
(
tempDb
[
i
].
slot_size
_index
);
}
}
}
}
...
@@ -1625,7 +1625,7 @@ int dbSwapDatabases(int id1, int id2) {
...
@@ -1625,7 +1625,7 @@ int dbSwapDatabases(int id1, int id2) {
db1
->
resize_cursor
=
db2
->
resize_cursor
;
db1
->
resize_cursor
=
db2
->
resize_cursor
;
db1
->
dict_count
=
db2
->
dict_count
;
db1
->
dict_count
=
db2
->
dict_count
;
db1
->
key_count
=
db2
->
key_count
;
db1
->
key_count
=
db2
->
key_count
;
db1
->
binary
_index
=
db2
->
binary
_index
;
db1
->
slot_size
_index
=
db2
->
slot_size
_index
;
db2
->
dict
=
aux
.
dict
;
db2
->
dict
=
aux
.
dict
;
db2
->
expires
=
aux
.
expires
;
db2
->
expires
=
aux
.
expires
;
...
@@ -1634,7 +1634,7 @@ int dbSwapDatabases(int id1, int id2) {
...
@@ -1634,7 +1634,7 @@ int dbSwapDatabases(int id1, int id2) {
db2
->
resize_cursor
=
aux
.
resize_cursor
;
db2
->
resize_cursor
=
aux
.
resize_cursor
;
db2
->
dict_count
=
aux
.
dict_count
;
db2
->
dict_count
=
aux
.
dict_count
;
db2
->
key_count
=
aux
.
key_count
;
db2
->
key_count
=
aux
.
key_count
;
db2
->
binary
_index
=
aux
.
binary
_index
;
db2
->
slot_size
_index
=
aux
.
slot_size
_index
;
/* Now we need to handle clients blocked on lists: as an effect
/* Now we need to handle clients blocked on lists: as an effect
* of swapping the two DBs, a client that was waiting for list
* of swapping the two DBs, a client that was waiting for list
...
@@ -1675,7 +1675,7 @@ void swapMainDbWithTempDb(redisDb *tempDb) {
...
@@ -1675,7 +1675,7 @@ void swapMainDbWithTempDb(redisDb *tempDb) {
activedb
->
resize_cursor
=
newdb
->
resize_cursor
;
activedb
->
resize_cursor
=
newdb
->
resize_cursor
;
activedb
->
dict_count
=
newdb
->
dict_count
;
activedb
->
dict_count
=
newdb
->
dict_count
;
activedb
->
key_count
=
newdb
->
key_count
;
activedb
->
key_count
=
newdb
->
key_count
;
activedb
->
binary
_index
=
newdb
->
binary
_index
;
activedb
->
slot_size
_index
=
newdb
->
slot_size
_index
;
newdb
->
dict
=
aux
.
dict
;
newdb
->
dict
=
aux
.
dict
;
newdb
->
expires
=
aux
.
expires
;
newdb
->
expires
=
aux
.
expires
;
...
@@ -1684,7 +1684,7 @@ void swapMainDbWithTempDb(redisDb *tempDb) {
...
@@ -1684,7 +1684,7 @@ void swapMainDbWithTempDb(redisDb *tempDb) {
newdb
->
resize_cursor
=
aux
.
resize_cursor
;
newdb
->
resize_cursor
=
aux
.
resize_cursor
;
newdb
->
dict_count
=
aux
.
dict_count
;
newdb
->
dict_count
=
aux
.
dict_count
;
newdb
->
key_count
=
aux
.
key_count
;
newdb
->
key_count
=
aux
.
key_count
;
newdb
->
binary
_index
=
aux
.
binary
_index
;
newdb
->
slot_size
_index
=
aux
.
slot_size
_index
;
/* Now we need to handle clients blocked on lists: as an effect
/* Now we need to handle clients blocked on lists: as an effect
* of swapping the two DBs, a client that was waiting for list
* of swapping the two DBs, a client that was waiting for list
...
...
src/server.c
View file @
7fe71894
...
@@ -2635,7 +2635,7 @@ void initServer(void) {
...
@@ -2635,7 +2635,7 @@ void initServer(void) {
server
.
db
[
j
].
rehashing
=
listCreate
();
server
.
db
[
j
].
rehashing
=
listCreate
();
server
.
db
[
j
].
dict_count
=
slotCount
;
server
.
db
[
j
].
dict_count
=
slotCount
;
server
.
db
[
j
].
key_count
=
0
;
server
.
db
[
j
].
key_count
=
0
;
server
.
db
[
j
].
binary
_index
=
server
.
cluster_enabled
?
zcalloc
(
sizeof
(
unsigned
long
long
)
*
(
CLUSTER_SLOTS
+
1
))
:
NULL
;
server
.
db
[
j
].
slot_size
_index
=
server
.
cluster_enabled
?
zcalloc
(
sizeof
(
unsigned
long
long
)
*
(
CLUSTER_SLOTS
+
1
))
:
NULL
;
listSetFreeMethod
(
server
.
db
[
j
].
defrag_later
,(
void
(
*
)(
void
*
))
sdsfree
);
listSetFreeMethod
(
server
.
db
[
j
].
defrag_later
,(
void
(
*
)(
void
*
))
sdsfree
);
}
}
evictionPoolAlloc
();
/* Initialize the LRU keys pool. */
evictionPoolAlloc
();
/* Initialize the LRU keys pool. */
...
...
src/server.h
View file @
7fe71894
...
@@ -975,7 +975,7 @@ typedef struct redisDb {
...
@@ -975,7 +975,7 @@ typedef struct redisDb {
list
*
rehashing
;
/* List of dictionaries in this DB that are currently rehashing. */
list
*
rehashing
;
/* List of dictionaries in this DB that are currently rehashing. */
int
dict_count
;
/* Indicates total number of dictionaires owned by this DB, 1 dict per slot in cluster mode. */
int
dict_count
;
/* Indicates total number of dictionaires owned by this DB, 1 dict per slot in cluster mode. */
unsigned
long
long
key_count
;
/* Total number of keys in this DB. */
unsigned
long
long
key_count
;
/* Total number of keys in this DB. */
unsigned
long
long
*
binary
_index
;
/* Binary indexed tree (BIT) that describes cumulative key frequencies up until given slot. */
unsigned
long
long
*
slot_size
_index
;
/* Binary indexed tree (BIT) that describes cumulative key frequencies up until given slot. */
}
redisDb
;
}
redisDb
;
/* forward declaration for functions ctx */
/* forward declaration for functions ctx */
...
...
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