Skip to content

Commit

Permalink
Refactor source file structure (#989)
Browse files Browse the repository at this point in the history
  • Loading branch information
PragmaTwice committed Oct 17, 2022
1 parent e79871a commit 17d5fd7
Show file tree
Hide file tree
Showing 131 changed files with 160 additions and 160 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ find_library(FOUND_UNWIND_LIB unwind)
set(WARNING_FLAGS -Wall -Wpedantic -Wsign-compare -Wreturn-type)

# kvrocks objects target
file(GLOB KVROCKS_SRCS src/*.cc)
file(GLOB_RECURSE KVROCKS_SRCS src/*.cc)
list(FILTER KVROCKS_SRCS EXCLUDE REGEX src/main.cc)

add_library(kvrocks_objs OBJECT ${KVROCKS_SRCS})

target_include_directories(kvrocks_objs PUBLIC src ${PROJECT_BINARY_DIR})
target_include_directories(kvrocks_objs PUBLIC src src/common ${PROJECT_BINARY_DIR})
target_compile_features(kvrocks_objs PUBLIC cxx_std_11)
target_compile_options(kvrocks_objs PUBLIC ${WARNING_FLAGS} -fno-omit-frame-pointer)
target_link_libraries(kvrocks_objs PUBLIC -fno-omit-frame-pointer)
Expand Down
4 changes: 2 additions & 2 deletions src/cluster.cc → src/cluster/cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
#include <cstring>
#include <memory>

#include "commands/redis_cmd.h"
#include "parse_util.h"
#include "redis_cmd.h"
#include "replication.h"
#include "server.h"
#include "server/server.h"
#include "util.h"

const char *errInvalidNodeID = "Invalid cluster node id";
Expand Down
4 changes: 2 additions & 2 deletions src/cluster.h → src/cluster/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
#include <unordered_map>
#include <vector>

#include "redis_cmd.h"
#include "redis_connection.h"
#include "commands/redis_cmd.h"
#include "redis_slot.h"
#include "rw_lock.h"
#include "server/redis_connection.h"
#include "status.h"

enum {
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/replication.cc → src/cluster/replication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@

#include "event_util.h"
#include "fd_util.h"
#include "redis_reply.h"
#include "rocksdb_crc32c.h"
#include "server.h"
#include "server/redis_reply.h"
#include "server/server.h"
#include "status.h"
#include "util.h"

Expand Down
4 changes: 2 additions & 2 deletions src/replication.h → src/cluster/replication.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
#include <utility>
#include <vector>

#include "redis_connection.h"
#include "server/redis_connection.h"
#include "status.h"
#include "storage.h"
#include "storage/storage.h"

class Server;

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/slot_import.h → src/cluster/slot_import.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include <string>
#include <vector>

#include "config.h"
#include "redis_db.h"
#include "server.h"
#include "config/config.h"
#include "server/server.h"
#include "storage/redis_db.h"

enum ImportStatus {
kImportStart,
Expand Down
2 changes: 1 addition & 1 deletion src/slot_migrate.cc → src/cluster/slot_migrate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include <memory>
#include <utility>

#include "batch_extractor.h"
#include "event_util.h"
#include "storage/batch_extractor.h"

static std::map<RedisType, std::string> type_to_cmd = {
{kRedisString, "set"}, {kRedisList, "rpush"}, {kRedisHash, "hmset"}, {kRedisSet, "sadd"},
Expand Down
6 changes: 3 additions & 3 deletions src/slot_migrate.h → src/cluster/slot_migrate.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
#include "config.h"
#include "encoding.h"
#include "parse_util.h"
#include "redis_db.h"
#include "redis_slot.h"
#include "server.h"
#include "server/server.h"
#include "slot_import.h"
#include "stats.h"
#include "stats/stats.h"
#include "status.h"
#include "storage/redis_db.h"
#include "util.h"

constexpr const auto CLUSTER_SLOTS = HASH_SLOTS_SIZE;
Expand Down
44 changes: 22 additions & 22 deletions src/redis_cmd.cc → src/commands/redis_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,30 @@
#include <unordered_map>
#include <utility>

#include "cluster.h"
#include "cluster/cluster.h"
#include "cluster/redis_slot.h"
#include "cluster/slot_import.h"
#include "cluster/slot_migrate.h"
#include "fd_util.h"
#include "log_collector.h"
#include "parse_util.h"
#include "redis_bitmap.h"
#include "redis_connection.h"
#include "redis_db.h"
#include "redis_disk.h"
#include "redis_geo.h"
#include "redis_hash.h"
#include "redis_list.h"
#include "redis_pubsub.h"
#include "redis_reply.h"
#include "redis_set.h"
#include "redis_slot.h"
#include "redis_sortedint.h"
#include "redis_stream.h"
#include "redis_string.h"
#include "redis_zset.h"
#include "scripting.h"
#include "server.h"
#include "slot_import.h"
#include "slot_migrate.h"
#include "storage.h"
#include "server/redis_connection.h"
#include "server/redis_reply.h"
#include "server/server.h"
#include "stats/disk_stats.h"
#include "stats/log_collector.h"
#include "storage/redis_db.h"
#include "storage/redis_pubsub.h"
#include "storage/scripting.h"
#include "storage/storage.h"
#include "types/redis_bitmap.h"
#include "types/redis_geo.h"
#include "types/redis_hash.h"
#include "types/redis_list.h"
#include "types/redis_set.h"
#include "types/redis_sortedint.h"
#include "types/redis_stream.h"
#include "types/redis_string.h"
#include "types/redis_zset.h"
#include "util.h"

namespace Redis {
Expand Down
2 changes: 1 addition & 1 deletion src/redis_cmd.h → src/commands/redis_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <utility>
#include <vector>

#include "redis_reply.h"
#include "server/redis_reply.h"
#include "status.h"

class Server;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/config.cc → src/config/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
#include "config_type.h"
#include "config_util.h"
#include "parse_util.h"
#include "server.h"
#include "server/server.h"
#include "server/tls_util.h"
#include "status.h"
#include "tls_util.h"
#include "util.h"

const char *kDefaultNamespace = "__namespace";
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

#include "config.h"
#include "fd_util.h"
#include "server.h"
#include "storage.h"
#include "server/server.h"
#include "storage/storage.h"
#include "util.h"
#include "version.h"

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/redis_connection.h → src/server/redis_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <utility>
#include <vector>

#include "redis_cmd.h"
#include "commands/redis_cmd.h"
#include "redis_request.h"

class Worker;
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/redis_request.cc → src/server/redis_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
#include <memory>
#include <utility>

#include "cluster/redis_slot.h"
#include "event_util.h"
#include "parse_util.h"
#include "redis_connection.h"
#include "redis_reply.h"
#include "redis_slot.h"
#include "server.h"
#include "util.h"

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/server.cc → src/server/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
#include <memory>
#include <utility>

#include "compaction_checker.h"
#include "config.h"
#include "redis_connection.h"
#include "redis_db.h"
#include "redis_request.h"
#include "scripting.h"
#include "storage/compaction_checker.h"
#include "storage/redis_db.h"
#include "storage/scripting.h"
#include "tls_util.h"
#include "util.h"
#include "version.h"
Expand Down
16 changes: 8 additions & 8 deletions src/server.h → src/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
#include <utility>
#include <vector>

#include "cluster.h"
#include "log_collector.h"
#include "cluster/cluster.h"
#include "cluster/replication.h"
#include "cluster/slot_import.h"
#include "cluster/slot_migrate.h"
#include "lua.hpp"
#include "redis_metadata.h"
#include "replication.h"
#include "rw_lock.h"
#include "slot_import.h"
#include "slot_migrate.h"
#include "stats.h"
#include "storage.h"
#include "stats/log_collector.h"
#include "stats/stats.h"
#include "storage/redis_metadata.h"
#include "storage/storage.h"
#include "task_runner.h"
#include "tls_util.h"
#include "worker.h"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/tls_util.h → src/server/tls_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include <memory>

#include "config.h"
#include "config/config.h"
#include "event_util.h"

void InitSSL();
Expand Down
2 changes: 1 addition & 1 deletion src/worker.cc → src/server/worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

#include "redis_connection.h"
#include "redis_request.h"
#include "scripting.h"
#include "server.h"
#include "storage/scripting.h"
#include "util.h"

Worker::Worker(Server *svr, Config *config, bool repl) : svr_(svr) {
Expand Down
2 changes: 1 addition & 1 deletion src/worker.h → src/server/worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <vector>

#include "redis_connection.h"
#include "storage.h"
#include "storage/storage.h"

class Server;

Expand Down
10 changes: 5 additions & 5 deletions src/redis_disk.cc → src/stats/disk_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
*/

#include "redis_disk.h"
#include "disk_stats.h"

#include <algorithm>
#include <memory>
Expand All @@ -27,12 +27,12 @@
#include <vector>

#include "db_util.h"
#include "redis_bitmap.h"
#include "redis_metadata.h"
#include "redis_sortedint.h"
#include "redis_zset.h"
#include "rocksdb/status.h"
#include "status.h"
#include "storage/redis_metadata.h"
#include "types/redis_bitmap.h"
#include "types/redis_sortedint.h"
#include "types/redis_zset.h"

namespace Redis {

Expand Down
4 changes: 2 additions & 2 deletions src/redis_disk.h → src/stats/disk_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

#include <string>

#include "redis_db.h"
#include "redis_metadata.h"
#include "storage/redis_db.h"
#include "storage/redis_metadata.h"

namespace Redis {

Expand Down
2 changes: 1 addition & 1 deletion src/log_collector.cc → src/stats/log_collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <algorithm>

#include "redis_reply.h"
#include "server/redis_reply.h"

std::string SlowEntry::ToRedisString() {
std::string output;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions src/batch_extractor.cc → src/storage/batch_extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
#include <glog/logging.h>
#include <rocksdb/write_batch.h>

#include "cluster/redis_slot.h"
#include "parse_util.h"
#include "redis_bitmap.h"
#include "redis_reply.h"
#include "redis_slot.h"
#include "server.h"
#include "server/redis_reply.h"
#include "server/server.h"
#include "types/redis_bitmap.h"

void WriteBatchExtractor::LogData(const rocksdb::Slice &blob) {
// Currently, we only have two kinds of log data
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/compact_filter.cc → src/storage/compact_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <string>
#include <utility>

#include "redis_bitmap.h"
#include "types/redis_bitmap.h"

namespace Engine {
using rocksdb::Slice;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/redis_db.cc → src/storage/redis_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
#include <ctime>
#include <map>

#include "cluster/redis_slot.h"
#include "db_util.h"
#include "parse_util.h"
#include "redis_slot.h"
#include "rocksdb/iterator.h"
#include "server.h"
#include "server/server.h"
#include "util.h"

namespace Redis {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/redis_metadata.cc → src/storage/redis_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <ctime>
#include <vector>

#include "redis_slot.h"
#include "cluster/redis_slot.h"

// 52 bit for microseconds and 11 bit for counter
const int VersionCounterBits = 11;
Expand Down
2 changes: 1 addition & 1 deletion src/redis_metadata.h → src/storage/redis_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <vector>

#include "encoding.h"
#include "redis_stream_base.h"
#include "types/redis_stream_base.h"

enum RedisType {
kRedisNone,
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/scripting.cc → src/storage/scripting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@

#include <string>

#include "commands/redis_cmd.h"
#include "rand.h"
#include "redis_cmd.h"
#include "redis_connection.h"
#include "server.h"
#include "server/redis_connection.h"
#include "server/server.h"
#include "sha1.h"
#include "util.h"

Expand Down
Loading

0 comments on commit 17d5fd7

Please sign in to comment.