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

Function ParseBlock

cpp/src/arrow/json/reader.cc:140–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138};
139
140Result<std::shared_ptr<Array>> ParseBlock(const ChunkedBlock& block,
141 const ParseOptions& parse_options,
142 MemoryPool* pool, int64_t* out_size = nullptr) {
143 std::unique_ptr<BlockParser> parser;
144 RETURN_NOT_OK(BlockParser::Make(pool, parse_options, &parser));
145
146 int64_t size = block.partial->size() + block.completion->size() + block.whole->size();
147 RETURN_NOT_OK(parser->ReserveScalarStorage(size));
148
149 if (block.partial->size() || block.completion->size()) {
150 std::shared_ptr<Buffer> straddling;
151 if (!block.completion->size()) {
152 straddling = block.partial;
153 } else if (!block.partial->size()) {
154 straddling = block.completion;
155 } else {
156 ARROW_ASSIGN_OR_RAISE(straddling,
157 ConcatenateBuffers({block.partial, block.completion}, pool));
158 }
159 RETURN_NOT_OK(parser->Parse(straddling));
160 }
161 if (block.whole->size()) {
162 RETURN_NOT_OK(parser->Parse(block.whole));
163 }
164
165 std::shared_ptr<Array> parsed;
166 RETURN_NOT_OK(parser->Finish(&parsed));
167
168 if (out_size) *out_size = size;
169
170 return parsed;
171}
172
173class ChunkingTransformer {
174 public:

Callers

nothing calls this directly

Calls 7

ConcatenateBuffersFunction · 0.85
ReserveScalarStorageMethod · 0.80
MakeFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
sizeMethod · 0.45
ParseMethod · 0.45
FinishMethod · 0.45

Tested by

no test coverage detected