% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/arrow.R
\name{a5_cell_from_arrow}
\alias{a5_cell_from_arrow}
\alias{a5_cell_to_arrow}
\title{Convert between a5_cell and Arrow uint64 arrays}
\usage{
a5_cell_from_arrow(x)

a5_cell_to_arrow(x)
}
\arguments{
\item{x}{For \code{a5_cell_from_arrow()}, an Arrow \code{Array} or
\code{ChunkedArray} of type \code{uint64}. For \code{a5_cell_to_arrow()}, an
\link{a5_cell} vector.}
}
\value{
\code{a5_cell_from_arrow()} returns an \link{a5_cell} vector.
\code{a5_cell_to_arrow()} returns an Arrow \code{Array} of type \code{uint64}.
}
\description{
Losslessly convert between \link{a5_cell} vectors and Arrow \code{uint64}
arrays. This avoids the precision loss that occurs when Arrow
converts \code{uint64} to R's \code{double} (which can only represent
integers exactly up to 2^53, while A5 cell IDs span the full
0--2^64 range).
}
\details{
Internally these use Arrow's zero-copy \code{View()} to reinterpret
\code{uint64} bytes as \code{fixed_size_binary(8)}, then convert to/from the
raw-byte representation used by \link{a5_cell}. The resulting Arrow
arrays can be written directly to Parquet and read correctly by
DuckDB, Python, and other Arrow-compatible tools.
}
\examples{
\dontshow{if (requireNamespace("arrow", quietly = TRUE)) withAutoprint(\{ # examplesIf}
cell <- a5_lonlat_to_cell(135, 0, resolution = 10)
arr <- a5_cell_to_arrow(cell)
back <- a5_cell_from_arrow(arr)
identical(format(cell), format(back))
\dontshow{\}) # examplesIf}
\dontshow{if (requireNamespace("arrow", quietly = TRUE)) withAutoprint(\{ # examplesIf}
cells <- a5_lonlat_to_cell(c(-3.19, 135), c(55.95, 0), resolution = 10)
arr <- a5_cell_to_arrow(cells)
arr$type$ToString()
\dontshow{\}) # examplesIf}
}
\seealso{
\code{\link[=a5_u64_to_hex]{a5_u64_to_hex()}} for converting to hex strings instead.
}
