blob: 6226c3add4b668228fc8ae4156339445f5ad49d8 [file] [log] [blame]
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Provides an R interface to the nanoarrow C library and the Apache Arrow application binary interface. Functions to import and export ArrowArray, ArrowSchema, and ArrowArrayStream C structures to and from R objects are provided alongside helpers to facilitate zero-copy data transfer among R bindings to libraries implementing the Arrow C data interface.">
<title>Interface to the nanoarrow C Library • nanoarrow</title>
<script src="deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet">
<script src="deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous">
<!-- bootstrap-toc --><script src="https://cdn.jsdelivr.net/gh/afeld/bootstrap-toc@v1.0.1/dist/bootstrap-toc.min.js" integrity="sha256-4veVQbu7//Lk5TSmc7YV48MxtMy98e26cf5MrgZYnwo=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.11/clipboard.min.js" integrity="sha512-7O5pXpc0oCRrxk8RUfDYFgn0nO1t+jLuIOQdOMRp4APB7uZ4vSjspzp5y6YDtDs4VzUSTbWzBFZ/LKJhnyFOKw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script><!-- search --><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js" integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js" integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww==" crossorigin="anonymous"></script><!-- pkgdown --><script src="pkgdown.js"></script><meta property="og:title" content="Interface to the nanoarrow C Library">
<meta property="og:description" content="Provides an R interface to the nanoarrow C library and the Apache Arrow application binary interface. Functions to import and export ArrowArray, ArrowSchema, and ArrowArrayStream C structures to and from R objects are provided alongside helpers to facilitate zero-copy data transfer among R bindings to libraries implementing the Arrow C data interface.">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<a href="#main" class="visually-hidden-focusable">Skip to contents</a>
<nav class="navbar fixed-top navbar-light navbar-expand-lg bg-light" data-bs-theme="light"><div class="container">
<a class="navbar-brand me-2" href="index.html">nanoarrow</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">0.5.0.9000</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbar" class="collapse navbar-collapse ms-3">
<ul class="navbar-nav me-auto">
<li class="nav-item">
<a class="nav-link" href="reference/index.html">Reference</a>
</li>
<li class="nav-item">
<a class="nav-link" href="news/index.html">Changelog</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0" role="search">
<input type="search" class="form-control me-sm-2" aria-label="Toggle navigation" name="search-input" data-search-index="search.json" id="search-input" placeholder="Search for" autocomplete="off">
</form>
<ul class="navbar-nav">
<li class="nav-item">
<a class="external-link nav-link" href="https://github.com/apache/arrow-nanoarrow/" aria-label="github">
<span class="fab fa fab fa-github fa-lg"></span>
</a>
</li>
</ul>
</div>
</div>
</nav><div class="container template-home">
<div class="row">
<main id="main" class="col-md-9"><div class="section level1">
<div class="page-header"><h1 id="nanoarrow">nanoarrow<a class="anchor" aria-label="anchor" href="#nanoarrow"></a>
</h1></div>
<!-- badges: start -->
<!-- badges: end -->
<p>The goal of nanoarrow is to provide minimal useful bindings to the <a href="https://arrow.apache.org/docs/format/CDataInterface.html" class="external-link">Arrow C Data</a> and <a href="https://arrow.apache.org/docs/format/CStreamInterface.html" class="external-link">Arrow C Stream</a> interfaces using the <a href="https://arrow.apache.org/nanoarrow/" class="external-link">nanoarrow C library</a>.</p>
<div class="section level2">
<h2 id="installation">Installation<a class="anchor" aria-label="anchor" href="#installation"></a>
</h2>
<p>You can install the released version of nanoarrow from <a href="https://cran.r-project.org/" class="external-link">CRAN</a> with:</p>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html" class="external-link">install.packages</a></span><span class="op">(</span><span class="st">"nanoarrow"</span><span class="op">)</span></span></code></pre></div>
<p>You can install the development version of nanoarrow from <a href="https://github.com/" class="external-link">GitHub</a> with:</p>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># install.packages("remotes")</span></span>
<span><span class="fu">remotes</span><span class="fu">::</span><span class="fu">install_github</span><span class="op">(</span><span class="st">"apache/arrow-nanoarrow/r"</span><span class="op">)</span></span></code></pre></div>
<p>If you can load the package, you’re good to go!</p>
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://arrow.apache.org/nanoarrow/latest/r/" class="external-link">nanoarrow</a></span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level2">
<h2 id="example">Example<a class="anchor" aria-label="anchor" href="#example"></a>
</h2>
<p>The Arrow C Data and Arrow C Stream interfaces are comprised of three structures: the <code>ArrowSchema</code> which represents a data type of an array, the <code>ArrowArray</code> which represents the values of an array, and an <code>ArrowArrayStream</code>, which represents zero or more <code>ArrowArray</code>s with a common <code>ArrowSchema</code>. All three can be wrapped by R objects using the nanoarrow R package.</p>
<div class="section level3">
<h3 id="schemas">Schemas<a class="anchor" aria-label="anchor" href="#schemas"></a>
</h3>
<p>Use <code><a href="reference/as_nanoarrow_schema.html">infer_nanoarrow_schema()</a></code> to get the ArrowSchema object that corresponds to a given R vector type; use <code><a href="reference/as_nanoarrow_schema.html">as_nanoarrow_schema()</a></code> to convert an object from some other data type representation (e.g., an arrow R package <code>DataType</code> like <code><a href="https://arrow.apache.org/docs/r/reference/data-type.html" class="external-link">arrow::int32()</a></code>); or use <code>na_XXX()</code> functions to construct them.</p>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="reference/as_nanoarrow_schema.html">infer_nanoarrow_schema</a></span><span class="op">(</span><span class="fl">1</span><span class="op">:</span><span class="fl">5</span><span class="op">)</span></span>
<span><span class="co">#&gt; &lt;nanoarrow_schema int32&gt;</span></span>
<span><span class="co">#&gt; $ format : chr "i"</span></span>
<span><span class="co">#&gt; $ name : chr ""</span></span>
<span><span class="co">#&gt; $ metadata : list()</span></span>
<span><span class="co">#&gt; $ flags : int 2</span></span>
<span><span class="co">#&gt; $ children : list()</span></span>
<span><span class="co">#&gt; $ dictionary: NULL</span></span>
<span><span class="fu"><a href="reference/as_nanoarrow_schema.html">as_nanoarrow_schema</a></span><span class="op">(</span><span class="fu">arrow</span><span class="fu">::</span><span class="fu"><a href="https://arrow.apache.org/docs/r/reference/schema.html" class="external-link">schema</a></span><span class="op">(</span>col1 <span class="op">=</span> <span class="fu">arrow</span><span class="fu">::</span><span class="fu"><a href="https://arrow.apache.org/docs/r/reference/data-type.html" class="external-link">float64</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="co">#&gt; &lt;nanoarrow_schema struct&gt;</span></span>
<span><span class="co">#&gt; $ format : chr "+s"</span></span>
<span><span class="co">#&gt; $ name : chr ""</span></span>
<span><span class="co">#&gt; $ metadata : list()</span></span>
<span><span class="co">#&gt; $ flags : int 0</span></span>
<span><span class="co">#&gt; $ children :List of 1</span></span>
<span><span class="co">#&gt; ..$ col1:&lt;nanoarrow_schema double&gt;</span></span>
<span><span class="co">#&gt; .. ..$ format : chr "g"</span></span>
<span><span class="co">#&gt; .. ..$ name : chr "col1"</span></span>
<span><span class="co">#&gt; .. ..$ metadata : list()</span></span>
<span><span class="co">#&gt; .. ..$ flags : int 2</span></span>
<span><span class="co">#&gt; .. ..$ children : list()</span></span>
<span><span class="co">#&gt; .. ..$ dictionary: NULL</span></span>
<span><span class="co">#&gt; $ dictionary: NULL</span></span>
<span><span class="fu"><a href="reference/na_type.html">na_int64</a></span><span class="op">(</span><span class="op">)</span></span>
<span><span class="co">#&gt; &lt;nanoarrow_schema int64&gt;</span></span>
<span><span class="co">#&gt; $ format : chr "l"</span></span>
<span><span class="co">#&gt; $ name : chr ""</span></span>
<span><span class="co">#&gt; $ metadata : list()</span></span>
<span><span class="co">#&gt; $ flags : int 2</span></span>
<span><span class="co">#&gt; $ children : list()</span></span>
<span><span class="co">#&gt; $ dictionary: NULL</span></span></code></pre></div>
</div>
<div class="section level3">
<h3 id="arrays">Arrays<a class="anchor" aria-label="anchor" href="#arrays"></a>
</h3>
<p>Use <code><a href="reference/as_nanoarrow_array.html">as_nanoarrow_array()</a></code> to convert an object to an ArrowArray object:</p>
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="reference/as_nanoarrow_array.html">as_nanoarrow_array</a></span><span class="op">(</span><span class="fl">1</span><span class="op">:</span><span class="fl">5</span><span class="op">)</span></span>
<span><span class="co">#&gt; &lt;nanoarrow_array int32[5]&gt;</span></span>
<span><span class="co">#&gt; $ length : int 5</span></span>
<span><span class="co">#&gt; $ null_count: int 0</span></span>
<span><span class="co">#&gt; $ offset : int 0</span></span>
<span><span class="co">#&gt; $ buffers :List of 2</span></span>
<span><span class="co">#&gt; ..$ :&lt;nanoarrow_buffer validity&lt;bool&gt;[0][0 b]&gt; ``</span></span>
<span><span class="co">#&gt; ..$ :&lt;nanoarrow_buffer data&lt;int32&gt;[5][20 b]&gt; `1 2 3 4 5`</span></span>
<span><span class="co">#&gt; $ dictionary: NULL</span></span>
<span><span class="co">#&gt; $ children : list()</span></span>
<span><span class="fu"><a href="reference/as_nanoarrow_array.html">as_nanoarrow_array</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>col1 <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">1.1</span>, <span class="fl">2.2</span><span class="op">)</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="co">#&gt; &lt;nanoarrow_array struct[2]&gt;</span></span>
<span><span class="co">#&gt; $ length : int 2</span></span>
<span><span class="co">#&gt; $ null_count: int 0</span></span>
<span><span class="co">#&gt; $ offset : int 0</span></span>
<span><span class="co">#&gt; $ buffers :List of 1</span></span>
<span><span class="co">#&gt; ..$ :&lt;nanoarrow_buffer validity&lt;bool&gt;[0][0 b]&gt; ``</span></span>
<span><span class="co">#&gt; $ children :List of 1</span></span>
<span><span class="co">#&gt; ..$ col1:&lt;nanoarrow_array double[2]&gt;</span></span>
<span><span class="co">#&gt; .. ..$ length : int 2</span></span>
<span><span class="co">#&gt; .. ..$ null_count: int 0</span></span>
<span><span class="co">#&gt; .. ..$ offset : int 0</span></span>
<span><span class="co">#&gt; .. ..$ buffers :List of 2</span></span>
<span><span class="co">#&gt; .. .. ..$ :&lt;nanoarrow_buffer validity&lt;bool&gt;[0][0 b]&gt; ``</span></span>
<span><span class="co">#&gt; .. .. ..$ :&lt;nanoarrow_buffer data&lt;double&gt;[2][16 b]&gt; `1.1 2.2`</span></span>
<span><span class="co">#&gt; .. ..$ dictionary: NULL</span></span>
<span><span class="co">#&gt; .. ..$ children : list()</span></span>
<span><span class="co">#&gt; $ dictionary: NULL</span></span></code></pre></div>
<p>You can use <code><a href="https://rdrr.io/r/base/vector.html" class="external-link">as.vector()</a></code> or <code><a href="https://rdrr.io/r/base/as.data.frame.html" class="external-link">as.data.frame()</a></code> to get the R representation of the object back:</p>
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">array</span> <span class="op">&lt;-</span> <span class="fu"><a href="reference/as_nanoarrow_array.html">as_nanoarrow_array</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>col1 <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">1.1</span>, <span class="fl">2.2</span><span class="op">)</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/as.data.frame.html" class="external-link">as.data.frame</a></span><span class="op">(</span><span class="va">array</span><span class="op">)</span></span>
<span><span class="co">#&gt; col1</span></span>
<span><span class="co">#&gt; 1 1.1</span></span>
<span><span class="co">#&gt; 2 2.2</span></span></code></pre></div>
<p>Even though at the C level the ArrowArray is distinct from the ArrowSchema, at the R level we attach a schema wherever possible. You can access the attached schema using <code><a href="reference/as_nanoarrow_schema.html">infer_nanoarrow_schema()</a></code>:</p>
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="reference/as_nanoarrow_schema.html">infer_nanoarrow_schema</a></span><span class="op">(</span><span class="va">array</span><span class="op">)</span></span>
<span><span class="co">#&gt; &lt;nanoarrow_schema struct&gt;</span></span>
<span><span class="co">#&gt; $ format : chr "+s"</span></span>
<span><span class="co">#&gt; $ name : chr ""</span></span>
<span><span class="co">#&gt; $ metadata : list()</span></span>
<span><span class="co">#&gt; $ flags : int 0</span></span>
<span><span class="co">#&gt; $ children :List of 1</span></span>
<span><span class="co">#&gt; ..$ col1:&lt;nanoarrow_schema double&gt;</span></span>
<span><span class="co">#&gt; .. ..$ format : chr "g"</span></span>
<span><span class="co">#&gt; .. ..$ name : chr "col1"</span></span>
<span><span class="co">#&gt; .. ..$ metadata : list()</span></span>
<span><span class="co">#&gt; .. ..$ flags : int 2</span></span>
<span><span class="co">#&gt; .. ..$ children : list()</span></span>
<span><span class="co">#&gt; .. ..$ dictionary: NULL</span></span>
<span><span class="co">#&gt; $ dictionary: NULL</span></span></code></pre></div>
</div>
<div class="section level3">
<h3 id="array-streams">Array Streams<a class="anchor" aria-label="anchor" href="#array-streams"></a>
</h3>
<p>The easiest way to create an ArrowArrayStream is from a list of arrays or objects that can be converted to an array using <code><a href="reference/as_nanoarrow_array.html">as_nanoarrow_array()</a></code>:</p>
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">stream</span> <span class="op">&lt;-</span> <span class="fu"><a href="reference/basic_array_stream.html">basic_array_stream</a></span><span class="op">(</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>col1 <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">1.1</span>, <span class="fl">2.2</span><span class="op">)</span><span class="op">)</span>,</span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>col1 <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">3.3</span>, <span class="fl">4.4</span><span class="op">)</span><span class="op">)</span></span>
<span> <span class="op">)</span></span>
<span><span class="op">)</span></span></code></pre></div>
<p>You can pull batches from the stream using the <code>$get_next()</code> method. The last batch will return <code>NULL</code>.</p>
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">stream</span><span class="op">$</span><span class="fu">get_next</span><span class="op">(</span><span class="op">)</span></span>
<span><span class="co">#&gt; &lt;nanoarrow_array struct[2]&gt;</span></span>
<span><span class="co">#&gt; $ length : int 2</span></span>
<span><span class="co">#&gt; $ null_count: int 0</span></span>
<span><span class="co">#&gt; $ offset : int 0</span></span>
<span><span class="co">#&gt; $ buffers :List of 1</span></span>
<span><span class="co">#&gt; ..$ :&lt;nanoarrow_buffer validity&lt;bool&gt;[0][0 b]&gt; ``</span></span>
<span><span class="co">#&gt; $ children :List of 1</span></span>
<span><span class="co">#&gt; ..$ col1:&lt;nanoarrow_array double[2]&gt;</span></span>
<span><span class="co">#&gt; .. ..$ length : int 2</span></span>
<span><span class="co">#&gt; .. ..$ null_count: int 0</span></span>
<span><span class="co">#&gt; .. ..$ offset : int 0</span></span>
<span><span class="co">#&gt; .. ..$ buffers :List of 2</span></span>
<span><span class="co">#&gt; .. .. ..$ :&lt;nanoarrow_buffer validity&lt;bool&gt;[0][0 b]&gt; ``</span></span>
<span><span class="co">#&gt; .. .. ..$ :&lt;nanoarrow_buffer data&lt;double&gt;[2][16 b]&gt; `1.1 2.2`</span></span>
<span><span class="co">#&gt; .. ..$ dictionary: NULL</span></span>
<span><span class="co">#&gt; .. ..$ children : list()</span></span>
<span><span class="co">#&gt; $ dictionary: NULL</span></span>
<span><span class="va">stream</span><span class="op">$</span><span class="fu">get_next</span><span class="op">(</span><span class="op">)</span></span>
<span><span class="co">#&gt; &lt;nanoarrow_array struct[2]&gt;</span></span>
<span><span class="co">#&gt; $ length : int 2</span></span>
<span><span class="co">#&gt; $ null_count: int 0</span></span>
<span><span class="co">#&gt; $ offset : int 0</span></span>
<span><span class="co">#&gt; $ buffers :List of 1</span></span>
<span><span class="co">#&gt; ..$ :&lt;nanoarrow_buffer validity&lt;bool&gt;[0][0 b]&gt; ``</span></span>
<span><span class="co">#&gt; $ children :List of 1</span></span>
<span><span class="co">#&gt; ..$ col1:&lt;nanoarrow_array double[2]&gt;</span></span>
<span><span class="co">#&gt; .. ..$ length : int 2</span></span>
<span><span class="co">#&gt; .. ..$ null_count: int 0</span></span>
<span><span class="co">#&gt; .. ..$ offset : int 0</span></span>
<span><span class="co">#&gt; .. ..$ buffers :List of 2</span></span>
<span><span class="co">#&gt; .. .. ..$ :&lt;nanoarrow_buffer validity&lt;bool&gt;[0][0 b]&gt; ``</span></span>
<span><span class="co">#&gt; .. .. ..$ :&lt;nanoarrow_buffer data&lt;double&gt;[2][16 b]&gt; `3.3 4.4`</span></span>
<span><span class="co">#&gt; .. ..$ dictionary: NULL</span></span>
<span><span class="co">#&gt; .. ..$ children : list()</span></span>
<span><span class="co">#&gt; $ dictionary: NULL</span></span>
<span><span class="va">stream</span><span class="op">$</span><span class="fu">get_next</span><span class="op">(</span><span class="op">)</span></span>
<span><span class="co">#&gt; NULL</span></span></code></pre></div>
<p>You can pull all the batches into a <code><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame()</a></code> by calling <code><a href="https://rdrr.io/r/base/as.data.frame.html" class="external-link">as.data.frame()</a></code> or <code><a href="https://rdrr.io/r/base/vector.html" class="external-link">as.vector()</a></code>:</p>
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">stream</span> <span class="op">&lt;-</span> <span class="fu"><a href="reference/basic_array_stream.html">basic_array_stream</a></span><span class="op">(</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>col1 <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">1.1</span>, <span class="fl">2.2</span><span class="op">)</span><span class="op">)</span>,</span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>col1 <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">3.3</span>, <span class="fl">4.4</span><span class="op">)</span><span class="op">)</span></span>
<span> <span class="op">)</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/as.data.frame.html" class="external-link">as.data.frame</a></span><span class="op">(</span><span class="va">stream</span><span class="op">)</span></span>
<span><span class="co">#&gt; col1</span></span>
<span><span class="co">#&gt; 1 1.1</span></span>
<span><span class="co">#&gt; 2 2.2</span></span>
<span><span class="co">#&gt; 3 3.3</span></span>
<span><span class="co">#&gt; 4 4.4</span></span></code></pre></div>
<p>After consuming a stream, you should call the release method as soon as you can. This lets the implementation of the stream release any resources (like open files) it may be holding in a more predictable way than waiting for the garbage collector to clean up the object.</p>
</div>
</div>
<div class="section level2">
<h2 id="integration-with-the-arrow-package">Integration with the arrow package<a class="anchor" aria-label="anchor" href="#integration-with-the-arrow-package"></a>
</h2>
<p>The nanoarrow package implements <code><a href="reference/as_nanoarrow_schema.html">as_nanoarrow_schema()</a></code>, <code><a href="reference/as_nanoarrow_array.html">as_nanoarrow_array()</a></code>, and <code><a href="reference/as_nanoarrow_array_stream.html">as_nanoarrow_array_stream()</a></code> for most arrow package types. Similarly, it implements <code><a href="https://arrow.apache.org/docs/r/reference/as_arrow_array.html" class="external-link">arrow::as_arrow_array()</a></code>, <code><a href="https://arrow.apache.org/docs/r/reference/as_record_batch.html" class="external-link">arrow::as_record_batch()</a></code>, <code><a href="https://arrow.apache.org/docs/r/reference/as_arrow_table.html" class="external-link">arrow::as_arrow_table()</a></code>, <code><a href="https://arrow.apache.org/docs/r/reference/as_record_batch_reader.html" class="external-link">arrow::as_record_batch_reader()</a></code>, <code><a href="https://arrow.apache.org/docs/r/reference/infer_type.html" class="external-link">arrow::infer_type()</a></code>, <code><a href="https://arrow.apache.org/docs/r/reference/as_data_type.html" class="external-link">arrow::as_data_type()</a></code>, and <code><a href="https://arrow.apache.org/docs/r/reference/as_schema.html" class="external-link">arrow::as_schema()</a></code> for nanoarrow objects such that you can pass equivalent nanoarrow objects into many arrow functions and vice versa.</p>
</div>
</div>
</main><aside class="col-md-3"><div class="links">
<h2 data-toc-skip>Links</h2>
<ul class="list-unstyled">
<li><a href="https://cloud.r-project.org/package=nanoarrow" class="external-link">View on CRAN</a></li>
<li><a href="https://github.com/apache/arrow-nanoarrow/" class="external-link">Browse source code</a></li>
<li><a href="https://github.com/apache/arrow-nanoarrow/issues" class="external-link">Report a bug</a></li>
</ul>
</div>
<div class="license">
<h2 data-toc-skip>License</h2>
<ul class="list-unstyled">
<li><a href="LICENSE.html">Full license</a></li>
<li><small>Apache License (&gt;= 2)</small></li>
</ul>
</div>
<div class="citation">
<h2 data-toc-skip>Citation</h2>
<ul class="list-unstyled">
<li><a href="authors.html#citation">Citing nanoarrow</a></li>
</ul>
</div>
<div class="developers">
<h2 data-toc-skip>Developers</h2>
<ul class="list-unstyled">
<li>Dewey Dunnington <br><small class="roles"> Author, maintainer </small> <a href="https://orcid.org/0000-0002-9415-4582" target="orcid.widget" aria-label="ORCID" class="external-link"><span class="fab fa-orcid orcid" aria-hidden="true"></span></a> </li>
<li>Apache Arrow <br><small class="roles"> Author, copyright holder </small> </li>
<li><a href="authors.html">More about authors...</a></li>
</ul>
</div>
</aside>
</div>
<footer><div class="pkgdown-footer-left">
<p>Developed by Dewey Dunnington, Apache Arrow.</p>
</div>
<div class="pkgdown-footer-right">
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.9.</p>
</div>
</footer>
</div>
</body>
</html>