Hazelcast C++ Client
Hazelcast C++ Client Library
read_result_set.h
1 /*
2  * Copyright (c) 2008-2021, 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  public:
35  static const int64_t SEQUENCE_UNAVAILABLE = -1;
36 
37  read_result_set(int32_t read_count, std::vector<serialization::pimpl::data> &&data_items,
38  serialization::pimpl::SerializationService &serialization_service,
39  boost::optional<std::vector<int64_t>> &item_seqs, int64_t next_seq)
40  : items_read_count_(read_count), item_seqs_(std::move(item_seqs)), next_seq_(next_seq) {
41  for (auto &&item : data_items) {
42  items_.emplace_back(item, serialization_service);
43  }
44  }
45 
59  int32_t read_count() const {
60  return items_read_count_;
61  }
62 
63  const std::vector<typed_data> &get_items() const {
64  return items_;
65  }
66 
75  int64_t get_sequence(int32_t index) const {
76  if (index >= (int32_t) item_seqs_->size() || index < 0) {
78  "read_result_set::getSequence") << "Index " << index
79  << " is out of bounds. Sequences size is:"
80  << item_seqs_->size()).build());
81  }
82 
83  return (*item_seqs_)[index];
84  }
85 
108  return next_seq_;
109  }
110 
111  private:
112  int32_t items_read_count_;
113  std::vector<typed_data> items_;
114  boost::optional<std::vector<int64_t>> item_seqs_;
115  int64_t next_seq_;
116  };
117  }
118  }
119 }
120 
121 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
122 #pragma warning(pop)
123 #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.