Skip to content

Commit ca04900

Browse files
Merge branch 'unstable' into unstable
2 parents 43959d5 + e19164f commit ca04900

File tree

26 files changed

+478
-118
lines changed

26 files changed

+478
-118
lines changed

.github/workflows/kvrocks.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,17 @@ jobs:
239239
FORCE_JAVASCRIPT_ACTIONS_TO_NODE20: true
240240
RISCV_PATH: "/opt/riscv"
241241
steps:
242+
- name: Maximize build space
243+
if: ${{ matrix.riscv_toolchain }}
244+
run: |
245+
# refer to https://github.com/easimon/maximize-build-space,
246+
# we take some ideas from this action but don't use it directly.
247+
sudo df -h
248+
sudo rm -rf /usr/share/dotnet
249+
sudo rm -rf /usr/local/lib/android
250+
sudo rm -rf /opt/ghc
251+
sudo df -h
252+
242253
- name: Setup macOS
243254
if: ${{ startsWith(matrix.os, 'macos') }}
244255
run: |
@@ -272,6 +283,7 @@ jobs:
272283
sudo mkdir -p $RISCV_PATH
273284
wget "${{ matrix.riscv_toolchain_url }}" -O riscv-toolchain.tar.xz
274285
sudo tar -xvf riscv-toolchain.tar.xz -C $RISCV_PATH --strip-components=1
286+
rm riscv-toolchain.tar.xz
275287
sudo sed -i "s|libdir='/mnt/riscv/riscv64-unknown-linux-gnu/lib'|libdir='$RISCV_PATH/riscv64-unknown-linux-gnu/lib'|g" \
276288
$RISCV_PATH/riscv64-unknown-linux-gnu/lib/libatomic.la
277289
echo "PATH=$RISCV_PATH/bin:$PATH" >> $GITHUB_ENV
@@ -491,9 +503,10 @@ jobs:
491503
- name: ArchLinux
492504
image: archlinux:base
493505
compiler: gcc
494-
- name: Rocky Linux 8
495-
image: rockylinux:8
496-
compiler: gcc
506+
# FIXME: disable it due to "No space left on device" issue
507+
# - name: Rocky Linux 8
508+
# image: rockylinux:8
509+
# compiler: gcc
497510
- name: Rocky Linux 9
498511
image: rockylinux:9
499512
compiler: gcc

.gitignore

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
*.gch
1212
*.pch
1313

14+
# Linker files
15+
*.ilk
16+
17+
# Debugger Files
18+
*.pdb
19+
1420
# Compiled Dynamic libraries
1521
*.so
1622
*.dylib
@@ -31,19 +37,18 @@
3137
*.out
3238
*.app
3339

34-
*.pyc
35-
*.swp
36-
*.swo
37-
.DS_Store
38-
version.h
40+
# debug information files
41+
*.dwo
3942

40-
.idea
41-
.vscode
42-
.cache
43+
# for macOS
44+
.DS_Store
4345

44-
compactdb
45-
testdb
46+
# for IDEs
47+
/.idea/
48+
/.vscode/
49+
/.cache/
4650

47-
build
48-
cmake-build-*
49-
build-*
51+
# for build directories
52+
/build/
53+
/cmake-build-*/
54+
/build-*/

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@ set(CMAKE_CXX_STANDARD 17)
7373
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7474

7575
set(DEPS_FETCH_PROXY "" CACHE STRING
76-
"a template URL to proxy the traffic for fetching dependencies, e.g. with DEPS_FETCH_PROXY = https://some-proxy/,
76+
"a template URL to proxy the traffic for fetching dependencies,
77+
e.g. with DEPS_FETCH_PROXY = https://some-proxy/,
7778
https://example/some-dep.zip -> https://some-proxy/https://example/some-dep.zip")
79+
set(DEPS_FETCH_DIR "" CACHE PATH
80+
"if specified, dependencies will be downloaded into this directory first,
81+
and reused in subsequent builds")
7882

7983
if(ENABLE_ASAN AND ENABLE_TSAN)
8084
message(FATAL_ERROR "ASan and TSan cannot be used at the same time")

cmake/pegtl.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ include_guard()
1919

2020
include(cmake/utils.cmake)
2121

22-
FetchContent_DeclareGitHubTarWithMirror(pegtl
22+
FetchContent_DeclareGitHubWithMirror(pegtl
2323
taocpp/PEGTL 3.2.8
24-
MD5=50339029d1bb037909b28c382214033e
24+
MD5=5c919edd001ef157b0d25fc9dcc8b3e1
2525
)
2626

2727
FetchContent_MakeAvailableWithArgs(pegtl)

cmake/trie.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ include_guard()
2020
include(cmake/utils.cmake)
2121

2222
FetchContent_DeclareGitHubWithMirror(trie
23-
Tessil/hat-trie 906e6abd1e7063f1dacd3a6b270aa654b525eb0a
24-
MD5=a930364e9f6b60371319664bddf78000
23+
Tessil/hat-trie v0.7.1
24+
MD5=0536f8c1970788863093504441089e6e
2525
)
2626

2727
FetchContent_MakeAvailableWithArgs(trie)

cmake/utils.cmake

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,29 @@ function(FetchContent_MakeAvailableWithArgs dep)
4646
endif()
4747
endfunction()
4848

49-
function(FetchContent_DeclareWithMirror dep url hash)
50-
FetchContent_Declare(${dep}
51-
URL ${DEPS_FETCH_PROXY}${url}
52-
URL_HASH ${hash}
53-
)
54-
endfunction()
55-
5649
function(FetchContent_DeclareGitHubWithMirror dep repo tag hash)
57-
FetchContent_DeclareWithMirror(${dep}
58-
https://github.com/${repo}/archive/${tag}.zip
59-
${hash}
60-
)
61-
endfunction()
50+
set(_dep_fetch_url "${DEPS_FETCH_PROXY}https://github.com/${repo}/archive/${tag}.zip")
51+
if(DEPS_FETCH_DIR)
52+
get_filename_component(_deps_fetch_dir ${DEPS_FETCH_DIR} ABSOLUTE)
53+
set(_dep_fetch_dst ${_deps_fetch_dir}/${dep}-${tag}.zip)
6254

63-
function(FetchContent_DeclareGitHubTarWithMirror dep repo tag hash)
64-
FetchContent_DeclareWithMirror(${dep}
65-
https://github.com/${repo}/archive/${tag}.tar.gz
66-
${hash}
67-
)
55+
if(NOT EXISTS ${_dep_fetch_dst})
56+
message("Downloading ${_dep_fetch_url} to ${_dep_fetch_dst}...")
57+
file(DOWNLOAD ${_dep_fetch_url} ${_dep_fetch_dst} STATUS _dep_download_status)
58+
list(GET _dep_download_status 0 _dep_download_status_code)
59+
if(NOT _dep_download_status_code EQUAL 0)
60+
message(FATAL_ERROR "Failed to download ${_dep_fetch_url} to ${_dep_fetch_dst}")
61+
endif()
62+
endif()
63+
64+
FetchContent_Declare(${dep}
65+
URL ${_dep_fetch_dst}
66+
URL_HASH ${hash}
67+
)
68+
else()
69+
FetchContent_Declare(${dep}
70+
URL ${_dep_fetch_url}
71+
URL_HASH ${hash}
72+
)
73+
endif()
6874
endfunction()

src/cluster/replication.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ void FeedSlaveThread::loop() {
214214
// kMaxDelayUpdates than latest sequence.
215215
if (is_first_repl_batch || batches_bulk.size() >= max_delay_bytes_ || updates_in_batches >= max_delay_updates_ ||
216216
srv_->storage->LatestSeqNumber() - batch.sequence <= max_delay_updates_) {
217-
if (shouldSendGetAck(batch.sequence)) {
217+
// get the last sequence number of the batch, because WAIT uses
218+
// the last sequence number to wake up the connection.
219+
if (shouldSendGetAck(batch.sequence + batch.writeBatchPtr->Count() - 1)) {
218220
batches_bulk += redis::BulkString("_getack");
219221
}
220222

src/commands/cmd_tdigest.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ class CommandTDigestAdd : public Commander {
176176
std::vector<double> values_;
177177
};
178178

179-
class CommandTDigestRevRank : public Commander {
179+
template <bool reverse>
180+
class TDigestRankCommand : public Commander {
180181
public:
181182
Status Parse(const std::vector<std::string> &args) override {
182183
key_name_ = args[1];
@@ -201,7 +202,7 @@ class CommandTDigestRevRank : public Commander {
201202
TDigest tdigest(srv->storage, conn->GetNamespace());
202203
std::vector<int> result;
203204
result.reserve(origin_inputs_.size());
204-
if (const auto s = tdigest.RevRank(ctx, key_name_, unique_inputs_, result); !s.ok()) {
205+
if (const auto s = tdigest.Rank(ctx, key_name_, unique_inputs_, reverse, result); !s.ok()) {
205206
if (s.IsNotFound()) {
206207
return {Status::RedisExecErr, errKeyNotFound};
207208
}
@@ -224,6 +225,10 @@ class CommandTDigestRevRank : public Commander {
224225
std::vector<std::string> origin_inputs_;
225226
};
226227

228+
class CommandTDigestRevRank : public TDigestRankCommand<true> {};
229+
230+
class CommandTDigestRank : public TDigestRankCommand<false> {};
231+
227232
class CommandTDigestMinMax : public Commander {
228233
public:
229234
explicit CommandTDigestMinMax(bool is_min) : is_min_(is_min) {}
@@ -418,6 +423,7 @@ REDIS_REGISTER_COMMANDS(TDigest, MakeCmdAttr<CommandTDigestCreate>("tdigest.crea
418423
MakeCmdAttr<CommandTDigestMax>("tdigest.max", 2, "read-only", 1, 1, 1),
419424
MakeCmdAttr<CommandTDigestMin>("tdigest.min", 2, "read-only", 1, 1, 1),
420425
MakeCmdAttr<CommandTDigestRevRank>("tdigest.revrank", -3, "read-only", 1, 1, 1),
426+
MakeCmdAttr<CommandTDigestRank>("tdigest.rank", -3, "read-only", 1, 1, 1),
421427
MakeCmdAttr<CommandTDigestQuantile>("tdigest.quantile", -3, "read-only", 1, 1, 1),
422428
MakeCmdAttr<CommandTDigestReset>("tdigest.reset", 2, "write", 1, 1, 1),
423429
MakeCmdAttr<CommandTDigestMerge>("tdigest.merge", -4, "write", GetMergeKeyRange));

src/commands/command_parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
template <typename Iter>
3535
struct MoveIterator : Iter {
36-
explicit MoveIterator(Iter iter) : Iter(iter){};
36+
explicit MoveIterator(Iter iter) : Iter(iter) {}
3737

3838
typename Iter::value_type&& operator*() const { return std::move(this->Iter::operator*()); }
3939
};

src/commands/commander.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ namespace redis {
2727

2828
RegisterToCommandTable::RegisterToCommandTable(CommandCategory category,
2929
std::initializer_list<CommandAttributes> list) {
30+
if (category == CommandCategory::Disabled) {
31+
return;
32+
}
33+
3034
for (auto attr : list) {
3135
attr.category = category;
3236
CommandTable::redis_command_table.emplace_back(attr);

0 commit comments

Comments
 (0)