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

Function AssertChunkingBlockSize

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

Source from the content-addressed store, hash-verified

119}
120
121void AssertChunkingBlockSize(Chunker& chunker, std::shared_ptr<Buffer> buf,
122 int64_t block_size, int expected_count) {
123 std::shared_ptr<Buffer> partial = Buffer::FromString({});
124 int64_t pos = 0;
125 int total_count = 0;
126 while (pos < buf->size()) {
127 int count;
128 auto block = SliceBuffer(buf, pos, std::min(block_size, buf->size() - pos));
129 pos += block->size();
130 std::shared_ptr<Buffer> completion, whole, next_partial;
131
132 if (pos == buf->size()) {
133 // Last block
134 ASSERT_OK(chunker.ProcessFinal(partial, block, &completion, &whole));
135 } else {
136 std::shared_ptr<Buffer> starts_with_whole;
137 ASSERT_OK(
138 chunker.ProcessWithPartial(partial, block, &completion, &starts_with_whole));
139 ASSERT_OK(chunker.Process(starts_with_whole, &whole, &next_partial));
140 }
141 // partial + completion should be a valid JSON block
142 ASSERT_OK_AND_ASSIGN(partial, ConcatenateBuffers({partial, completion}));
143 AssertOnlyWholeObjects(chunker, partial, &count);
144 total_count += count;
145 // whole should be a valid JSON block
146 AssertOnlyWholeObjects(chunker, whole, &count);
147 total_count += count;
148 partial = next_partial;
149 }
150 ASSERT_EQ(pos, buf->size());
151 ASSERT_EQ(total_count, expected_count);
152}
153
154void AssertStraddledChunking(Chunker& chunker, const std::shared_ptr<Buffer>& buf) {
155 auto first_half = SliceBuffer(buf, 0, buf->size() / 2);

Callers 1

TEST_PFunction · 0.85

Calls 9

FromStringFunction · 0.85
SliceBufferFunction · 0.85
ConcatenateBuffersFunction · 0.85
AssertOnlyWholeObjectsFunction · 0.85
ProcessFinalMethod · 0.80
ProcessWithPartialMethod · 0.80
ASSERT_OK_AND_ASSIGNFunction · 0.50
sizeMethod · 0.45
ProcessMethod · 0.45

Tested by

no test coverage detected