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

Function ReadStream

cpp/src/arrow/ipc/read_write_benchmark.cc:119–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119static void ReadStream(benchmark::State& state) { // NOLINT non-const reference
120 // 1MB
121 constexpr int64_t kTotalSize = 1 << 20;
122 auto options = ipc::IpcWriteOptions::Defaults();
123
124 std::shared_ptr<ResizableBuffer> buffer = *AllocateResizableBuffer(1024);
125 {
126 // Make Arrow IPC stream
127 auto record_batch = MakeRecordBatch(kTotalSize, state.range(0));
128
129 io::BufferOutputStream stream(buffer);
130
131 auto writer_result = ipc::MakeStreamWriter(&stream, record_batch->schema(), options);
132 ABORT_NOT_OK(writer_result);
133 auto writer = *writer_result;
134 ABORT_NOT_OK(writer->WriteRecordBatch(*record_batch));
135 ABORT_NOT_OK(writer->Close());
136 ABORT_NOT_OK(stream.Close());
137 }
138
139 ipc::DictionaryMemo empty_memo;
140 while (state.KeepRunning()) {
141 io::BufferReader input(buffer);
142 auto reader_result =
143 ipc::RecordBatchStreamReader::Open(&input, ipc::IpcReadOptions::Defaults());
144 ABORT_NOT_OK(reader_result);
145 auto reader = *reader_result;
146 while (true) {
147 std::shared_ptr<RecordBatch> batch;
148 ABORT_NOT_OK(reader->ReadNext(&batch));
149 if (batch.get() == nullptr) {
150 break;
151 }
152 }
153 }
154 state.SetBytesProcessed(int64_t(state.iterations()) * kTotalSize);
155}
156
157static void DecodeStream(benchmark::State& state) { // NOLINT non-const reference
158 // 1MB

Callers

nothing calls this directly

Calls 9

AllocateResizableBufferFunction · 0.85
MakeStreamWriterFunction · 0.85
MakeRecordBatchFunction · 0.70
DefaultsFunction · 0.50
schemaMethod · 0.45
WriteRecordBatchMethod · 0.45
CloseMethod · 0.45
ReadNextMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected