MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / serializeToIpc

Function serializeToIpc

pj_datastore/tests/plugin_host_write_test.cpp:25–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23using namespace PJ::sdk;
24
25std::vector<uint8_t> serializeToIpc(ArrowSchema* schema, ArrowArray* array) {
26 ArrowBuffer out_buf;
27 ArrowBufferInit(&out_buf);
28
29 ArrowIpcOutputStream out_stream;
30 EXPECT_EQ(ArrowIpcOutputStreamInitBuffer(&out_stream, &out_buf), NANOARROW_OK);
31
32 ArrowIpcWriter writer;
33 EXPECT_EQ(ArrowIpcWriterInit(&writer, &out_stream), NANOARROW_OK);
34
35 ArrowError error;
36 EXPECT_EQ(ArrowIpcWriterWriteSchema(&writer, schema, &error), NANOARROW_OK) << error.message;
37
38 nanoarrow::UniqueArrayView view;
39 EXPECT_EQ(ArrowArrayViewInitFromSchema(view.get(), schema, nullptr), NANOARROW_OK);
40 EXPECT_EQ(ArrowArrayViewSetArray(view.get(), array, nullptr), NANOARROW_OK);
41 EXPECT_EQ(ArrowIpcWriterWriteArrayView(&writer, view.get(), &error), NANOARROW_OK) << error.message;
42 EXPECT_EQ(ArrowIpcWriterWriteArrayView(&writer, nullptr, &error), NANOARROW_OK);
43
44 ArrowIpcWriterReset(&writer);
45
46 std::vector<uint8_t> result(static_cast<std::size_t>(out_buf.size_bytes));
47 std::memcpy(result.data(), out_buf.data, result.size());
48 ArrowBufferReset(&out_buf);
49 return result;
50}
51
52struct Fixture {
53 DataEngine engine;

Callers 1

TESTFunction · 0.70

Calls 3

getMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected