Skip to content

Commit

Permalink
avoid using std::vector to pass blob references
Browse files Browse the repository at this point in the history
  • Loading branch information
kuron99 committed Jan 16, 2025
1 parent 1d25c06 commit 349fc64
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 18 deletions.
27 changes: 21 additions & 6 deletions include/shirakami/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ Status init(database_options options = {}); // NOLINT
* @param[in] storage the handle of storage.
* @param[in] key the key of the inserted record
* @param[in] val the value of the inserted record
* @param[in] used_blobs the blob references used by the inserted record
* @param[in] blobs_data blob references list used by the inserted record.
* The blobs will be fully registered on datastore when transaction successfully commits.
* Specify nullptr to pass empty list if the inserted record does not contain blob.
* @param[in] blobs_size length of the blob references list
* Specify 0 to pass empty list.
* @return Status::ERR_CC Error about concurrency control.
* @return Status::OK success. If this tx executed delete operation, this insert
* change the operation into update operation which updates using @a val.
Expand All @@ -208,7 +212,8 @@ Status init(database_options options = {}); // NOLINT
Status insert(Token token, Storage storage,
std::string_view key, // NOLINT
std::string_view val,
std::vector<blob_id_type> const& used_blobs = {}
blob_id_type const* blobs_data = nullptr,
std::size_t blobs_size = 0
);

/**
Expand Down Expand Up @@ -396,7 +401,11 @@ Status tx_begin(transaction_options options = {}); // NOLINT
* @param[in] storage the handle of storage.
* @param[in] key the key of the updated record
* @param[in] val the value of the updated record
* @param[in] used_blobs the blob references used by the updated record
* @param[in] blobs_data blob references list used by the updated record.
* The blobs will be fully registered on datastore when transaction successfully commits.
* Specify nullptr to pass empty list if the updated record does not contain blob.
* @param[in] blobs_size length of the blob references list
* Specify 0 to pass empty list.
* @return Status::OK Success.
* @return Status::WARN_ILLEGAL_OPERATION You execute update on read only
* mode. So this operation was canceled.
Expand All @@ -409,7 +418,8 @@ Status tx_begin(transaction_options options = {}); // NOLINT
* @return Status::ERR_READ_AREA_VIOLATION error about read area.
*/
Status update(Token token, Storage storage, std::string_view key, std::string_view val,
std::vector<blob_id_type> const& used_blobs = {}); // NOLINT
blob_id_type const* blobs_data = nullptr,
std::size_t blobs_size = 0); // NOLINT

/**
* @brief update the record for the given key, or insert the key/value if the
Expand All @@ -418,7 +428,11 @@ Status update(Token token, Storage storage, std::string_view key, std::string_vi
* @param[in] storage the handle of storage.
* @param[in] key the key of the upserted record
* @param[in] val the value of the upserted record
* @param[in] used_blobs the blob references used by the upserted record
* @param[in] blobs_data blob references list used by the upserted record.
* The blobs will be fully registered on datastore when transaction successfully commits.
* Specify nullptr to pass empty list if the upserted record does not contain blob.
* @param[in] blobs_size length of the blob references list
* Specify 0 to pass empty list.
* @return Status::ERR_CC Error about concurrency control.
* @return Status::OK Success
* @return Status::WARN_ILLEGAL_OPERATION You execute upsert on read only
Expand All @@ -434,7 +448,8 @@ Status update(Token token, Storage storage, std::string_view key, std::string_vi
* this tx is long tx and didn't execute wp for @a storage.
*/
Status upsert(Token token, Storage storage, std::string_view key, std::string_view val,
std::vector<blob_id_type> const& used_blobs = {}); // NOLINT
blob_id_type const* blobs_data = nullptr,
std::size_t blobs_size = 0); // NOLINT


//==========
Expand Down
4 changes: 3 additions & 1 deletion src/concurrency_control/interface/insert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ Status insert_body(Token const token, Storage const storage, // NOLINT
Status insert(Token const token, Storage const storage, // NOLINT
const std::string_view key, // NOLINT
const std::string_view val,
[[maybe_unused]] std::vector<blob_id_type> const& used_blobs) {
[[maybe_unused]] blob_id_type const* blobs_data,
[[maybe_unused]] std::size_t blobs_size) {
//TODO implement blobs
shirakami_log_entry << "insert, token: " << token
<< ", storage: " << storage << shirakami_binstring(key)
<< shirakami_binstring(val);
Expand Down
4 changes: 3 additions & 1 deletion src/concurrency_control/interface/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ Status update_body(Token token, Storage storage,
Status update(Token token, Storage storage,
std::string_view const key, // NOLINT
std::string_view const val,
[[maybe_unused]] std::vector<blob_id_type> const& used_blobs) {
[[maybe_unused]] blob_id_type const* blobs_data,
[[maybe_unused]] std::size_t blobs_size) {
//TODO implement blobs
shirakami_log_entry << "update, token: " << token
<< ", storage: " << storage << shirakami_binstring(key)
<< shirakami_binstring(val);
Expand Down
4 changes: 3 additions & 1 deletion src/concurrency_control/interface/upsert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ Status upsert_body(Token token, Storage storage, const std::string_view key,

Status upsert(Token token, Storage storage, std::string_view const key,
std::string_view const val,
[[maybe_unused]] std::vector<blob_id_type> const& used_blobs) {
[[maybe_unused]] blob_id_type const* blobs_data,
[[maybe_unused]] std::size_t blobs_size) {
//TODO implement blobs
shirakami_log_entry << "upsert, token: " << token << ", storage; "
<< storage << shirakami_binstring(key)
<< shirakami_binstring(val);
Expand Down
6 changes: 3 additions & 3 deletions test/tsurugi_issues/tsurugi_issue665_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ TEST_P(tsurugi_issue665_test, // NOLINT
ASSERT_OK(commit(t));

// prepare write operator
std::function<Status(Token, Storage, std::string_view, std::string_view, std::vector<blob_id_type> const&)>
std::function<Status(Token, Storage, std::string_view, std::string_view, blob_id_type const*, std::size_t)>
write;
if (GetParam()) {
write = insert;
Expand Down Expand Up @@ -270,7 +270,7 @@ TEST_P(tsurugi_issue665_test, // NOLINT

// write st1, st2
rc = write(t, st1, std::to_string(count + 1),
std::to_string(count + 1), std::vector<blob_id_type>{});
std::to_string(count + 1), nullptr, 0);
ASSERT_TRUE(rc == Status::WARN_ALREADY_EXISTS || rc == Status::OK ||
rc == Status::ERR_CC);
if (rc == Status::WARN_ALREADY_EXISTS) { abort(t); }
Expand All @@ -280,7 +280,7 @@ TEST_P(tsurugi_issue665_test, // NOLINT
}
ASSERT_OK(rc);
rc = write(t, st2, std::to_string(count + 1),
std::to_string(count + 1), std::vector<blob_id_type>{});
std::to_string(count + 1), nullptr, 0);
ASSERT_TRUE(rc == Status::WARN_ALREADY_EXISTS || rc == Status::OK ||
rc == Status::ERR_CC);
if (rc == Status::WARN_ALREADY_EXISTS) { abort(t); }
Expand Down
6 changes: 3 additions & 3 deletions test/tsurugi_issues/tsurugi_issue707_3_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ TEST_P(tsurugi_issue707_3_test, // NOLINT
ASSERT_OK(commit(t));

// prepare write operator
std::function<Status(Token, Storage, std::string_view, std::string_view, std::vector<blob_id_type> const&)>
std::function<Status(Token, Storage, std::string_view, std::string_view, blob_id_type const*, std::size_t)>
write;
if (GetParam()) {
write = insert;
Expand Down Expand Up @@ -208,7 +208,7 @@ TEST_P(tsurugi_issue707_3_test, // NOLINT
ASSERT_OK(rc);

// write st1
rc = write(t, st1, gen_st1_key(count + 1), gen_st1_key(count + 1), std::vector<blob_id_type>{});
rc = write(t, st1, gen_st1_key(count + 1), gen_st1_key(count + 1), nullptr, 0);
ASSERT_TRUE(rc == Status::WARN_ALREADY_EXISTS || rc == Status::OK ||
rc == Status::ERR_CC);
if (rc == Status::WARN_ALREADY_EXISTS) {
Expand All @@ -232,7 +232,7 @@ TEST_P(tsurugi_issue707_3_test, // NOLINT
// write st2
for (std::size_t i = 0; i < st2_insert_unit; ++i) {
rc = write(t, st2, gen_st2_key(count + 1, i),
gen_st2_key(count + 1, i), std::vector<blob_id_type>{});
gen_st2_key(count + 1, i), nullptr, 0);
ASSERT_TRUE(rc == Status::WARN_ALREADY_EXISTS ||
rc == Status::OK || rc == Status::ERR_CC);
if (rc == Status::WARN_ALREADY_EXISTS) {
Expand Down
6 changes: 3 additions & 3 deletions test/tsurugi_issues/tsurugi_issue707_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ TEST_P(tsurugi_issue707_test, // NOLINT
ASSERT_OK(commit(t));

// prepare write operator
std::function<Status(Token, Storage, std::string_view, std::string_view, std::vector<blob_id_type> const&)>
std::function<Status(Token, Storage, std::string_view, std::string_view, blob_id_type const*, std::size_t)>
write;
if (GetParam()) {
write = insert;
Expand Down Expand Up @@ -200,7 +200,7 @@ TEST_P(tsurugi_issue707_test, // NOLINT

// write st1
rc = write(t, st1, std::to_string(count + 1),
std::to_string(count + 1), std::vector<blob_id_type>{});
std::to_string(count + 1), nullptr, 0);
ASSERT_TRUE(rc == Status::WARN_ALREADY_EXISTS || rc == Status::OK ||
rc == Status::ERR_CC);
if (rc == Status::WARN_ALREADY_EXISTS) {
Expand All @@ -223,7 +223,7 @@ TEST_P(tsurugi_issue707_test, // NOLINT

// write st2
rc = write(t, st2, std::to_string(count + 1),
std::to_string(count + 1), std::vector<blob_id_type>{});
std::to_string(count + 1), nullptr, 0);
ASSERT_TRUE(rc == Status::WARN_ALREADY_EXISTS || rc == Status::OK ||
rc == Status::ERR_CC);
if (rc == Status::WARN_ALREADY_EXISTS) {
Expand Down

0 comments on commit 349fc64

Please sign in to comment.