Hazelcast C++ Client
Hazelcast C++ Client Library
Loading...
Searching...
No Matches
read_result_set.h
1/*
2 * Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include <vector>
19
20#include <boost/optional.hpp>
21
22#include "hazelcast/client/serialization/pimpl/data.h"
23
24#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
25#pragma warning(push)
26#pragma warning(disable : 4251) // for dll export
27#endif
28
29namespace hazelcast {
30namespace client {
31namespace rb {
32class HAZELCAST_API read_result_set
33{
34public:
40 static const int64_t SEQUENCE_UNAVAILABLE = -1;
41
42 read_result_set(
43 int32_t read_count,
44 std::vector<serialization::pimpl::data>&& data_items,
45 serialization::pimpl::SerializationService& serialization_service,
46 boost::optional<std::vector<int64_t>>& item_seqs,
47 int64_t next_seq)
48 : items_read_count_(read_count)
49 , item_seqs_(std::move(item_seqs))
50 , next_seq_(next_seq)
51 {
52 for (auto&& item : data_items) {
53 items_.emplace_back(item, serialization_service);
54 }
55 }
56
70 int32_t read_count() const { return items_read_count_; }
71
72 const std::vector<typed_data>& get_items() const { return items_; }
73
82 int64_t get_sequence(int32_t index) const
83 {
84 if (index >= (int32_t)item_seqs_->size() || index < 0) {
85 BOOST_THROW_EXCEPTION(
87 "read_result_set::getSequence")
88 << "Index " << index
89 << " is out of bounds. Sequences size is:" << item_seqs_->size())
90 .build());
91 }
92
93 return (*item_seqs_)[index];
94 }
95
118 int64_t get_next_sequence_to_read_from() const { return next_seq_; }
119
120private:
121 int32_t items_read_count_;
122 std::vector<typed_data> items_;
123 boost::optional<std::vector<int64_t>> item_seqs_;
124 int64_t next_seq_;
125};
126} // namespace rb
127} // namespace client
128} // namespace hazelcast
129
130#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
131#pragma warning(pop)
132#endif
int64_t get_sequence(int32_t index) const
Return the sequence number for the item at the given index.
int32_t read_count() const
Returns the number of items that have been read before filtering.
int64_t get_next_sequence_to_read_from() const
Returns the sequence of the item following the last read item.
static const int64_t SEQUENCE_UNAVAILABLE
Value returned from methods returning a sequence number when the information is not available (e....
STL namespace.