21 #include "kinetic/key_range_iterator.h"
29 KeyRangeIterator KeyRangeEnd() {
34 KeyRangeIterator::KeyRangeIterator()
41 reverse_order_(false),
46 KeyRangeIterator::KeyRangeIterator(
47 BlockingKineticConnection* p,
55 first_inc_(start_inclusive),
57 last_inc_(end_inclusive),
59 reverse_order_(false),
66 KeyRangeIterator::KeyRangeIterator(
const KeyRangeIterator& rhs)
69 first_inc_(rhs.first_inc_),
71 last_inc_(rhs.last_inc_),
72 framesz_(rhs.framesz_),
73 reverse_order_(rhs.reverse_order_),
77 if (rhs.keys_.get() != NULL) {
78 this->keys_ = unique_ptr<vector<string>>(
new vector<string>(*rhs.keys_));
83 KeyRangeIterator& KeyRangeIterator::operator=(KeyRangeIterator
const& rhs) {
85 this->bconn_ = rhs.bconn_;
86 this->first_ = rhs.first_;
87 this->first_inc_ = rhs.first_inc_;
88 this->last_ = rhs.last_;
89 this->last_inc_ = rhs.last_inc_;
90 this->framesz_ = rhs.framesz_;
91 this->reverse_order_ = rhs.reverse_order_;
92 this->relpos_ = rhs.relpos_;
93 this->eol_ = rhs.eol_;
95 if (rhs.keys_.get() != NULL) {
96 this->keys_ = unique_ptr<vector<string>>(
new vector<string>(*rhs.keys_));
102 KeyRangeIterator::~KeyRangeIterator() {}
104 bool KeyRangeIterator::operator==(KeyRangeIterator
const& rhs)
const {
105 return ((rhs.eol_ ==
true && this->eol_ ==
true)
106 || (rhs.relpos_ != -1 && this->relpos_ != -1
107 && rhs.keys_.get() != NULL && this->keys_.get() != NULL
108 && (*rhs.keys_)[rhs.relpos_] == (*this->keys_)[this->relpos_]));
111 bool KeyRangeIterator::operator!=(
112 KeyRangeIterator
const& rhs)
const {
113 return !(*
this == rhs);
116 KeyRangeIterator& KeyRangeIterator::operator++() {
117 if (this->relpos_ == -1 || this->keys_.get() == NULL) {
118 throw std::runtime_error(
"Iterator is in a bad state");
126 KeyRangeIterator KeyRangeIterator::operator++(
int unused) {
127 if (this->relpos_ == -1 || this->keys_.get() == NULL) {
128 throw std::runtime_error(
"Iterator is in a bad state");
131 KeyRangeIterator copy(*
this);
138 std::string* KeyRangeIterator::operator->() {
139 if (this->relpos_ == -1 || this->keys_.get() == NULL) {
140 throw std::runtime_error(
"Iterator is in a bad state");
143 throw std::out_of_range(
"Iterator is out of bounds.");
145 return &(*this->keys_)[this->relpos_];
148 const std::string& KeyRangeIterator::operator*()
const {
149 if (this->relpos_ == -1 || this->keys_.get() == NULL) {
150 throw std::runtime_error(
"Iterator is in a bad state");
153 throw std::out_of_range(
"Iterator is out of bounds.");
155 return (*this->keys_)[this->relpos_];
158 void KeyRangeIterator::next_frame() {
160 if (this->relpos_ != -1 && this->keys_.get() != NULL) {
161 this->first_ = (*this->keys_)[this->keys_->size() - 1];
162 this->first_inc_ =
false;
166 this->first_, this->first_inc_,
167 this->last_, this->last_inc_,
168 this->reverse_order_, this->framesz_,
172 throw std::runtime_error(status.message());
176 if (this->keys_.get() == NULL || this->keys_->size() == 0) {
181 void KeyRangeIterator::advance() {
183 if (this->relpos_ == -1
184 || this->relpos_ == static_cast<int>(this->keys_->size())) {
Indicates whether a Kinetic operation (get, put, security, etc) put succeeded or failed. Unlike Status it provides details like whether the failure resulted from a version or an HMAC error.