OpenAtomFoundation / pikiwidb

a high-performance, large-capacity, multi-tenant, data-persistent, strong data consistency based on raft, Redis-compatible elastic KV data storage system based on RocksDB
BSD 3-Clause "New" or "Revised" License
201 stars 63 forks source link

feat: Adjust the UnboundedBuffer::PushData() function to C++ style. #234

Closed KKorpse closed 7 months ago

KKorpse commented 7 months ago

Which PikiwiDB functionalities are relevant/related to the feature request?

No response

Description

这个接口有点太过于原始了,用起来很别扭,字符数量是靠人来数的: image

Proposed solution

其实可以简单封装一下,提供一个这样的接口,使用起来合理一点。

std::size_t UnboundedBuffer::PushData(const std::string_view& data) {
  return PushData(data.data(), data.size());
}

新接口使用方式:

  UnboundedBuffer req;
  req.PushData("RAFT.NODE ADD ");

Alternatives considered

现在总共需要修改的地方也不多,总共 36 处左右,可以考虑换一下? image

hnwyllmm commented 7 months ago

给我试一下?

Issues-translate-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically.


Give me a try?

KKorpse commented 7 months ago

给我试一下?

ok

Issues-translate-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically.


Give me a try?

OK

hnwyllmm commented 7 months ago

string_view 是C++17才支持的,但是pikiwidb希望使用的是C++11。 替代方案是实现 const char 版本的函数,但是使用const char 版本会降低性能。 有什么建议吗?

Issues-translate-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically.


string_view is only supported by C++17, but pikiwidb hopes to use C++11. The alternative is to implement a const char version of the function, but using the const char version will reduce performance. Any suggestions?

KKorpse commented 7 months ago

string_view 是C++17才支持的,但是pikiwidb希望使用的是C++11。 替代方案是实现 const char 版本的函数,但是使用const char 版本会降低性能。 有什么建议吗?

README 有点过时了,正在重新写。 其实最高用到 C++ 20 都行,不一定限制在 11。

Cmake 文件有这么一行

SET(CMAKE_CXX_STANDARD 20)