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

Function SpliceMessages

cpp/src/arrow/ipc/read_write_test.cc:2177–2210  ·  view source on GitHub ↗

Delimit IPC stream messages and reassemble with the indicated messages included. This way we can remove messages from an IPC stream to test different failure modes or other difficult-to-test behaviors

Source from the content-addressed store, hash-verified

2175// included. This way we can remove messages from an IPC stream to test
2176// different failure modes or other difficult-to-test behaviors
2177void SpliceMessages(std::shared_ptr<Buffer> stream,
2178 const std::vector<int>& included_indices,
2179 std::shared_ptr<Buffer>* spliced_stream) {
2180 ASSERT_OK_AND_ASSIGN(auto out, io::BufferOutputStream::Create(0));
2181
2182 io::BufferReader buffer_reader(stream);
2183 std::unique_ptr<MessageReader> message_reader = MessageReader::Open(&buffer_reader);
2184 std::unique_ptr<Message> msg;
2185
2186 // Parse and reassemble first two messages in stream
2187 int message_index = 0;
2188 while (true) {
2189 ASSERT_OK_AND_ASSIGN(msg, message_reader->ReadNextMessage());
2190 if (!msg) {
2191 break;
2192 }
2193
2194 if (std::find(included_indices.begin(), included_indices.end(), message_index++) ==
2195 included_indices.end()) {
2196 // Message being dropped, continue
2197 continue;
2198 }
2199
2200 IpcWriteOptions options;
2201 IpcPayload payload;
2202 payload.type = msg->type();
2203 payload.metadata = msg->metadata();
2204 payload.body_buffers.push_back(msg->body());
2205 payload.body_length = msg->body()->size();
2206 int32_t unused_metadata_length = -1;
2207 ASSERT_OK(ipc::WriteIpcPayload(payload, options, out.get(), &unused_metadata_length));
2208 }
2209 ASSERT_OK_AND_ASSIGN(*spliced_stream, out->Finish());
2210}
2211
2212TEST(TestRecordBatchStreamReader, NotEnoughDictionaries) {
2213 // ARROW-6126

Callers 1

TESTFunction · 0.85

Calls 12

WriteIpcPayloadFunction · 0.85
push_backMethod · 0.80
ASSERT_OK_AND_ASSIGNFunction · 0.50
ReadNextMessageMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
typeMethod · 0.45
metadataMethod · 0.45
bodyMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45
FinishMethod · 0.45

Tested by

no test coverage detected