Hazelcast C++ Client
Hazelcast C++ Client Library
read_result_set.h
1 /*
2  * Copyright (c) 2008-2022, 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 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
21 #pragma warning(push)
22 #pragma warning(disable : 4251) // for dll export
23 #endif
24 
25 namespace hazelcast {
26 namespace client {
27 namespace rb {
28 class HAZELCAST_API read_result_set
29 {
30 public:
36  static const int64_t SEQUENCE_UNAVAILABLE = -1;
37 
39  int32_t read_count,
40  std::vector<serialization::pimpl::data>&& data_items,
41  serialization::pimpl::SerializationService& serialization_service,
42  boost::optional<std::vector<int64_t>>& item_seqs,
43  int64_t next_seq)
44  : items_read_count_(read_count)
45  , item_seqs_(std::move(item_seqs))
46  , next_seq_(next_seq)
47  {
48  for (auto&& item : data_items) {
49  items_.emplace_back(item, serialization_service);
50  }
51  }
52 
66  int32_t read_count() const { return items_read_count_; }
67 
68  const std::vector<typed_data>& get_items() const { return items_; }
69 
78  int64_t get_sequence(int32_t index) const
79  {
80  if (index >= (int32_t)item_seqs_->size() || index < 0) {
81  BOOST_THROW_EXCEPTION(
83  "read_result_set::getSequence")
84  << "Index " << index
85  << " is out of bounds. Sequences size is:" << item_seqs_->size())
86  .build());
87  }
88 
89  return (*item_seqs_)[index];
90  }
91 
114  int64_t get_next_sequence_to_read_from() const { return next_seq_; }
115 
116 private:
117  int32_t items_read_count_;
118  std::vector<typed_data> items_;
119  boost::optional<std::vector<int64_t>> item_seqs_;
120  int64_t next_seq_;
121 };
122 } // namespace rb
123 } // namespace client
124 } // namespace hazelcast
125 
126 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
127 #pragma warning(pop)
128 #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.