Skip to content

Commit

Permalink
Merge branch 'unstable' into stringcmdsetbit
Browse files Browse the repository at this point in the history
  • Loading branch information
callme-taota authored Dec 12, 2023
2 parents 55ef8f3 + ad6d274 commit 89a90f7
Show file tree
Hide file tree
Showing 83 changed files with 16,543 additions and 29 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/pikiwidb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@ on:
branches: [ "unstable" ]

jobs:
build_on_macos:
runs-on: macos-latest
check_format:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Deps
run: |
brew install clang-format
- name: Build
run: |
sh build.sh
run: bash ci/build.sh

- name: Check Format
working-directory: ${{ github.workspace }}/build
run: make check-format

build_on_macos:
runs-on: macos-latest
needs: check_format

steps:
- uses: actions/checkout@v4

- name: Build
run: |
make check-format
sh build.sh
- name: GTest
working-directory: ${{ github.workspace }}/build
Expand All @@ -33,6 +38,7 @@ jobs:

build_on_ubuntu:
runs-on: ubuntu-latest
needs: check_format

steps:
- uses: actions/checkout@v4
Expand All @@ -41,10 +47,6 @@ jobs:
run: |
bash build.sh
- name: Check Format
working-directory: ${{ github.workspace }}/build
run: make check-format

- name: GTest
working-directory: ${{ github.workspace }}/build
# Execute tests defined by the CMake configuration.
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ enable_testing()

ADD_SUBDIRECTORY(src/pstd)
ADD_SUBDIRECTORY(src/net)
ADD_SUBDIRECTORY(src/storage)
ADD_SUBDIRECTORY(src)

#############################################################################
Expand Down
Empty file.
27 changes: 27 additions & 0 deletions ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

BUILD_TIME=$(git log -1 --format=%ai)
BUILD_TIME=${BUILD_TIME: 0: 10}

COMMIT_ID=$(git rev-parse HEAD)
SHORT_COMMIT_ID=${COMMIT_ID: 0: 8}

BUILD_TYPE=release
VERBOSE=0
CMAKE_FLAGS=""
MAKE_FLAGS=""
PREFIX="build"

if [ -z "$SHORT_COMMIT_ID" ]; then
echo "no git commit id"
SHORT_COMMIT_ID="pikiwidb"
fi

echo "BUILD_TIME:" $BUILD_TIME
echo "COMMIT_ID:" $SHORT_COMMIT_ID

echo "BUILD_TYPE:" $BUILD_TYPE
echo "CMAKE_FLAGS:" $CMAKE_FLAGS
echo "MAKE_FLAGS:" $MAKE_FLAGS

cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_TIME=$BUILD_TIME -DGIT_COMMIT_ID=$SHORT_COMMIT_ID ${CMAKE_FLAGS} -S . -B ${PREFIX}
9 changes: 7 additions & 2 deletions cmake/rocksdb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

include_guard()

FetchContent_Declare(
rocksdb
GIT_REPOSITORY https://github.com/facebook/rocksdb.git
GIT_TAG v8.6.7
GIT_TAG v8.3.3
)

FetchContent_MakeAvailableWithArgs(rocksdb
Expand All @@ -20,6 +21,10 @@ FetchContent_MakeAvailableWithArgs(rocksdb
WITH_TRACE_TOOLS=OFF
WITH_EXAMPLES=OFF
ROCKSDB_BUILD_SHARED=OFF
WITH_GFLAGS=OFF
WITH_LIBURING=OFF
WITH_LZ4=OFF
WITH_SNAPPY=OFF
WITH_ZLIB=OFF
WITH_ZSTD=OFF
WITH_GFLAGS=OFF
)
10 changes: 10 additions & 0 deletions src/base_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const std::string kCmdNameSetex = "setex";
const std::string kCmdNamePsetex = "psetex";
const std::string kCmdNameSetnx = "setnx";
const std::string kCmdNameSetBit = "setbit";
const std::string kCmdNameIncrbyfloat = "incrbyfloat";
const std::string kCmdNameGetBit = "getbit";

// multi
Expand All @@ -46,6 +47,7 @@ const std::string kCmdNameDiscard = "discard";

// admin
const std::string kCmdNameConfig = "config";
const std::string kCmdNameFlushdb = "flushdb";

const std::string kCmdNameAppend = "append";
const std::string kCmdNameGetset = "getset";
Expand All @@ -55,6 +57,14 @@ const std::string kCmdNameBitCount = "bitcount";

const std::string kCmdNameAuth = "auth";

// hash cmd
const std::string kCmdNameHSet = "hset";
const std::string kCmdNameHGet = "hget";
const std::string kCmdNameHMSet = "hmset";
const std::string kCmdNameHMGet = "hmget";
const std::string kCmdNameHGetAll = "hgetall";
const std::string kCmdNameHKeys = "hkeys";

enum CmdFlags {
CmdFlagsWrite = (1 << 0), // May modify the dataset
CmdFlagsReadonly = (1 << 1), // Doesn't modify the dataset
Expand Down
13 changes: 13 additions & 0 deletions src/cmd_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include "cmd_admin.h"
#include "store.h"

namespace pikiwidb {

Expand All @@ -27,4 +28,16 @@ bool CmdConfigSet::DoInitial(PClient* client) { return true; }

void CmdConfigSet::DoCmd(PClient* client) { client->AppendString("config cmd in development"); }

FlushdbCmd::FlushdbCmd(const std::string& name, int16_t arity)
: BaseCmd(name, arity, CmdFlagsAdmin | CmdFlagsWrite, AclCategoryWrite | AclCategoryAdmin) {}

bool FlushdbCmd::DoInitial(PClient* client) { return true; }

void FlushdbCmd::DoCmd(PClient* client) {
PSTORE.dirty_ += PSTORE.DBSize();
PSTORE.ClearCurrentDB();
Propagate(PSTORE.GetDB(), std::vector<PString>{"flushdb"});
client->SetRes(CmdRes::kOk);
}

} // namespace pikiwidb
11 changes: 11 additions & 0 deletions src/cmd_admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,15 @@ class CmdConfigSet : public BaseCmd {
void DoCmd(PClient* client) override;
};

class FlushdbCmd : public BaseCmd {
public:
FlushdbCmd(const std::string& name, int16_t arity);

protected:
bool DoInitial(PClient* client) override;

private:
void DoCmd(PClient* client) override;
};

} // namespace pikiwidb
Loading

0 comments on commit 89a90f7

Please sign in to comment.