This is an automated email from the ASF dual-hosted git repository.

twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/incubator-kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new c439f3af Split util.h to more concrete util headers (#1144)
c439f3af is described below

commit c439f3af9d5c7ccb97ff4c7bdab088287acd73cc
Author: Twice <[email protected]>
AuthorDate: Sat Nov 26 20:42:49 2022 +0800

    Split util.h to more concrete util headers (#1144)
---
 src/cluster/cluster.cc                             |   3 +-
 src/cluster/redis_slot.cc                          |   2 -
 src/cluster/replication.cc                         |   3 +-
 src/cluster/slot_migrate.cc                        |   3 +
 src/cluster/slot_migrate.h                         |   1 -
 src/commands/command_parser.h                      |   2 +-
 src/commands/redis_cmd.cc                          |   4 +-
 src/common/{util.cc => io_util.cc}                 | 335 +--------------------
 src/common/{util.h => io_util.h}                   |  40 +--
 src/common/string_util.cc                          | 322 ++++++++++++++++++++
 src/common/{util.h => string_util.h}               |  39 ---
 src/common/task_runner.cc                          |   2 +-
 .../cron_test.cc => src/common/thread_util.cc      |  39 +--
 .../cron_test.cc => src/common/thread_util.h       |  35 +--
 .../cppunit/cron_test.cc => src/common/time_util.h |  38 +--
 src/config/config.cc                               |   1 -
 src/config/config_type.h                           |   2 +-
 src/config/config_util.cc                          |   2 +-
 src/main.cc                                        |   3 +-
 src/server/redis_request.cc                        |   1 -
 src/server/server.cc                               |   3 +-
 src/server/worker.cc                               |   5 +-
 src/stats/stats.cc                                 |   2 +-
 src/storage/compaction_checker.cc                  |   1 +
 src/storage/redis_db.cc                            |   1 -
 src/storage/redis_metadata.cc                      |   2 +-
 src/storage/scripting.cc                           |   1 -
 src/storage/storage.cc                             |   1 +
 src/types/redis_geo.cc                             |   2 -
 src/types/redis_stream_base.cc                     |   2 +-
 src/types/redis_string.cc                          |   1 +
 src/types/redis_zset.cc                            |   1 -
 tests/cppunit/cluster_test.cc                      |   1 -
 tests/cppunit/cron_test.cc                         |   2 -
 tests/cppunit/string_util_test.cc                  |   4 +-
 tests/cppunit/t_stream_test.cc                     |   1 +
 utils/kvrocks2redis/config.cc                      |   1 -
 utils/kvrocks2redis/main.cc                        |   1 +
 utils/kvrocks2redis/redis_writer.cc                |   3 +-
 utils/kvrocks2redis/sync.cc                        |   2 +-
 utils/kvrocks2redis/writer.cc                      |   2 +-
 41 files changed, 393 insertions(+), 523 deletions(-)

diff --git a/src/cluster/cluster.cc b/src/cluster/cluster.cc
index d9bb378b..09b4e2c6 100644
--- a/src/cluster/cluster.cc
+++ b/src/cluster/cluster.cc
@@ -30,7 +30,8 @@
 #include "parse_util.h"
 #include "replication.h"
 #include "server/server.h"
-#include "util.h"
+#include "string_util.h"
+#include "time_util.h"
 
 const char *errInvalidNodeID = "Invalid cluster node id";
 const char *errInvalidSlotID = "Invalid slot id";
diff --git a/src/cluster/redis_slot.cc b/src/cluster/redis_slot.cc
index 2d664507..12d423db 100644
--- a/src/cluster/redis_slot.cc
+++ b/src/cluster/redis_slot.cc
@@ -26,8 +26,6 @@
 #include <cstdlib>
 #include <string>
 
-#include "util.h"
-
 static const uint16_t crc16tab[256] = {
     0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 
0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad,
     0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 
0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a,
diff --git a/src/cluster/replication.cc b/src/cluster/replication.cc
index 0de4427d..b757819f 100644
--- a/src/cluster/replication.cc
+++ b/src/cluster/replication.cc
@@ -35,12 +35,13 @@
 #include "event_util.h"
 #include "fd_util.h"
 #include "fmt/format.h"
+#include "io_util.h"
 #include "rocksdb_crc32c.h"
 #include "server/redis_reply.h"
 #include "server/server.h"
 #include "status.h"
 #include "storage/batch_debugger.h"
-#include "util.h"
+#include "thread_util.h"
 
 Status FeedSlaveThread::Start() {
   try {
diff --git a/src/cluster/slot_migrate.cc b/src/cluster/slot_migrate.cc
index 8f7b8924..c5727d43 100644
--- a/src/cluster/slot_migrate.cc
+++ b/src/cluster/slot_migrate.cc
@@ -25,7 +25,10 @@
 
 #include "event_util.h"
 #include "fmt/format.h"
+#include "io_util.h"
 #include "storage/batch_extractor.h"
+#include "thread_util.h"
+#include "time_util.h"
 
 static std::map<RedisType, std::string> type_to_cmd = {
     {kRedisString, "set"}, {kRedisList, "rpush"},    {kRedisHash, "hmset"},    
  {kRedisSet, "sadd"},
diff --git a/src/cluster/slot_migrate.h b/src/cluster/slot_migrate.h
index 77e3ca38..a86927ec 100644
--- a/src/cluster/slot_migrate.h
+++ b/src/cluster/slot_migrate.h
@@ -42,7 +42,6 @@
 #include "stats/stats.h"
 #include "status.h"
 #include "storage/redis_db.h"
-#include "util.h"
 
 constexpr const auto CLUSTER_SLOTS = HASH_SLOTS_SIZE;
 
diff --git a/src/commands/command_parser.h b/src/commands/command_parser.h
index 9a18909d..07d58cd9 100644
--- a/src/commands/command_parser.h
+++ b/src/commands/command_parser.h
@@ -27,7 +27,7 @@
 
 #include "parse_util.h"
 #include "status.h"
-#include "util.h"
+#include "string_util.h"
 
 template <typename Iter>
 struct MoveIterator : Iter {
diff --git a/src/commands/redis_cmd.cc b/src/commands/redis_cmd.cc
index 4bbf1d41..46cb237a 100644
--- a/src/commands/redis_cmd.cc
+++ b/src/commands/redis_cmd.cc
@@ -38,6 +38,7 @@
 #include "cluster/slot_migrate.h"
 #include "command_parser.h"
 #include "fd_util.h"
+#include "io_util.h"
 #include "parse_util.h"
 #include "server/redis_connection.h"
 #include "server/redis_reply.h"
@@ -49,6 +50,8 @@
 #include "storage/redis_pubsub.h"
 #include "storage/scripting.h"
 #include "storage/storage.h"
+#include "thread_util.h"
+#include "time_util.h"
 #include "types/redis_bitmap.h"
 #include "types/redis_geo.h"
 #include "types/redis_hash.h"
@@ -58,7 +61,6 @@
 #include "types/redis_stream.h"
 #include "types/redis_string.h"
 #include "types/redis_zset.h"
-#include "util.h"
 
 namespace Redis {
 
diff --git a/src/common/util.cc b/src/common/io_util.cc
similarity index 53%
rename from src/common/util.cc
rename to src/common/io_util.cc
index 2679b12f..43fa1be6 100644
--- a/src/common/util.cc
+++ b/src/common/io_util.cc
@@ -18,39 +18,22 @@
  *
  */
 
-#include "fmt/core.h"
-#define __STDC_FORMAT_MACROS
+#include "io_util.h"
 
-#include <event2/buffer.h>
-#include <event2/util.h>
-#include <glog/logging.h>
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <fmt/format.h>
+#include <netdb.h>
+#include <netinet/tcp.h>
+#include <sys/poll.h>
 
 #ifdef __linux__
 #include <sys/sendfile.h>
 #endif
 
-#include <fcntl.h>
-#include <netdb.h>
-#include <netinet/tcp.h>
-#include <poll.h>
-#include <pthread.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <unistd.h>
-
-#include <algorithm>
-#include <cerrno>
-#include <cmath>
-#include <string>
-
 #include "event_util.h"
 #include "fd_util.h"
-#include "parse_util.h"
 #include "scope_exit.h"
-#include "status.h"
-#include "util.h"
 
 #ifndef POLLIN
 #define POLLIN 0x0001   /* There is data to read */
@@ -101,14 +84,6 @@ Status SockConnect(const std::string &host, uint32_t port, 
int *fd) {
   return Status::FromErrno();
 }
 
-const std::string Float2String(double d) {
-  if (std::isinf(d)) {
-    return d > 0 ? "inf" : "-inf";
-  }
-
-  return fmt::format("{:.17g}", d);
-}
-
 Status SockSetTcpNoDelay(int fd, int val) {
   if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)) == -1) {
     return Status::FromErrno();
@@ -332,291 +307,6 @@ int GetLocalPort(int fd) {
   return 0;
 }
 
-Status DecimalStringToNum(const std::string &str, int64_t *n, int64_t min, 
int64_t max) {
-  auto parse_result = ParseInt<int64_t>(str, NumericRange<int64_t>{min, max}, 
10);
-  if (!parse_result) {
-    return parse_result.ToStatus();
-  }
-  *n = *parse_result;
-  return Status::OK();
-}
-
-Status OctalStringToNum(const std::string &str, int64_t *n, int64_t min, 
int64_t max) {
-  auto parse_result = ParseInt<int64_t>(str, NumericRange<int64_t>{min, max}, 
8);
-  if (!parse_result) {
-    return parse_result.ToStatus();
-  }
-  *n = *parse_result;
-  return Status::OK();
-}
-
-std::string ToLower(std::string in) {
-  std::transform(in.begin(), in.end(), in.begin(), [](char c) -> char { return 
static_cast<char>(std::tolower(c)); });
-  return in;
-}
-
-bool EqualICase(std::string_view lhs, std::string_view rhs) {
-  return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), 
rhs.begin(),
-                                                [](char l, char r) { return 
std::tolower(l) == std::tolower(r); });
-}
-
-std::string Trim(std::string in, const std::string &chars) {
-  if (in.empty()) return in;
-
-  in.erase(0, in.find_first_not_of(chars));
-  in.erase(in.find_last_not_of(chars) + 1);
-
-  return in;
-}
-
-std::vector<std::string> Split(const std::string &in, const std::string 
&delim) {
-  std::vector<std::string> out;
-
-  if (in.empty()) {
-    return out;
-  }
-
-  if (delim.empty()) {
-    out.resize(in.size());
-    std::transform(in.begin(), in.end(), out.begin(), [](char c) -> 
std::string { return {c}; });
-    return out;
-  }
-
-  size_t begin = 0, end = in.find_first_of(delim);
-  do {
-    std::string elem = in.substr(begin, end - begin);
-    if (!elem.empty()) out.push_back(std::move(elem));
-    if (end == std::string::npos) break;
-    begin = end + 1;
-    end = in.find_first_of(delim, begin);
-  } while (true);
-
-  return out;
-}
-
-std::vector<std::string> Split2KV(const std::string &in, const std::string 
&delim) {
-  std::vector<std::string> out;
-
-  std::string::size_type pos = in.find_first_of(delim);
-  if (pos != std::string::npos) {
-    std::string key = in.substr(0, pos);
-    if (!key.empty()) out.push_back(std::move(key));
-
-    std::string value = Trim(in.substr(pos + 1), delim);
-    if (!value.empty()) out.push_back(std::move(value));
-  }
-
-  return out;
-}
-
-bool HasPrefix(const std::string &str, const std::string &prefix) {
-  if (str.empty() || prefix.empty()) return false;
-  return !strncasecmp(str.data(), prefix.data(), prefix.size());
-}
-
-int StringMatch(const std::string &pattern, const std::string &in, int nocase) 
{
-  return StringMatchLen(pattern.c_str(), pattern.length(), in.c_str(), 
in.length(), nocase);
-}
-
-// Glob-style pattern matching.
-int StringMatchLen(const char *pattern, int patternLen, const char *string, 
int stringLen, int nocase) {
-  while (patternLen && stringLen) {
-    switch (pattern[0]) {
-      case '*':
-        while (pattern[1] == '*') {
-          pattern++;
-          patternLen--;
-        }
-        if (patternLen == 1) return 1; /* match */
-        while (stringLen) {
-          if (StringMatchLen(pattern + 1, patternLen - 1, string, stringLen, 
nocase)) return 1; /* match */
-          string++;
-          stringLen--;
-        }
-        return 0; /* no match */
-        break;
-      case '?':
-        if (stringLen == 0) return 0; /* no match */
-        string++;
-        stringLen--;
-        break;
-      case '[': {
-        int not_symbol, match;
-
-        pattern++;
-        patternLen--;
-        not_symbol = pattern[0] == '^';
-        if (not_symbol) {
-          pattern++;
-          patternLen--;
-        }
-        match = 0;
-        while (true) {
-          if (pattern[0] == '\\' && patternLen >= 2) {
-            pattern++;
-            patternLen--;
-            if (pattern[0] == string[0]) match = 1;
-          } else if (pattern[0] == ']') {
-            break;
-          } else if (patternLen == 0) {
-            pattern--;
-            patternLen++;
-            break;
-          } else if (pattern[1] == '-' && patternLen >= 3) {
-            int start = pattern[0];
-            int end = pattern[2];
-            int c = string[0];
-            if (start > end) {
-              int t = start;
-              start = end;
-              end = t;
-            }
-            if (nocase) {
-              start = tolower(start);
-              end = tolower(end);
-              c = tolower(c);
-            }
-            pattern += 2;
-            patternLen -= 2;
-            if (c >= start && c <= end) match = 1;
-          } else {
-            if (!nocase) {
-              if (pattern[0] == string[0]) match = 1;
-            } else {
-              if (tolower(static_cast<int>(pattern[0])) == 
tolower(static_cast<int>(string[0]))) match = 1;
-            }
-          }
-          pattern++;
-          patternLen--;
-        }
-        if (not_symbol) match = !match;
-        if (!match) return 0; /* no match */
-        string++;
-        stringLen--;
-        break;
-      }
-      case '\\':
-        if (patternLen >= 2) {
-          pattern++;
-          patternLen--;
-        }
-        /* fall through */
-      default:
-        if (!nocase) {
-          if (pattern[0] != string[0]) return 0; /* no match */
-        } else {
-          if (tolower(static_cast<int>(pattern[0])) != 
tolower(static_cast<int>(string[0]))) return 0; /* no match */
-        }
-        string++;
-        stringLen--;
-        break;
-    }
-    pattern++;
-    patternLen--;
-    if (stringLen == 0) {
-      while (*pattern == '*') {
-        pattern++;
-        patternLen--;
-      }
-      break;
-    }
-  }
-  if (patternLen == 0 && stringLen == 0) return 1;
-  return 0;
-}
-
-std::string StringToHex(const std::string &input) {
-  static const char hex_digits[] = "0123456789ABCDEF";
-  std::string output;
-  output.reserve(input.length() * 2);
-  for (unsigned char c : input) {
-    output.push_back(hex_digits[c >> 4]);
-    output.push_back(hex_digits[c & 15]);
-  }
-  return output;
-}
-
-constexpr unsigned long long expTo1024(unsigned n) { return 1ULL << (n * 10); }
-
-void BytesToHuman(char *buf, size_t size, uint64_t n) {
-  if (n < expTo1024(1)) {
-    fmt::format_to_n(buf, size, "{}B", n);
-  } else if (n < expTo1024(2)) {
-    fmt::format_to_n(buf, size, "{:.2f}K", static_cast<double>(n) / 
expTo1024(1));
-  } else if (n < expTo1024(3)) {
-    fmt::format_to_n(buf, size, "{:.2f}M", static_cast<double>(n) / 
expTo1024(2));
-  } else if (n < expTo1024(4)) {
-    fmt::format_to_n(buf, size, "{:.2f}G", static_cast<double>(n) / 
expTo1024(3));
-  } else if (n < expTo1024(5)) {
-    fmt::format_to_n(buf, size, "{:.2f}T", static_cast<double>(n) / 
expTo1024(4));
-  } else if (n < expTo1024(6)) {
-    fmt::format_to_n(buf, size, "{:.2f}P", static_cast<double>(n) / 
expTo1024(5));
-  } else {
-    fmt::format_to_n(buf, size, "{}B", n);
-  }
-}
-
-std::vector<std::string> TokenizeRedisProtocol(const std::string &value) {
-  std::vector<std::string> tokens;
-
-  if (value.empty()) {
-    return tokens;
-  }
-
-  enum ParserState { stateArrayLen, stateBulkLen, stateBulkData };
-  uint64_t array_len = 0, bulk_len = 0;
-  int state = stateArrayLen;
-  const char *start = value.data(), *end = start + value.size(), *p;
-  while (start != end) {
-    switch (state) {
-      case stateArrayLen: {
-        if (start[0] != '*') {
-          return tokens;
-        }
-        p = strchr(start, '\r');
-        if (!p || (p == end) || p[1] != '\n') {
-          tokens.clear();
-          return tokens;
-        }
-        // parse_result expects to must be parsed successfully here
-        array_len = *ParseInt<uint64_t>(std::string(start + 1, p), 10);
-        start = p + 2;
-        state = stateBulkLen;
-        break;
-      }
-      case stateBulkLen: {
-        if (start[0] != '$') {
-          return tokens;
-        }
-        p = strchr(start, '\r');
-        if (!p || (p == end) || p[1] != '\n') {
-          tokens.clear();
-          return tokens;
-        }
-        // parse_result expects to must be parsed successfully here
-        bulk_len = *ParseInt<uint64_t>(std::string(start + 1, p), 10);
-        start = p + 2;
-        state = stateBulkData;
-        break;
-      }
-      case stateBulkData: {
-        if (bulk_len + 2 > static_cast<uint64_t>(end - start)) {
-          tokens.clear();
-          return tokens;
-        }
-        tokens.emplace_back(start, start + bulk_len);
-        start += bulk_len + 2;
-        state = stateBulkLen;
-        break;
-      }
-    }
-  }
-  if (array_len != tokens.size()) {
-    tokens.clear();
-  }
-  return tokens;
-}
-
 bool IsPortInUse(int port) {
   int fd = NullFD;
   Status s = SockConnect("0.0.0.0", static_cast<uint32_t>(port), &fd);
@@ -624,18 +314,10 @@ bool IsPortInUse(int port) {
   return s.IsOK();
 }
 
-void ThreadSetName(const char *name) {
-#ifdef __APPLE__
-  pthread_setname_np(name);
-#else
-  pthread_setname_np(pthread_self(), name);
-#endif
-}
-
 /* Wait for milliseconds until the given file descriptor becomes
  * writable/readable/exception */
 int aeWait(int fd, int mask, uint64_t timeout) {
-  struct pollfd pfd;
+  pollfd pfd;
   int retmask = 0, retval;
 
   memset(&pfd, 0, sizeof(pfd));
@@ -670,4 +352,5 @@ Status WriteImpl(int fd, std::string_view data, Args 
&&...args) {
 Status Write(int fd, const std::string &data) { return WriteImpl<write>(fd, 
data); }
 
 Status Pwrite(int fd, const std::string &data, off_t offset) { return 
WriteImpl<pwrite>(fd, data, offset); }
+
 }  // namespace Util
diff --git a/src/common/util.h b/src/common/io_util.h
similarity index 51%
copy from src/common/util.h
copy to src/common/io_util.h
index 12c038ce..23f431b4 100644
--- a/src/common/util.h
+++ b/src/common/io_util.h
@@ -20,23 +20,12 @@
 
 #pragma once
 
-#define __STDC_FORMAT_MACROS
+#include <netinet/in.h>
 
-#include <arpa/inet.h>
-
-#include <cctype>
-#include <chrono>
-#include <cinttypes>
-#include <memory>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "solarisfixes.h"
 #include "status.h"
 
 namespace Util {
-// sock util
+
 sockaddr_in NewSockaddrInet(const std::string &host, uint32_t port);
 Status SockConnect(const std::string &host, uint32_t port, int *fd);
 Status SockConnect(const std::string &host, uint32_t port, int *fd, uint64_t 
conn_timeout, uint64_t timeout = 0);
@@ -50,32 +39,9 @@ int GetPeerAddr(int fd, std::string *addr, uint32_t *port);
 int GetLocalPort(int fd);
 bool IsPortInUse(int port);
 
-// string util
-Status DecimalStringToNum(const std::string &str, int64_t *n, int64_t min = 
INT64_MIN, int64_t max = INT64_MAX);
-Status OctalStringToNum(const std::string &str, int64_t *n, int64_t min = 
INT64_MIN, int64_t max = INT64_MAX);
-const std::string Float2String(double d);
-std::string ToLower(std::string in);
-bool EqualICase(std::string_view lhs, std::string_view rhs);
-void BytesToHuman(char *buf, size_t size, uint64_t n);
-std::string Trim(std::string in, const std::string &chars);
-std::vector<std::string> Split(const std::string &in, const std::string 
&delim);
-std::vector<std::string> Split2KV(const std::string &in, const std::string 
&delim);
-bool HasPrefix(const std::string &str, const std::string &prefix);
-int StringMatch(const std::string &pattern, const std::string &in, int nocase);
-int StringMatchLen(const char *p, int plen, const char *s, int slen, int 
nocase);
-std::string StringToHex(const std::string &input);
-std::vector<std::string> TokenizeRedisProtocol(const std::string &value);
-
-void ThreadSetName(const char *name);
 int aeWait(int fd, int mask, uint64_t milliseconds);
 
-template <typename Duration = std::chrono::seconds>
-auto GetTimeStamp() {
-  return 
std::chrono::duration_cast<Duration>(std::chrono::system_clock::now().time_since_epoch()).count();
-}
-inline uint64_t GetTimeStampMS() { return 
GetTimeStamp<std::chrono::milliseconds>(); }
-inline uint64_t GetTimeStampUS() { return 
GetTimeStamp<std::chrono::microseconds>(); }
-// file util
 Status Write(int fd, const std::string &data);
 Status Pwrite(int fd, const std::string &data, off_t offset);
+
 }  // namespace Util
diff --git a/src/common/string_util.cc b/src/common/string_util.cc
new file mode 100644
index 00000000..204307de
--- /dev/null
+++ b/src/common/string_util.cc
@@ -0,0 +1,322 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "string_util.h"
+
+#include <fmt/format.h>
+
+#include "parse_util.h"
+
+namespace Util {
+
+Status DecimalStringToNum(const std::string &str, int64_t *n, int64_t min, 
int64_t max) {
+  auto parse_result = ParseInt<int64_t>(str, NumericRange<int64_t>{min, max}, 
10);
+  if (!parse_result) {
+    return parse_result.ToStatus();
+  }
+  *n = *parse_result;
+  return Status::OK();
+}
+
+Status OctalStringToNum(const std::string &str, int64_t *n, int64_t min, 
int64_t max) {
+  auto parse_result = ParseInt<int64_t>(str, NumericRange<int64_t>{min, max}, 
8);
+  if (!parse_result) {
+    return parse_result.ToStatus();
+  }
+  *n = *parse_result;
+  return Status::OK();
+}
+
+const std::string Float2String(double d) {
+  if (std::isinf(d)) {
+    return d > 0 ? "inf" : "-inf";
+  }
+
+  return fmt::format("{:.17g}", d);
+}
+
+std::string ToLower(std::string in) {
+  std::transform(in.begin(), in.end(), in.begin(), [](char c) -> char { return 
static_cast<char>(std::tolower(c)); });
+  return in;
+}
+
+bool EqualICase(std::string_view lhs, std::string_view rhs) {
+  return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), 
rhs.begin(),
+                                                [](char l, char r) { return 
std::tolower(l) == std::tolower(r); });
+}
+
+std::string Trim(std::string in, const std::string &chars) {
+  if (in.empty()) return in;
+
+  in.erase(0, in.find_first_not_of(chars));
+  in.erase(in.find_last_not_of(chars) + 1);
+
+  return in;
+}
+
+std::vector<std::string> Split(const std::string &in, const std::string 
&delim) {
+  std::vector<std::string> out;
+
+  if (in.empty()) {
+    return out;
+  }
+
+  if (delim.empty()) {
+    out.resize(in.size());
+    std::transform(in.begin(), in.end(), out.begin(), [](char c) -> 
std::string { return {c}; });
+    return out;
+  }
+
+  size_t begin = 0, end = in.find_first_of(delim);
+  do {
+    std::string elem = in.substr(begin, end - begin);
+    if (!elem.empty()) out.push_back(std::move(elem));
+    if (end == std::string::npos) break;
+    begin = end + 1;
+    end = in.find_first_of(delim, begin);
+  } while (true);
+
+  return out;
+}
+
+std::vector<std::string> Split2KV(const std::string &in, const std::string 
&delim) {
+  std::vector<std::string> out;
+
+  std::string::size_type pos = in.find_first_of(delim);
+  if (pos != std::string::npos) {
+    std::string key = in.substr(0, pos);
+    if (!key.empty()) out.push_back(std::move(key));
+
+    std::string value = Trim(in.substr(pos + 1), delim);
+    if (!value.empty()) out.push_back(std::move(value));
+  }
+
+  return out;
+}
+
+bool HasPrefix(const std::string &str, const std::string &prefix) {
+  if (str.empty() || prefix.empty()) return false;
+  return !strncasecmp(str.data(), prefix.data(), prefix.size());
+}
+
+int StringMatch(const std::string &pattern, const std::string &in, int nocase) 
{
+  return StringMatchLen(pattern.c_str(), pattern.length(), in.c_str(), 
in.length(), nocase);
+}
+
+// Glob-style pattern matching.
+int StringMatchLen(const char *pattern, int patternLen, const char *string, 
int stringLen, int nocase) {
+  while (patternLen && stringLen) {
+    switch (pattern[0]) {
+      case '*':
+        while (pattern[1] == '*') {
+          pattern++;
+          patternLen--;
+        }
+        if (patternLen == 1) return 1; /* match */
+        while (stringLen) {
+          if (StringMatchLen(pattern + 1, patternLen - 1, string, stringLen, 
nocase)) return 1; /* match */
+          string++;
+          stringLen--;
+        }
+        return 0; /* no match */
+        break;
+      case '?':
+        if (stringLen == 0) return 0; /* no match */
+        string++;
+        stringLen--;
+        break;
+      case '[': {
+        int not_symbol, match;
+
+        pattern++;
+        patternLen--;
+        not_symbol = pattern[0] == '^';
+        if (not_symbol) {
+          pattern++;
+          patternLen--;
+        }
+        match = 0;
+        while (true) {
+          if (pattern[0] == '\\' && patternLen >= 2) {
+            pattern++;
+            patternLen--;
+            if (pattern[0] == string[0]) match = 1;
+          } else if (pattern[0] == ']') {
+            break;
+          } else if (patternLen == 0) {
+            pattern--;
+            patternLen++;
+            break;
+          } else if (pattern[1] == '-' && patternLen >= 3) {
+            int start = pattern[0];
+            int end = pattern[2];
+            int c = string[0];
+            if (start > end) {
+              int t = start;
+              start = end;
+              end = t;
+            }
+            if (nocase) {
+              start = tolower(start);
+              end = tolower(end);
+              c = tolower(c);
+            }
+            pattern += 2;
+            patternLen -= 2;
+            if (c >= start && c <= end) match = 1;
+          } else {
+            if (!nocase) {
+              if (pattern[0] == string[0]) match = 1;
+            } else {
+              if (tolower(static_cast<int>(pattern[0])) == 
tolower(static_cast<int>(string[0]))) match = 1;
+            }
+          }
+          pattern++;
+          patternLen--;
+        }
+        if (not_symbol) match = !match;
+        if (!match) return 0; /* no match */
+        string++;
+        stringLen--;
+        break;
+      }
+      case '\\':
+        if (patternLen >= 2) {
+          pattern++;
+          patternLen--;
+        }
+        /* fall through */
+      default:
+        if (!nocase) {
+          if (pattern[0] != string[0]) return 0; /* no match */
+        } else {
+          if (tolower(static_cast<int>(pattern[0])) != 
tolower(static_cast<int>(string[0]))) return 0; /* no match */
+        }
+        string++;
+        stringLen--;
+        break;
+    }
+    pattern++;
+    patternLen--;
+    if (stringLen == 0) {
+      while (*pattern == '*') {
+        pattern++;
+        patternLen--;
+      }
+      break;
+    }
+  }
+  if (patternLen == 0 && stringLen == 0) return 1;
+  return 0;
+}
+
+std::string StringToHex(const std::string &input) {
+  static const char hex_digits[] = "0123456789ABCDEF";
+  std::string output;
+  output.reserve(input.length() * 2);
+  for (unsigned char c : input) {
+    output.push_back(hex_digits[c >> 4]);
+    output.push_back(hex_digits[c & 15]);
+  }
+  return output;
+}
+
+constexpr unsigned long long expTo1024(unsigned n) { return 1ULL << (n * 10); }
+
+void BytesToHuman(char *buf, size_t size, uint64_t n) {
+  if (n < expTo1024(1)) {
+    fmt::format_to_n(buf, size, "{}B", n);
+  } else if (n < expTo1024(2)) {
+    fmt::format_to_n(buf, size, "{:.2f}K", static_cast<double>(n) / 
expTo1024(1));
+  } else if (n < expTo1024(3)) {
+    fmt::format_to_n(buf, size, "{:.2f}M", static_cast<double>(n) / 
expTo1024(2));
+  } else if (n < expTo1024(4)) {
+    fmt::format_to_n(buf, size, "{:.2f}G", static_cast<double>(n) / 
expTo1024(3));
+  } else if (n < expTo1024(5)) {
+    fmt::format_to_n(buf, size, "{:.2f}T", static_cast<double>(n) / 
expTo1024(4));
+  } else if (n < expTo1024(6)) {
+    fmt::format_to_n(buf, size, "{:.2f}P", static_cast<double>(n) / 
expTo1024(5));
+  } else {
+    fmt::format_to_n(buf, size, "{}B", n);
+  }
+}
+
+std::vector<std::string> TokenizeRedisProtocol(const std::string &value) {
+  std::vector<std::string> tokens;
+
+  if (value.empty()) {
+    return tokens;
+  }
+
+  enum ParserState { stateArrayLen, stateBulkLen, stateBulkData };
+  uint64_t array_len = 0, bulk_len = 0;
+  int state = stateArrayLen;
+  const char *start = value.data(), *end = start + value.size(), *p;
+  while (start != end) {
+    switch (state) {
+      case stateArrayLen: {
+        if (start[0] != '*') {
+          return tokens;
+        }
+        p = strchr(start, '\r');
+        if (!p || (p == end) || p[1] != '\n') {
+          tokens.clear();
+          return tokens;
+        }
+        // parse_result expects to must be parsed successfully here
+        array_len = *ParseInt<uint64_t>(std::string(start + 1, p), 10);
+        start = p + 2;
+        state = stateBulkLen;
+        break;
+      }
+      case stateBulkLen: {
+        if (start[0] != '$') {
+          return tokens;
+        }
+        p = strchr(start, '\r');
+        if (!p || (p == end) || p[1] != '\n') {
+          tokens.clear();
+          return tokens;
+        }
+        // parse_result expects to must be parsed successfully here
+        bulk_len = *ParseInt<uint64_t>(std::string(start + 1, p), 10);
+        start = p + 2;
+        state = stateBulkData;
+        break;
+      }
+      case stateBulkData: {
+        if (bulk_len + 2 > static_cast<uint64_t>(end - start)) {
+          tokens.clear();
+          return tokens;
+        }
+        tokens.emplace_back(start, start + bulk_len);
+        start += bulk_len + 2;
+        state = stateBulkLen;
+        break;
+      }
+    }
+  }
+  if (array_len != tokens.size()) {
+    tokens.clear();
+  }
+  return tokens;
+}
+
+}  // namespace Util
diff --git a/src/common/util.h b/src/common/string_util.h
similarity index 56%
rename from src/common/util.h
rename to src/common/string_util.h
index 12c038ce..9ed3a145 100644
--- a/src/common/util.h
+++ b/src/common/string_util.h
@@ -20,37 +20,10 @@
 
 #pragma once
 
-#define __STDC_FORMAT_MACROS
-
-#include <arpa/inet.h>
-
-#include <cctype>
-#include <chrono>
-#include <cinttypes>
-#include <memory>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "solarisfixes.h"
 #include "status.h"
 
 namespace Util {
-// sock util
-sockaddr_in NewSockaddrInet(const std::string &host, uint32_t port);
-Status SockConnect(const std::string &host, uint32_t port, int *fd);
-Status SockConnect(const std::string &host, uint32_t port, int *fd, uint64_t 
conn_timeout, uint64_t timeout = 0);
-Status SockSetTcpNoDelay(int fd, int val);
-Status SockSetTcpKeepalive(int fd, int interval);
-Status SockSend(int fd, const std::string &data);
-Status SockReadLine(int fd, std::string *data);
-Status SockSendFile(int out_fd, int in_fd, size_t size);
-Status SockSetBlocking(int fd, int blocking);
-int GetPeerAddr(int fd, std::string *addr, uint32_t *port);
-int GetLocalPort(int fd);
-bool IsPortInUse(int port);
 
-// string util
 Status DecimalStringToNum(const std::string &str, int64_t *n, int64_t min = 
INT64_MIN, int64_t max = INT64_MAX);
 Status OctalStringToNum(const std::string &str, int64_t *n, int64_t min = 
INT64_MIN, int64_t max = INT64_MAX);
 const std::string Float2String(double d);
@@ -66,16 +39,4 @@ int StringMatchLen(const char *p, int plen, const char *s, 
int slen, int nocase)
 std::string StringToHex(const std::string &input);
 std::vector<std::string> TokenizeRedisProtocol(const std::string &value);
 
-void ThreadSetName(const char *name);
-int aeWait(int fd, int mask, uint64_t milliseconds);
-
-template <typename Duration = std::chrono::seconds>
-auto GetTimeStamp() {
-  return 
std::chrono::duration_cast<Duration>(std::chrono::system_clock::now().time_since_epoch()).count();
-}
-inline uint64_t GetTimeStampMS() { return 
GetTimeStamp<std::chrono::milliseconds>(); }
-inline uint64_t GetTimeStampUS() { return 
GetTimeStamp<std::chrono::microseconds>(); }
-// file util
-Status Write(int fd, const std::string &data);
-Status Pwrite(int fd, const std::string &data, off_t offset);
 }  // namespace Util
diff --git a/src/common/task_runner.cc b/src/common/task_runner.cc
index ea1b6676..732134ed 100644
--- a/src/common/task_runner.cc
+++ b/src/common/task_runner.cc
@@ -22,7 +22,7 @@
 
 #include <thread>
 
-#include "util.h"
+#include "thread_util.h"
 
 Status TaskRunner::Publish(const Task &task) {
   std::lock_guard<std::mutex> guard(mu_);
diff --git a/tests/cppunit/cron_test.cc b/src/common/thread_util.cc
similarity index 54%
copy from tests/cppunit/cron_test.cc
copy to src/common/thread_util.cc
index 9c3f3bd3..b93d3fec 100644
--- a/tests/cppunit/cron_test.cc
+++ b/src/common/thread_util.cc
@@ -18,37 +18,18 @@
  *
  */
 
-#include "cron.h"
+#include "thread_util.h"
 
-#include <gtest/gtest.h>
+#include <pthread.h>
 
-#include <memory>
+namespace Util {
 
-#include "util.h"
-
-class CronTest : public testing::Test {
- protected:
-  explicit CronTest() {
-    cron = std::make_unique<Cron>();
-    std::vector<std::string> schedule{"*", "3", "*", "*", "*"};
-    cron->SetScheduleTime(schedule);
-  }
-  ~CronTest() = default;
-
- protected:
-  std::unique_ptr<Cron> cron;
-};
-
-TEST_F(CronTest, IsTimeMatch) {
-  std::time_t t = std::time(0);
-  std::tm *now = std::localtime(&t);
-  now->tm_hour = 3;
-  ASSERT_TRUE(cron->IsTimeMatch(now));
-  now->tm_hour = 4;
-  ASSERT_FALSE(cron->IsTimeMatch(now));
+void ThreadSetName(const char *name) {
+#ifdef __APPLE__
+  pthread_setname_np(name);
+#else
+  pthread_setname_np(pthread_self(), name);
+#endif
 }
 
-TEST_F(CronTest, ToString) {
-  std::string got = cron->ToString();
-  ASSERT_EQ("* 3 * * *", got);
-}
+}  // namespace Util
diff --git a/tests/cppunit/cron_test.cc b/src/common/thread_util.h
similarity index 54%
copy from tests/cppunit/cron_test.cc
copy to src/common/thread_util.h
index 9c3f3bd3..f4ffc789 100644
--- a/tests/cppunit/cron_test.cc
+++ b/src/common/thread_util.h
@@ -18,37 +18,10 @@
  *
  */
 
-#include "cron.h"
+#pragma once
 
-#include <gtest/gtest.h>
+namespace Util {
 
-#include <memory>
+void ThreadSetName(const char *name);
 
-#include "util.h"
-
-class CronTest : public testing::Test {
- protected:
-  explicit CronTest() {
-    cron = std::make_unique<Cron>();
-    std::vector<std::string> schedule{"*", "3", "*", "*", "*"};
-    cron->SetScheduleTime(schedule);
-  }
-  ~CronTest() = default;
-
- protected:
-  std::unique_ptr<Cron> cron;
-};
-
-TEST_F(CronTest, IsTimeMatch) {
-  std::time_t t = std::time(0);
-  std::tm *now = std::localtime(&t);
-  now->tm_hour = 3;
-  ASSERT_TRUE(cron->IsTimeMatch(now));
-  now->tm_hour = 4;
-  ASSERT_FALSE(cron->IsTimeMatch(now));
-}
-
-TEST_F(CronTest, ToString) {
-  std::string got = cron->ToString();
-  ASSERT_EQ("* 3 * * *", got);
-}
+}  // namespace Util
diff --git a/tests/cppunit/cron_test.cc b/src/common/time_util.h
similarity index 54%
copy from tests/cppunit/cron_test.cc
copy to src/common/time_util.h
index 9c3f3bd3..d0fb20b3 100644
--- a/tests/cppunit/cron_test.cc
+++ b/src/common/time_util.h
@@ -18,37 +18,17 @@
  *
  */
 
-#include "cron.h"
+#pragma once
 
-#include <gtest/gtest.h>
+#include <chrono>
 
-#include <memory>
+namespace Util {
 
-#include "util.h"
-
-class CronTest : public testing::Test {
- protected:
-  explicit CronTest() {
-    cron = std::make_unique<Cron>();
-    std::vector<std::string> schedule{"*", "3", "*", "*", "*"};
-    cron->SetScheduleTime(schedule);
-  }
-  ~CronTest() = default;
-
- protected:
-  std::unique_ptr<Cron> cron;
-};
-
-TEST_F(CronTest, IsTimeMatch) {
-  std::time_t t = std::time(0);
-  std::tm *now = std::localtime(&t);
-  now->tm_hour = 3;
-  ASSERT_TRUE(cron->IsTimeMatch(now));
-  now->tm_hour = 4;
-  ASSERT_FALSE(cron->IsTimeMatch(now));
+template <typename Duration = std::chrono::seconds>
+auto GetTimeStamp() {
+  return 
std::chrono::duration_cast<Duration>(std::chrono::system_clock::now().time_since_epoch()).count();
 }
+inline uint64_t GetTimeStampMS() { return 
GetTimeStamp<std::chrono::milliseconds>(); }
+inline uint64_t GetTimeStampUS() { return 
GetTimeStamp<std::chrono::microseconds>(); }
 
-TEST_F(CronTest, ToString) {
-  std::string got = cron->ToString();
-  ASSERT_EQ("* 3 * * *", got);
-}
+}  // namespace Util
diff --git a/src/config/config.cc b/src/config/config.cc
index aa169b28..09058b8c 100644
--- a/src/config/config.cc
+++ b/src/config/config.cc
@@ -43,7 +43,6 @@
 #include "server/server.h"
 #include "server/tls_util.h"
 #include "status.h"
-#include "util.h"
 
 const char *kDefaultNamespace = "__namespace";
 
diff --git a/src/config/config_type.h b/src/config/config_type.h
index 27410115..04b04a03 100644
--- a/src/config/config_type.h
+++ b/src/config/config_type.h
@@ -24,7 +24,7 @@
 #include <utility>
 
 #include "status.h"
-#include "util.h"
+#include "string_util.h"
 
 // forward declaration
 class Server;
diff --git a/src/config/config_util.cc b/src/config/config_util.cc
index 4e788dc5..f4edf44e 100644
--- a/src/config/config_util.cc
+++ b/src/config/config_util.cc
@@ -20,7 +20,7 @@
 
 #include "config_util.h"
 
-#include "util.h"
+#include "string_util.h"
 
 StatusOr<ConfigKV> ParseConfigLine(const std::string& line) {
   enum {
diff --git a/src/main.cc b/src/main.cc
index c1733c55..705a18e1 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -40,10 +40,11 @@
 
 #include "config.h"
 #include "fd_util.h"
+#include "io_util.h"
 #include "scope_exit.h"
 #include "server/server.h"
 #include "storage/storage.h"
-#include "util.h"
+#include "string_util.h"
 #include "version.h"
 
 namespace google {
diff --git a/src/server/redis_request.cc b/src/server/redis_request.cc
index 0b74c7c0..22066331 100644
--- a/src/server/redis_request.cc
+++ b/src/server/redis_request.cc
@@ -33,7 +33,6 @@
 #include "redis_connection.h"
 #include "redis_reply.h"
 #include "server.h"
-#include "util.h"
 
 namespace Redis {
 const size_t PROTO_INLINE_MAX_SIZE = 16 * 1024L;
diff --git a/src/server/server.cc b/src/server/server.cc
index 1e4913c0..b05189b4 100644
--- a/src/server/server.cc
+++ b/src/server/server.cc
@@ -37,8 +37,9 @@
 #include "storage/compaction_checker.h"
 #include "storage/redis_db.h"
 #include "storage/scripting.h"
+#include "thread_util.h"
+#include "time_util.h"
 #include "tls_util.h"
-#include "util.h"
 #include "version.h"
 #include "worker.h"
 
diff --git a/src/server/worker.cc b/src/server/worker.cc
index 50caf3ad..0d4d32cb 100644
--- a/src/server/worker.cc
+++ b/src/server/worker.cc
@@ -25,6 +25,10 @@
 
 #include <string>
 
+#include "io_util.h"
+#include "thread_util.h"
+#include "time_util.h"
+
 #ifdef ENABLE_OPENSSL
 #include <event2/bufferevent_ssl.h>
 #include <openssl/err.h>
@@ -46,7 +50,6 @@
 #include "redis_request.h"
 #include "server.h"
 #include "storage/scripting.h"
-#include "util.h"
 
 Worker::Worker(Server *svr, Config *config, bool repl) : svr_(svr) {
   base_ = event_base_new();
diff --git a/src/stats/stats.cc b/src/stats/stats.cc
index b3736c43..0602a854 100644
--- a/src/stats/stats.cc
+++ b/src/stats/stats.cc
@@ -23,7 +23,7 @@
 #include <chrono>
 
 #include "fmt/format.h"
-#include "util.h"
+#include "time_util.h"
 
 Stats::Stats() {
   for (int i = 0; i < STATS_METRIC_COUNT; i++) {
diff --git a/src/storage/compaction_checker.cc 
b/src/storage/compaction_checker.cc
index 80af78be..a8c6f0be 100644
--- a/src/storage/compaction_checker.cc
+++ b/src/storage/compaction_checker.cc
@@ -24,6 +24,7 @@
 
 #include "parse_util.h"
 #include "storage.h"
+#include "time_util.h"
 
 void CompactionChecker::CompactPropagateAndPubSubFiles() {
   rocksdb::CompactRangeOptions compact_opts;
diff --git a/src/storage/redis_db.cc b/src/storage/redis_db.cc
index 8677ddfb..cdf79bdb 100644
--- a/src/storage/redis_db.cc
+++ b/src/storage/redis_db.cc
@@ -28,7 +28,6 @@
 #include "parse_util.h"
 #include "rocksdb/iterator.h"
 #include "server/server.h"
-#include "util.h"
 
 namespace Redis {
 
diff --git a/src/storage/redis_metadata.cc b/src/storage/redis_metadata.cc
index ddf34069..ed05f300 100644
--- a/src/storage/redis_metadata.cc
+++ b/src/storage/redis_metadata.cc
@@ -29,7 +29,7 @@
 #include <vector>
 
 #include "cluster/redis_slot.h"
-#include "util.h"
+#include "time_util.h"
 
 // 52 bit for microseconds and 11 bit for counter
 const int VersionCounterBits = 11;
diff --git a/src/storage/scripting.cc b/src/storage/scripting.cc
index fe05e259..b47f1080 100644
--- a/src/storage/scripting.cc
+++ b/src/storage/scripting.cc
@@ -62,7 +62,6 @@
 #include "server/redis_connection.h"
 #include "server/server.h"
 #include "sha1.h"
-#include "util.h"
 
 /* The maximum number of characters needed to represent a long double
  * as a string (long double has a huge range).
diff --git a/src/storage/storage.cc b/src/storage/storage.cc
index cff41f7b..e6f4ae52 100644
--- a/src/storage/storage.cc
+++ b/src/storage/storage.cc
@@ -47,6 +47,7 @@
 #include "rocksdb_crc32c.h"
 #include "server/server.h"
 #include "table_properties_collector.h"
+#include "time_util.h"
 
 namespace Engine {
 
diff --git a/src/types/redis_geo.cc b/src/types/redis_geo.cc
index 0400eddc..ff8078f2 100644
--- a/src/types/redis_geo.cc
+++ b/src/types/redis_geo.cc
@@ -22,8 +22,6 @@
 
 #include <algorithm>
 
-#include "util.h"
-
 namespace Redis {
 
 rocksdb::Status Geo::Add(const Slice &user_key, std::vector<GeoPoint> 
*geo_points, int *ret) {
diff --git a/src/types/redis_stream_base.cc b/src/types/redis_stream_base.cc
index 7ed399cf..9f9d6e72 100644
--- a/src/types/redis_stream_base.cc
+++ b/src/types/redis_stream_base.cc
@@ -22,7 +22,7 @@
 
 #include "encoding.h"
 #include "parse_util.h"
-#include "util.h"
+#include "time_util.h"
 
 namespace Redis {
 
diff --git a/src/types/redis_string.cc b/src/types/redis_string.cc
index 0d5492ee..d4b7f081 100644
--- a/src/types/redis_string.cc
+++ b/src/types/redis_string.cc
@@ -25,6 +25,7 @@
 #include <string>
 
 #include "parse_util.h"
+#include "time_util.h"
 
 namespace Redis {
 
diff --git a/src/types/redis_zset.cc b/src/types/redis_zset.cc
index 8cffa19e..d141a6f5 100644
--- a/src/types/redis_zset.cc
+++ b/src/types/redis_zset.cc
@@ -29,7 +29,6 @@
 #include <set>
 
 #include "db_util.h"
-#include "util.h"
 
 namespace Redis {
 
diff --git a/tests/cppunit/cluster_test.cc b/tests/cppunit/cluster_test.cc
index 678ef94d..b6e256d2 100644
--- a/tests/cppunit/cluster_test.cc
+++ b/tests/cppunit/cluster_test.cc
@@ -26,7 +26,6 @@
 #include <cstring>
 
 #include "server/server.h"
-#include "util.h"
 
 TEST(Cluster, CluseterSetNodes) {
   Status s;
diff --git a/tests/cppunit/cron_test.cc b/tests/cppunit/cron_test.cc
index 9c3f3bd3..98c5d422 100644
--- a/tests/cppunit/cron_test.cc
+++ b/tests/cppunit/cron_test.cc
@@ -24,8 +24,6 @@
 
 #include <memory>
 
-#include "util.h"
-
 class CronTest : public testing::Test {
  protected:
   explicit CronTest() {
diff --git a/tests/cppunit/string_util_test.cc 
b/tests/cppunit/string_util_test.cc
index c7fd3f22..17514d54 100644
--- a/tests/cppunit/string_util_test.cc
+++ b/tests/cppunit/string_util_test.cc
@@ -18,12 +18,12 @@
  *
  */
 
+#include "string_util.h"
+
 #include <gtest/gtest.h>
 
 #include <map>
 
-#include "util.h"
-
 TEST(StringUtil, ToLower) {
   std::map<std::string, std::string> cases{
       {"ABC", "abc"},
diff --git a/tests/cppunit/t_stream_test.cc b/tests/cppunit/t_stream_test.cc
index ac4cc10d..dfeba031 100644
--- a/tests/cppunit/t_stream_test.cc
+++ b/tests/cppunit/t_stream_test.cc
@@ -21,6 +21,7 @@
 #include <gtest/gtest.h>
 
 #include "test_base.h"
+#include "time_util.h"
 #include "types/redis_stream.h"
 
 class RedisStreamTest : public TestBase {
diff --git a/utils/kvrocks2redis/config.cc b/utils/kvrocks2redis/config.cc
index 197c96d5..318787bd 100644
--- a/utils/kvrocks2redis/config.cc
+++ b/utils/kvrocks2redis/config.cc
@@ -29,7 +29,6 @@
 #include <vector>
 
 #include "config/config.h"
-#include "util.h"
 
 namespace Kvrocks2redis {
 
diff --git a/utils/kvrocks2redis/main.cc b/utils/kvrocks2redis/main.cc
index b9d57a37..1fa343a9 100644
--- a/utils/kvrocks2redis/main.cc
+++ b/utils/kvrocks2redis/main.cc
@@ -28,6 +28,7 @@
 
 #include "config.h"
 #include "config/config.h"
+#include "io_util.h"
 #include "parser.h"
 #include "redis_writer.h"
 #include "storage/storage.h"
diff --git a/utils/kvrocks2redis/redis_writer.cc 
b/utils/kvrocks2redis/redis_writer.cc
index ed23eb68..cfd74fac 100644
--- a/utils/kvrocks2redis/redis_writer.cc
+++ b/utils/kvrocks2redis/redis_writer.cc
@@ -26,8 +26,9 @@
 
 #include <system_error>
 
+#include "io_util.h"
 #include "server/redis_reply.h"
-#include "util.h"
+#include "thread_util.h"
 
 RedisWriter::RedisWriter(Kvrocks2redis::Config *config) : Writer(config) {
   try {
diff --git a/utils/kvrocks2redis/sync.cc b/utils/kvrocks2redis/sync.cc
index 1c65f8d8..bac11f1f 100644
--- a/utils/kvrocks2redis/sync.cc
+++ b/utils/kvrocks2redis/sync.cc
@@ -31,8 +31,8 @@
 #include <fstream>
 #include <string>
 
+#include "io_util.h"
 #include "server/redis_reply.h"
-#include "util.h"
 
 void send_string_to_event(bufferevent *bev, const std::string &data) {
   auto output = bufferevent_get_output(bev);
diff --git a/utils/kvrocks2redis/writer.cc b/utils/kvrocks2redis/writer.cc
index d7680cdb..44ee4d05 100644
--- a/utils/kvrocks2redis/writer.cc
+++ b/utils/kvrocks2redis/writer.cc
@@ -25,7 +25,7 @@
 
 #include <cstring>
 
-#include "util.h"
+#include "io_util.h"
 
 Writer::~Writer() {
   for (const auto &iter : aof_fds_) {


Reply via email to