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

Function AssertStraddledChunking

cpp/src/arrow/json/chunker_test.cc:154–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154void AssertStraddledChunking(Chunker& chunker, const std::shared_ptr<Buffer>& buf) {
155 auto first_half = SliceBuffer(buf, 0, buf->size() / 2);
156 auto second_half = SliceBuffer(buf, buf->size() / 2);
157 AssertChunking(chunker, first_half, 1);
158 std::shared_ptr<Buffer> first_whole, partial;
159 ASSERT_OK(chunker.Process(first_half, &first_whole, &partial));
160 ASSERT_TRUE(std::string_view(*first_half).starts_with(std::string_view(*first_whole)));
161 std::shared_ptr<Buffer> completion, rest;
162 ASSERT_OK(chunker.ProcessWithPartial(partial, second_half, &completion, &rest));
163 ASSERT_TRUE(std::string_view(*second_half).starts_with(std::string_view(*completion)));
164 std::shared_ptr<Buffer> straddling;
165 ASSERT_OK_AND_ASSIGN(straddling, ConcatenateBuffers({partial, completion}));
166 auto length = ConsumeWholeObject(&straddling);
167 ASSERT_NE(length, string_view::npos);
168 ASSERT_NE(length, 0);
169 auto final_whole = SliceBuffer(second_half, completion->size());
170 ASSERT_EQ(string_view(*final_whole), string_view(*rest));
171 length = ConsumeWholeObject(&final_whole);
172 ASSERT_NE(length, string_view::npos);
173 ASSERT_NE(length, 0);
174}
175
176std::unique_ptr<Chunker> MakeChunker(bool newlines_in_values) {
177 auto options = ParseOptions::Defaults();

Callers 2

TEST_PFunction · 0.85
TESTFunction · 0.85

Calls 8

SliceBufferFunction · 0.85
ConcatenateBuffersFunction · 0.85
ProcessWithPartialMethod · 0.80
AssertChunkingFunction · 0.70
ConsumeWholeObjectFunction · 0.70
ASSERT_OK_AND_ASSIGNFunction · 0.50
sizeMethod · 0.45
ProcessMethod · 0.45

Tested by

no test coverage detected