| Apache Ignite C++

query_fields_cursor.h
Go to the documentation of this file.
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. 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
23 #ifndef _IGNITE_CACHE_QUERY_QUERY_FIELDS_CURSOR
24 #define _IGNITE_CACHE_QUERY_QUERY_FIELDS_CURSOR
25
26 #include <vector>
27
28 #include <ignite/common/concurrent.h>
29 #include <ignite/ignite_error.h>
30
31 #include "ignite/cache/cache_entry.h"
32 #include "ignite/cache/query/query_fields_row.h"
33 #include "ignite/impl/cache/query/query_impl.h"
34 #include "ignite/impl/operations.h"
35
36 namespace ignite
37 {
38 namespace cache
39 {
40 namespace query
41 {
50 class QueryFieldsCursor
51 {
52 public:
59 QueryFieldsCursor() : impl(0)
60 {
61 // No-op.
62 }
63
71 QueryFieldsCursor(impl::cache::query::QueryCursorImpl* impl) : impl(impl)
72 {
73 // No-op.
74 }
75
85 bool HasNext()
86 {
87 IgniteError err;
88
89 bool res = HasNext(err);
90
91 IgniteError::ThrowIfNeeded(err);
92
93 return res;
94 }
95
106 bool HasNext(IgniteError& err)
107 {
108 impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
109
110 if (impl0)
111 return impl0->HasNext(err);
112 else
113 {
114 err = IgniteError(IgniteError::IGNITE_ERR_GENERIC,
115 "Instance is not usable (did you check for error?).");
116
117 return false;
118 }
119 }
120
130 QueryFieldsRow GetNext()
131 {
132 IgniteError err;
133
134 QueryFieldsRow res = GetNext(err);
135
136 IgniteError::ThrowIfNeeded(err);
137
138 return res;
139 }
140
151 QueryFieldsRow GetNext(IgniteError& err)
152 {
153 impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
154
155 if (impl0)
156 return impl0->GetNextRow(err);
157 else
158 {
159 err = IgniteError(IgniteError::IGNITE_ERR_GENERIC,
160 "Instance is not usable (did you check for error?).");
161
162 return QueryFieldsRow();
163 }
164 }
165
177 bool IsValid() const
178 {
179 return impl.IsValid();
180 }
181
182 private:
184 ignite::common::concurrent::SharedPointer<impl::cache::query::QueryCursorImpl> impl;
185 };
186 }
187 }
188 }
189
190 #endif //_IGNITE_CACHE_QUERY_QUERY_FIELDS_CURSOR
ignite::cache::query::QueryFieldsCursor::HasNext
bool HasNext(IgniteError &err)
Check whether next entry exists.
Definition: query_fields_cursor.h:106
ignite::cache::query::QueryFieldsCursor::QueryFieldsCursor
QueryFieldsCursor()
Default constructor.
Definition: query_fields_cursor.h:59
query_fields_row.h
Declares ignite::cache::query::QueryFieldsRow class.
ignite::cache::query::QueryFieldsCursor
Query fields cursor.
Definition: query_fields_cursor.h:50
ignite::cache::query::QueryFieldsCursor::IsValid
bool IsValid() const
Check if the instance is valid.
Definition: query_fields_cursor.h:177
cache_entry.h
Declares ignite::cache::CacheEntry class.
ignite::IgniteError
Ignite error information.
Definition: ignite_error.h:94
ignite::cache::query::QueryFieldsCursor::GetNext
QueryFieldsRow GetNext()
Get next entry.
Definition: query_fields_cursor.h:130
ignite::cache::query::QueryFieldsRow
Query fields cursor.
Definition: query_fields_row.h:49
ignite
Apache Ignite API.
Definition: cache.h:48
ignite::cache::query::QueryFieldsCursor::HasNext
bool HasNext()
Check whether next entry exists.
Definition: query_fields_cursor.h:85
ignite_error.h
Declares ignite::IgniteError class.
ignite::cache::query::QueryFieldsCursor::QueryFieldsCursor
QueryFieldsCursor(impl::cache::query::QueryCursorImpl *impl)
Constructor.
Definition: query_fields_cursor.h:71
ignite::cache::query::QueryFieldsCursor::GetNext
QueryFieldsRow GetNext(IgniteError &err)
Get next entry.
Definition: query_fields_cursor.h:151
ignite::IgniteError::ThrowIfNeeded
static void ThrowIfNeeded(const IgniteError &err)
Throw an error if code is not IGNITE_SUCCESS.
Definition: ignite_error.cpp:27
ignite::IgniteError::IGNITE_ERR_GENERIC
static const int IGNITE_ERR_GENERIC
Generic Ignite error.
Definition: ignite_error.h:131