arrow-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bjoern Bachmann <bjoernbachm...@gmx.de>
Subject [C# C++] passing RecordBatch or Table from C++ build DLL to C#
Date Tue, 01 Jun 2021 10:50:41 GMT
<html><head></head><body><div style="font-family: Verdana;font-size:
12.0px;"><pre style="margin: 0em;">Hello Arrow users,

<tt>I would need some help to understand how I can pass an </tt><tt>RecordBatch
or a table created in a C++ build DLL into a C# application? How could this be handled efficiently
without much data copies?</tt></pre>

<div>
<pre style="margin: 0em;">&nbsp;</pre>

<pre>Kind Regards,
Bjoern Bachmann.</pre>

<div>&nbsp;</div>

<div>C++ sample code which is exported in the DLL:</div>

<div>&nbsp;</div>

<div>std::queue&lt;std::shared_ptr&lt;arrow::RecordBatch&gt;&gt; wfmQueue;</div>

<div>&nbsp;</div>

<div>
<div>ARROW_EXAM_API long EnqueueWaveformChunks()<br/>
&nbsp;&nbsp;&nbsp; {</div>

<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //En-Queue
Loop<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt;
&quot;En-Queue Data ... &#92;n&quot;;<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt;
chunk_size; i++) {<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
createWfmSrc(col0_data, col1_data);<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
WaveformChunkWriterHelper testWfm{&nbsp;col0_data, col1_data };&nbsp; //creates schema
and adds the data<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
testWfm.createRecBatch();<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
wfmQueue.push(testWfm.getRecBatch());<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return S_OK;<br/>
&nbsp;&nbsp;&nbsp; }</div>

<div>&nbsp;</div>

<div>&nbsp;&nbsp;&nbsp; ARROW_EXAM_API long DequeueSingleWaveformChunk(arrow::RecordBatch*
recBatch)<br/>
&nbsp;&nbsp;&nbsp; {<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::shared_ptr&lt;arrow::RecordBatch&gt;
queueItem;<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!wfmQueue.empty())
{<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
queueItem = wfmQueue.front();<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
wfmQueue.pop();</div>

<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
std::cout &lt;&lt; &quot;Get RecBatch from Queue&#92;n&quot;;<br/>
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
recBatch = queueItem.get();</div>

<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
//ExportRecordBatch(*queueItem, c_array);<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
//recBatch = reinterpret_cast&lt;void*&gt;(queueItem.get());<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return S_OK;<br/>
&nbsp;&nbsp;&nbsp; }</div>
</div>

<div>&nbsp;</div>
</div></div></body></html>

Mime
View raw message