MCPcopy Create free account
hub / github.com/apache/arrow / Next

Method Next

cpp/examples/arrow/rapidjson_row_converter.cc:266–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264 }
265
266 arrow::Result<const rapidjson::Value*> Next() {
267 const rapidjson::Value* value = nullptr;
268 size_t path_i;
269 int64_t arr_i;
270 // Can either start at document or at last array level
271 if (array_stack.size() > 0) {
272 auto pos = array_stack.back();
273 value = pos.array_node;
274 path_i = pos.path_index;
275 arr_i = array_stack.size() - 1;
276 }
277
278 value = NextArrayOrRow(value, &path_i, &arr_i);
279
280 // Traverse to desired level (with possible backtracking as needed)
281 while (path_i < path.size() || arr_i < array_levels) {
282 if (value == nullptr) {
283 return value;
284 } else if (value->IsArray() && value->Size() > 0) {
285 ArrayPosition pos;
286 pos.array_node = value;
287 pos.path_index = path_i;
288 pos.index = 0;
289 array_stack.push_back(pos);
290
291 value = &(*value)[0];
292 ++arr_i;
293 } else if (value->IsArray()) {
294 // Empty array means we need to backtrack and go to next array or row
295 value = NextArrayOrRow(value, &path_i, &arr_i);
296 } else if (value->HasMember(path[path_i])) {
297 value = &(*value)[path[path_i]];
298 ++path_i;
299 } else {
300 return &kNullJsonSingleton;
301 }
302 }
303
304 // Return value
305 return value;
306 }
307
308 private:
309 const std::vector<rapidjson::Document>& rows;

Callers 1

FieldValuesMethod · 0.45

Calls 4

backMethod · 0.80
push_backMethod · 0.80
sizeMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected