MCPcopy Create free account
hub / github.com/apache/impala / CountJsonObjects

Method CountJsonObjects

be/src/exec/json/json-parser.cc:139–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137
138template <class Scanner>
139Status JsonParser<Scanner>::CountJsonObjects(int max_rows, int* num_rows) {
140 JsonSkipper<CharStream> skipper(stream_);
141 while (*num_rows < max_rows) {
142 skipper.SkipNextObject();
143
144 if (UNLIKELY(skipper.HasError())) {
145 if (skipper.GetErrorCode() == kParseErrorDocumentEmpty) {
146 // See the comments at the corresponding location of the Parse().
147 if (UNLIKELY(!stream_.Eos())) {
148 DCHECK_EQ(stream_.Peek(), '\0');
149 stream_.Take();
150 continue;
151 }
152 return Status::OK();
153 }
154 RETURN_IF_ERROR(scanner_->HandleError(skipper.GetErrorCode(), stream_.Tell()));
155
156 // See the comments at the corresponding location of the Parse().
157 if (reader_.GetParseErrorCode() != kParseErrorObjectMissCommaOrCurlyBracket) {
158 MoveToNextJson();
159 }
160 }
161
162 ++(*num_rows);
163 if (UNLIKELY(scanner_->BreakParse())) break;
164 }
165
166 return Status::OK();
167}
168
169template <class Scanner>
170bool JsonParser<Scanner>::Key(const char* str, uint32_t len, bool copy) {

Callers 2

ParseWrapperMethod · 0.80
CountMethod · 0.80

Calls 10

OKFunction · 0.85
SkipNextObjectMethod · 0.80
HasErrorMethod · 0.80
GetErrorCodeMethod · 0.80
EosMethod · 0.45
PeekMethod · 0.45
TakeMethod · 0.45
HandleErrorMethod · 0.45
TellMethod · 0.45
BreakParseMethod · 0.45

Tested by

no test coverage detected