Skip to content

Commit 3c3f408

Browse files
authored
Fixes for PageView::get_keys parameters (#177)
* Initial commit * Made slice a const ref
1 parent 0b8f56d commit 3c3f408

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

src/llfs/api_types.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ BATT_STRONG_TYPEDEF(usize, BufferSize);
8585
*/
8686
BATT_STRONG_TYPEDEF(bool, HasOutgoingRefs);
8787

88+
/** \brief An index into a collection of items.
89+
*/
90+
BATT_STRONG_TYPEDEF(usize, ItemOffset);
91+
8892
} // namespace llfs
8993

9094
#endif // LLFS_API_TYPES_HPP

src/llfs/page_view.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ Status PageView::validate(PageId expected_id)
3737
return OkStatus();
3838
}
3939

40-
StatusOr<usize> PageView::get_keys([[maybe_unused]] LowerBoundParam lower_bound,
41-
[[maybe_unused]] KeyView* key_buffer_out,
42-
[[maybe_unused]] usize key_buffer_size,
40+
StatusOr<usize> PageView::get_keys([[maybe_unused]] ItemOffset lower_bound,
41+
[[maybe_unused]] const Slice<KeyView>& key_buffer_out,
4342
[[maybe_unused]] StableStringStore& storage) const
4443
{
4544
return StatusOr<usize>{batt::StatusCode::kUnimplemented};

src/llfs/page_view.hpp

+10-12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#ifndef LLFS_PAGE_VIEW_HPP
1111
#define LLFS_PAGE_VIEW_HPP
1212

13+
#include <llfs/api_types.hpp>
1314
#include <llfs/key.hpp>
1415
#include <llfs/optional.hpp>
1516
#include <llfs/page_buffer.hpp>
@@ -33,7 +34,6 @@ class PageView
3334
{
3435
public:
3536
//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
36-
using LowerBoundParam = std::variant<KeyView, usize>;
3737

3838
explicit PageView(std::shared_ptr<const PageBuffer>&& data) noexcept
3939
: data_{std::move(data)}
@@ -94,29 +94,27 @@ class PageView
9494
*/
9595
virtual Optional<KeyView> max_key() const = 0;
9696

97-
/** \brief Retrieves at most `key_buffer_size` number of keys contained in this page.
97+
/** \brief Retrieves at most the size of `key_buffer_out` number of keys contained in this page.
9898
*
9999
* \param lower_bound This parameter allows for "skipping" to an arbitrary place in the page's key
100-
* set. The caller can provide either a `KeyView` value or an index into the key set, which
101-
* represents the starting key from which this function will collect keys from to return.
100+
* set. The caller should provide an index (offset) into the key set, which represents the
101+
* starting key from which this function will collect keys from to return.
102102
*
103103
* \param key_buffer_out The output buffer that will be filled by this function with the requested
104104
* keys.
105105
*
106-
* \param key_buffer_size The size of the output buffer holding the returned keys.
107-
*
108106
* \param storage A `StableStringStore` instance that the caller can provide so that the returned
109107
* keys can still be a list of `KeyView` even if the keys in the page are stored in a way that
110108
* isn't contiguous or are compressed. Specific implementations of `PageView` will choose to use
111109
* this based on their key storage.
112110
*
113-
* \return The number of keys filled into `key_buffer_out`. This value will either be
114-
* `key_buffer_size` or the number of keys between `lower_bound` and the end of the key set,
115-
* whichever is smaller. In the event that the `lower_bound` parameter provided does not exist in
116-
* the key set (or is out of the range of the key set), this function will return 0.
111+
* \return The number of keys filled into `key_buffer_out`. This value will either be the size of
112+
* `key_buffer_out` or the number of keys between `lower_bound` and the end of the key set,
113+
* whichever is smaller. In the event that the `lower_bound` parameter provided is out of the
114+
* range of the key set, this function will return 0.
117115
*/
118-
virtual StatusOr<usize> get_keys(LowerBoundParam lower_bound, KeyView* key_buffer_out,
119-
usize key_buffer_size, StableStringStore& storage) const;
116+
virtual StatusOr<usize> get_keys(ItemOffset lower_bound, const Slice<KeyView>& key_buffer_out,
117+
StableStringStore& storage) const;
120118

121119
// Builds a key-based approximate member query (AMQ) filter for the page, to answer the question
122120
// whether a given key *might* be contained by the page.

0 commit comments

Comments
 (0)