[Rcpp-devel] passing a bit64 vector to C++ and returning it
Kirill Müller
kirill.mueller at ivt.baug.ethz.ch
Wed Jul 12 08:27:51 CEST 2017
On 12.07.2017 01:09, Dirk Eddelbuettel wrote:
> On 11 July 2017 at 23:44, David Bellot wrote:
> | it looks like I couldn't find a proper solution, even after googling every
> | where. The question is simple:
> |
> | I have a bit64 vector of integers (timestamps of financial tick data, you
> | bet ?) and I want to pass it to a C++ function. The good ol' method is to
> | convert it to strings, pass it and cast strings back to 64 bits integers in
>
> Have you seen my 'nanotime' package? It does just that: provide nanosecond
> resolution by relying on RcppCCTZ for the parsing/formating and int64 for the
> storage.
>
> | C++. And vice and versa when I pass my result back. But the size of my
> | vectors are in the range of millions of items, so the method is just a bit
> | slow.
>
> You never ever want to format + parse that many vectors. It is too slow.
> |
> | Since Rcpp 0.9.8, there is no more support for the LongVector class. Papers
> | like http://www.sciencedirect.com/science/article/pii/S0098300416307415,
> | despite very interesting, were not very useful to solve my simple problem,
> | so I was wondering if there is a better solution ?
> |
> | reinterpret_cast ?
> | GenericVector or RawVector ?
> | Anything so obvious that I just missed it ?
> |
> | And of course, same questions in the other direction: how to return my
> | vector back to R and have a bit64 at the end ?
>
> As Kevin correctly pointed out, int64 really just "rearranges" the 64 bits in
> a double. It is implemeneted as a REALSXP, or for us, a NumericVector.
>
> Poke around those two packages of mine and you should get farther.
For the sake of completeness, the RSQLite package supports reading (but
not yet writing) of 64-bit data, and uses Rcpp for this.
-Kirill
>
> Dirk
>
More information about the Rcpp-devel
mailing list