Couchbase C++ SDK 1.0.2 (rev. 51f4775)
Loading...
Searching...
No Matches
scan_options.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright 2024. Couchbase, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
21#include <couchbase/error.hxx>
25
26#include <cstdint>
27#include <functional>
28#include <optional>
29#include <vector>
30
31namespace couchbase
32{
33
40struct scan_options : public common_options<scan_options> {
41public:
52 {
53 ids_only_ = ids_only;
54 return self();
55 }
56
71 {
72 mutation_state_ = state.tokens();
73 return self();
74 }
75
87 {
88 batch_byte_limit_ = batch_byte_limit;
89 return self();
90 }
91
103 {
104 batch_item_limit_ = batch_item_limit;
105 return self();
106 }
107
117 auto concurrency(std::uint16_t concurrency) -> scan_options&
118 {
119 concurrency_ = concurrency;
120 return self();
121 }
122
129 struct built : public common_options<scan_options>::built {
131 std::vector<mutation_token> mutation_state;
132 std::optional<std::uint32_t> batch_byte_limit;
133 std::optional<std::uint32_t> batch_item_limit;
134 std::optional<std::uint16_t> concurrency;
135 };
136
148 [[nodiscard]] auto build() const -> built
149 {
150 return { build_common_options(), ids_only_, mutation_state_,
151 batch_byte_limit_, batch_item_limit_, concurrency_ };
152 }
153
154private:
155 bool ids_only_{ false };
156 std::vector<mutation_token> mutation_state_{};
157 std::optional<std::uint32_t> batch_byte_limit_{};
158 std::optional<std::uint32_t> batch_item_limit_{};
159 std::optional<std::uint16_t> concurrency_{};
160};
161
168using scan_handler = std::function<void(error, scan_result)>;
169} // namespace couchbase
Common options that used by most operations.
Definition common_options.hxx:37
auto self() -> scan_options &
Definition common_options.hxx:102
auto build_common_options() const -> built
Definition common_options.hxx:89
Definition error.hxx:30
Aggregation of one or more mutation_tokens for specifying consistency requirements of N1QL or FTS que...
Definition mutation_state.hxx:35
Definition scan_result.hxx:44
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
std::function< void(error, scan_result)> scan_handler
The signature for the handler of the collection::scan() operation.
Definition scan_options.hxx:168
Immutable value object representing consistent options.
Definition scan_options.hxx:129
std::vector< mutation_token > mutation_state
Definition scan_options.hxx:131
std::optional< std::uint32_t > batch_byte_limit
Definition scan_options.hxx:132
std::optional< std::uint32_t > batch_item_limit
Definition scan_options.hxx:133
bool ids_only
Definition scan_options.hxx:130
std::optional< std::uint16_t > concurrency
Definition scan_options.hxx:134
Options for collection::scan().
Definition scan_options.hxx:40
auto ids_only(bool ids_only) -> scan_options &
Specifies whether only document IDs should be included in the results.
Definition scan_options.hxx:51
auto batch_item_limit(std::uint32_t batch_item_limit) -> scan_options &
Allows to limit the maximum number of scan items that are sent from the server in each partition batc...
Definition scan_options.hxx:102
auto build() const -> built
Validates options and returns them as an immutable value.
Definition scan_options.hxx:148
auto batch_byte_limit(std::uint32_t batch_byte_limit) -> scan_options &
Allows to limit the maximum amount of bytes that are sent from the server in each partition batch.
Definition scan_options.hxx:86
auto concurrency(std::uint16_t concurrency) -> scan_options &
Specifies the maximum number of partitions that can be scanned concurrently.
Definition scan_options.hxx:117
auto consistent_with(const mutation_state &state) -> scan_options &
Sets the mutation_tokens this scan should be consistent with.
Definition scan_options.hxx:70