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 
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  {
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 
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  {
115  "Instance is not usable (did you check for error?).");
116 
117  return false;
118  }
119  }
120 
131  {
132  IgniteError err;
133 
134  QueryFieldsRow res = GetNext(err);
135 
137 
138  return res;
139  }
140 
152  {
153  impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
154 
155  if (impl0)
156  return impl0->GetNextRow(&err);
157  else
158  {
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
bool HasNext(IgniteError &err)
Check whether next entry exists.
Definition: query_fields_cursor.h:106
bool IsValid() const
Check if the instance is valid.
Definition: query_fields_cursor.h:177
QueryFieldsCursor()
Default constructor.
Definition: query_fields_cursor.h:59
Declares ignite::cache::query::QueryFieldsRow class.
Query fields cursor.
Definition: query_fields_cursor.h:50
static void ThrowIfNeeded(IgniteError &err)
Throw an error if code is not IGNITE_SUCCESS.
Definition: ignite_error.cpp:27
Declares ignite::cache::CacheEntry class.
Ignite error information.
Definition: ignite_error.h:89
QueryFieldsRow GetNext()
Get next entry.
Definition: query_fields_cursor.h:130
Query fields cursor.
Definition: query_fields_row.h:49
Apache Ignite API.
Definition: cache.h:43
bool HasNext()
Check whether next entry exists.
Definition: query_fields_cursor.h:85
Declares ignite::IgniteError class.
QueryFieldsCursor(impl::cache::query::QueryCursorImpl *impl)
Constructor.
Definition: query_fields_cursor.h:71
QueryFieldsRow GetNext(IgniteError &err)
Get next entry.
Definition: query_fields_cursor.h:151
static const int IGNITE_ERR_GENERIC
Generic Ignite error.
Definition: ignite_error.h:123