Skip to content

Commit

Permalink
fix: delete slot (OpenAtomFoundation#2251)
Browse files Browse the repository at this point in the history
* delets kv slot

* delete cmd slot

* delete cache slot

* delete slot command

* delete pika_slot.cc/h

* delete sharding code

* delete slot

* Add DB Shared_ptr in Cmd

---------

Co-authored-by: wuxianrong <[email protected]>
  • Loading branch information
Mixficsol and wuxianrong authored Jan 19, 2024
1 parent 5276adb commit 39fc96e
Show file tree
Hide file tree
Showing 108 changed files with 4,479 additions and 6,128 deletions.
4 changes: 2 additions & 2 deletions include/pika_acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class PikaAclCmd : public Cmd {
subCmdName_ = {"cat", "deluser", "dryrun", "genpass", "getuser", "list", "load",
"log", "save", "setuser", "users", "whoami", "help"};
}
void Do(std::shared_ptr<Slot> slot = nullptr) override;
void Split(std::shared_ptr<Slot> slot, const HintKeys& hint_keys) override{};
void Do() override;
void Split(const HintKeys& hint_keys) override{};
void Merge() override{};
Cmd* Clone() override { return new PikaAclCmd(*this); }

Expand Down
159 changes: 79 additions & 80 deletions include/pika_admin.h

Large diffs are not rendered by default.

14 changes: 2 additions & 12 deletions include/pika_binlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Version final : public pstd::noncopyable {

void debug() {
std::shared_lock l(rwlock_);
printf("Current pro_num %u pro_offset %lu\n", pro_num_, pro_offset_);
printf("Current pro_num %u pro_offset %llu\n", pro_num_, pro_offset_);
}

private:
Expand All @@ -63,12 +63,8 @@ class Binlog : public pstd::noncopyable {
// Need to hold Lock();
pstd::Status Truncate(uint32_t pro_num, uint64_t pro_offset, uint64_t index);

uint64_t file_size() { return file_size_; }

std::string filename() { return filename_; }

bool IsBinlogIoError() { return binlog_io_error_; }

// need to hold mutex_
void SetTerm(uint32_t term) {
std::lock_guard l(version_->rwlock_);
Expand All @@ -85,11 +81,9 @@ class Binlog : public pstd::noncopyable {

private:
pstd::Status Put(const char* item, int len);
pstd::Status EmitPhysicalRecord(RecordType t, const char* ptr, size_t n, int* temp_pro_offset);
static pstd::Status AppendPadding(pstd::WritableFile* file, uint64_t* len);
// pstd::WritableFile *queue() { return queue_; }

void InitLogFile();
pstd::Status EmitPhysicalRecord(RecordType t, const char* ptr, size_t n, int* temp_pro_offset);

/*
* Produce
Expand All @@ -109,17 +103,13 @@ class Binlog : public pstd::noncopyable {

int block_offset_ = 0;

char* pool_ = nullptr;
bool exit_all_consume_ = false;
const std::string binlog_path_;

uint64_t file_size_ = 0;

std::string filename_;

std::atomic<bool> binlog_io_error_;
// Not use
// int32_t retry_;
};

#endif
3 changes: 0 additions & 3 deletions include/pika_binlog_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

#include "include/pika_binlog.h"

// using pstd::Slice;
// using pstd::Status;

class PikaBinlogReader {
public:
PikaBinlogReader(uint32_t cur_filenum, uint64_t cur_offset);
Expand Down
53 changes: 26 additions & 27 deletions include/pika_bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "include/acl.h"
#include "include/pika_command.h"
#include "include/pika_kv.h"
#include "include/pika_slot.h"

/*
* bitoperation
Expand All @@ -25,11 +24,11 @@ class BitGetCmd : public Cmd {
res.push_back(key_);
return res;
}
void Do(std::shared_ptr<Slot> slot = nullptr) override;
void ReadCache(std::shared_ptr<Slot> slot = nullptr) override;
void DoUpdateCache(std::shared_ptr<Slot> slot = nullptr) override;
void DoThroughDB(std::shared_ptr<Slot> slot = nullptr) override;
void Split(std::shared_ptr<Slot> slot, const HintKeys& hint_keys) override {};
void Do() override;
void ReadCache() override;
void DoUpdateCache() override;
void DoThroughDB() override;
void Split(const HintKeys& hint_keys) override {};
void Merge() override {};
Cmd* Clone() override { return new BitGetCmd(*this); }

Expand All @@ -53,10 +52,10 @@ class BitSetCmd : public Cmd {
res.push_back(key_);
return res;
}
void Do(std::shared_ptr<Slot> slot = nullptr) override;
void DoUpdateCache(std::shared_ptr<Slot> slot = nullptr) override;
void DoThroughDB(std::shared_ptr<Slot> slot = nullptr) override;
void Split(std::shared_ptr<Slot> slot, const HintKeys& hint_keys) override {};
void Do() override;
void DoUpdateCache() override;
void DoThroughDB() override;
void Split(const HintKeys& hint_keys) override {};
void Merge() override {};
Cmd* Clone() override { return new BitSetCmd(*this); }

Expand All @@ -82,11 +81,11 @@ class BitCountCmd : public Cmd {
res.push_back(key_);
return res;
}
void Do(std::shared_ptr<Slot> slot = nullptr) override;
void ReadCache(std::shared_ptr<Slot> slot = nullptr) override;
void DoUpdateCache(std::shared_ptr<Slot> slot = nullptr) override;
void DoThroughDB(std::shared_ptr<Slot> slot = nullptr) override;
void Split(std::shared_ptr<Slot> slot, const HintKeys& hint_keys) override {};
void Do() override;
void ReadCache() override;
void DoUpdateCache() override;
void DoThroughDB() override;
void Split(const HintKeys& hint_keys) override {};
void Merge() override {};
Cmd* Clone() override { return new BitCountCmd(*this); }

Expand Down Expand Up @@ -114,11 +113,11 @@ class BitPosCmd : public Cmd {
res.push_back(key_);
return res;
}
void Do(std::shared_ptr<Slot> slot = nullptr) override;
void ReadCache(std::shared_ptr<Slot> slot = nullptr) override;
void DoUpdateCache(std::shared_ptr<Slot> slot = nullptr) override;
void DoThroughDB(std::shared_ptr<Slot> slot = nullptr) override;
void Split(std::shared_ptr<Slot> slot, const HintKeys& hint_keys) override {};
void Do() override;
void ReadCache() override;
void DoUpdateCache() override;
void DoThroughDB() override;
void Split(const HintKeys& hint_keys) override {};
void Merge() override {};
Cmd* Clone() override { return new BitPosCmd(*this); }

Expand All @@ -145,25 +144,25 @@ class BitOpCmd : public Cmd {
public:
BitOpCmd(const std::string& name, int arity, uint32_t flag)
: Cmd(name, arity, flag, static_cast<uint32_t>(AclCategory::BITMAP)) {
set_cmd_ = std::make_shared<SetCmd>(kCmdNameSet, -3, kCmdFlagsWrite | kCmdFlagsSingleSlot | kCmdFlagsKv);
set_cmd_ = std::make_shared<SetCmd>(kCmdNameSet, -3, kCmdFlagsWrite | kCmdFlagsKv);
};
BitOpCmd(const BitOpCmd& other)
: Cmd(other),
dest_key_(other.dest_key_),
src_keys_(other.src_keys_),
op_(other.op_),
value_to_dest_(other.value_to_dest_) {
set_cmd_ = std::make_shared<SetCmd>(kCmdNameSet, -3, kCmdFlagsWrite | kCmdFlagsSingleSlot | kCmdFlagsKv);
set_cmd_ = std::make_shared<SetCmd>(kCmdNameSet, -3, kCmdFlagsWrite | kCmdFlagsKv);
}

std::vector<std::string> current_key() const override { return {dest_key_}; }
void Do(std::shared_ptr<Slot> slot = nullptr) override;
void DoUpdateCache(std::shared_ptr<Slot> slot = nullptr) override;
void DoThroughDB(std::shared_ptr<Slot> slot = nullptr) override;
void Split(std::shared_ptr<Slot> slot, const HintKeys& hint_keys) override{};
void Do() override;
void DoUpdateCache() override;
void DoThroughDB() override;
void Split(const HintKeys& hint_keys) override{};
void Merge() override{};
Cmd* Clone() override { return new BitOpCmd(*this); }
void DoBinlog(const std::shared_ptr<SyncMasterSlot>& slot) override;
void DoBinlog() override;

private:
std::string dest_key_;
Expand Down
Loading

0 comments on commit 39fc96e

Please sign in to comment.