Skip to content

Commit 915580d

Browse files
committed
fix: clang-format code
1 parent 6f18dbd commit 915580d

7 files changed

Lines changed: 460 additions & 482 deletions

File tree

src/commands/cmd_topk.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*
1919
*/
2020

21-
#include "commander.h"
2221
#include "command_parser.h"
22+
#include "commander.h"
2323
#include "error_constants.h"
2424
#include "server/server.h"
2525
#include "types/redis_topk.h"
@@ -30,7 +30,7 @@ constexpr const char *errBadWidth = "Bad width";
3030
constexpr const char *errBadDepth = "Bad depth";
3131
constexpr const char *errBadDecay = "Bad decay";
3232
constexpr const char *errInvalidDecay = "Decay must be between 0 and 1";
33-
}
33+
} // namespace
3434

3535
namespace redis {
3636

@@ -84,6 +84,7 @@ class CommandTopKReserve final : public Commander {
8484
*output = redis::RESP_OK;
8585
return Status::OK();
8686
}
87+
8788
private:
8889
uint32_t k_;
8990
uint32_t width_ = 7;
@@ -150,7 +151,7 @@ class CommandTopKInfo final : public Commander {
150151
return Commander::Parse(args);
151152
}
152153

153-
Status Execute(engine::Context &ctx, Server *srv, Connection *conn, [[maybe_unused]]std::string *output) override {
154+
Status Execute(engine::Context &ctx, Server *srv, Connection *conn, std::string *output) override {
154155
redis::TopK topk_db(srv->storage, conn->GetNamespace());
155156
TopKInfo info;
156157

@@ -185,6 +186,7 @@ class CommandTopKInfo final : public Commander {
185186
}
186187
return Status::OK();
187188
}
189+
188190
private:
189191
TopKInfoType type_ = TopKInfoType::kAll;
190192
};
@@ -199,7 +201,7 @@ class CommandTopKQuery final : public Commander {
199201
auto s = topk.Query(ctx, args_[1], args_[2], &is_exists_);
200202
if (!s.ok()) {
201203
return {Status::RedisExecErr, s.ToString()};
202-
}
204+
}
203205
*output = redis::Bool(redis::RESP::v2, is_exists_);
204206
return Status::OK();
205207
}
@@ -211,4 +213,4 @@ REDIS_REGISTER_COMMANDS(TopK, MakeCmdAttr<CommandTopKAdd>("topk.add", 3, "write"
211213
MakeCmdAttr<CommandTopKQuery>("topk.query", 3, "read-only", 1, 1, 1),
212214
MakeCmdAttr<CommandTopKReserve>("topk.reserve", -3, "write", 1, 1, 1));
213215

214-
} // namespace redis
216+
} // namespace redis

src/storage/redis_metadata.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ enum RedisType : uint8_t {
5959
};
6060

6161
inline constexpr const std::array<std::string_view, kRedisTypeMax> RedisTypeNames = {
62-
"none", "string", "hash", "list", "set", "zset", "bitmap",
63-
"sortedint", "stream", "MBbloom--", "ReJSON-RL", "hyperloglog", "TDIS-TYPE", "timeseries",
64-
"topk"};
62+
"none", "string", "hash", "list", "set", "zset", "bitmap", "sortedint",
63+
"stream", "MBbloom--", "ReJSON-RL", "hyperloglog", "TDIS-TYPE", "timeseries", "topk"};
6564

6665
struct RedisTypes {
6766
RedisTypes(std::initializer_list<RedisType> list) {
@@ -413,20 +412,16 @@ class TimeSeriesMetadata : public Metadata {
413412
};
414413

415414
class TopKMetadata : public Metadata {
416-
public:
415+
public:
417416
uint32_t top_k;
418417
uint16_t width;
419418
uint32_t depth;
420419
double decay;
421420

422421
explicit TopKMetadata(bool generate_version = true) : Metadata(kRedisTopK, generate_version) {}
423422

424-
TopKMetadata(uint64_t top_k, uint64_t width = 7, uint64_t depth = 8, double decay = 0.9, bool generate_version = true)
425-
: Metadata(kRedisTopK, generate_version),
426-
top_k(top_k),
427-
width(width),
428-
depth(depth),
429-
decay(decay) {}
423+
TopKMetadata(uint64_t top_k, uint64_t width = 7, uint64_t depth = 8, double decay = 0.9, bool generate_version = true)
424+
: Metadata(kRedisTopK, generate_version), top_k(top_k), width(width), depth(depth), decay(decay) {}
430425

431426
void Encode(std::string *dst) const override;
432427
rocksdb::Status Decode(Slice *input) override;

0 commit comments

Comments
 (0)