-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add and modify headers and documentation for BLOB support (#80)
- Loading branch information
Showing
9 changed files
with
239 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# BLOB API | ||
|
||
本ドキュメントは、BLOB対応のためにLimestoneに追加および変更されるAPIについて記述する。 | ||
|
||
このドキュメントは、BLOB対応に伴う他モジュールとの連携および仕様調整を目的として作成する。 | ||
記載内容は作成時点の仕様に基づいているが、将来の仕様変更に際して本ドキュメントが必ずしも | ||
更新されるわけではない。そのため、最新の仕様については、必ずソースコードを参照すること。 | ||
|
||
本ドキュメントでは、追加および変更されるヘッダごとに、対応するAPIについて記述する。 | ||
APIの詳細については、各ヘッダのコメントを参照すること。 | ||
|
||
## blob_pool.h の追加 | ||
|
||
**新規追加項目** | ||
|
||
* blob_id_type | ||
* blob参照を表す型 | ||
|
||
* class blob_pool | ||
* BLOB プールの作成、破棄、および BLOB データの仮登録のためのクラス。 | ||
* BLOB プールは、`datastore::acquire_blob_pool()` で取得可能。 | ||
|
||
## blob_file.h の追加 | ||
|
||
**新規追加項目** | ||
|
||
* class blob_file | ||
* BLOB データにアクセスするためのクラス。 | ||
* BLOB ファイルのインスタンスは、`datastore::get_blob_file(blob_id_type reference)` で取得可能。 | ||
* BLOB ファイルから BLOB を保存しているファイルのパスを取得し、ファイルを読むことによりBLOBデータにアクセスできる。 | ||
|
||
|
||
## datastore.h の修正 | ||
|
||
**追加メソッド** | ||
|
||
* `std::unique_ptr<blob_pool> datastore::acquire_blob_pool()` | ||
* BLOB プールの取得のためのメソッド。 | ||
|
||
* `blob_file datastore::get_blob_file(blob_id_type reference)` | ||
* BLOB ファイルの取得のためのメソッド。 | ||
|
||
* `void switch_available_boundary_version(write_version_type version)` | ||
* LimestoneがBLOBデータを削除するには、その BLOB への参照を有するバージョンのエントリが誰からも参照されなくなっていることが必要となる。 | ||
これを判断するための情報は、 CC からデータストアに通知するためのメソッド。 | ||
* LimestoneはGCによるBLOBデータ削除時に、削除可能なデータの判断のためにこのメソッドで通知された値を使用する。 | ||
* コンパクション時のGCで、このメソッドで通知された値を使用する。 | ||
* 起動時のGCでは、永続化データから参照されていないBLOBデータを無条件で削除する。 | ||
|
||
## log_channel.h の修正 | ||
|
||
**add_entry メソッドのシグネチャ変更** | ||
|
||
**修正前** | ||
```cpp | ||
void add_entry( | ||
storage_id_type storage_id, | ||
std::string_view key, | ||
std::string_view value, | ||
write_version_type write_version, | ||
const std::vector<large_object_input>& large_objects | ||
); | ||
``` | ||
|
||
**修正後** | ||
```cpp | ||
void add_entry( | ||
storage_id_type storage_id, | ||
std::string_view key, | ||
std::string_view value, | ||
write_version_type write_version, | ||
const std::vector<blob_id_type>& large_objects | ||
); | ||
``` | ||
|
||
|
||
## large_object_input.h, large_object_view.h の削除 | ||
|
||
BLOB対応の方針変更により、以下のクラスを廃止しました。それに伴い、該当ヘッダファイルを削除しています。 | ||
|
||
* large_object_input クラス | ||
* large_object_view クラス | ||
|
||
|
||
## cursor.h の修正 | ||
|
||
BLOB対応の方針変更により、以下のメソッドを廃止しました。 | ||
|
||
* `std::vector<large_object_view>& large_objects();` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright 2022-2025 Project Tsurugi. | ||
* | ||
* Licensed 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. | ||
*/ | ||
#pragma once | ||
|
||
#include <boost/filesystem.hpp> | ||
|
||
namespace limestone::api { | ||
|
||
/// @brief BLOB reference type. | ||
using blob_id_type = std::uint64_t; | ||
|
||
/** | ||
* @brief represents a pool for provisional registration of BLOB data. | ||
*/ | ||
class blob_pool { | ||
public: | ||
|
||
/** | ||
* @brief creates a new object. | ||
*/ | ||
blob_pool() = default; | ||
|
||
/** | ||
* @brief destroys this object. | ||
*/ | ||
virtual ~blob_pool() = default; | ||
|
||
blob_pool(blob_pool const&) = delete; | ||
blob_pool(blob_pool&&) = delete; | ||
blob_pool& operator=(blob_pool const&) = delete; | ||
blob_pool& operator=(blob_pool&&) = delete; | ||
|
||
/** | ||
* @brief Discards all BLOB data provisionally registered in this pool, except for those that have already been persistent. | ||
* @note After this operation, this pool will be unusable. | ||
* @note This operation is idempotent. | ||
* @attention Undefined behavior if attempting to access the data of non-persistent BLOBs in this pool after this operation. | ||
* It depends on the implementation when the BLOB data is actually removed. | ||
*/ | ||
virtual void release() = 0; | ||
|
||
/** | ||
* @brief registers a BLOB file provisionally into this BLOB pool. | ||
* @param is_temporary_file true to allow remove the source file, or false to copy the source file | ||
* @return the corresponding BLOB reference | ||
* @attention This only act as provisional registration for the BLOB, and it may be lost after release() was called. | ||
* To avoid it, you need to pass the BLOB references to log_channel::add_entry() to persistent them. | ||
* @throws std::invalid_state if this pool is already released | ||
*/ | ||
[[nodiscard]] virtual blob_id_type register_file( | ||
boost::filesystem::path const& file, | ||
bool is_temporary_file) = 0; | ||
|
||
/** | ||
* @brief registers a BLOB data provisionally into this BLOB pool. | ||
* @param data the target BLOB data | ||
* @return the corresponding BLOB reference | ||
* @attention This only act as provisional registration for the BLOB, and it may be lost after release() was called. | ||
* To avoid it, you need to pass the BLOB references to log_channel::add_entry() to persistent them. | ||
* @throws std::invalid_state if this pool is already released | ||
*/ | ||
[[nodiscard]] virtual blob_id_type register_data(std::string_view data) = 0; | ||
|
||
/** | ||
* @brief duplicates the registered BLOB data, and registers the copy provisionally into this BLOB pool. | ||
* @param reference the source BLOB reference | ||
* @return the corresponding BLOB reference of the duplicated one | ||
* @attention This only act as provisional registration for the BLOB, and it may be lost after release() was called. | ||
* To avoid it, you need to pass the BLOB references to log_channel::add_entry() to persistent them. | ||
* @throws std::invalid_state if this pool is already released | ||
*/ | ||
[[nodiscard]] virtual blob_id_type duplicate_data(blob_id_type reference) = 0; | ||
}; | ||
|
||
} // namespace limestone::api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters