Creating an array and attaching it to a pointer to a type

167 views
Skip to first unread message

Douglas Bates

unread,
Apr 1, 2016, 6:11:02 PM4/1/16
to julia-dev
I'm still trying to come up with a way to read a feather (https://github.com/wesm/feather) file in Julia.  The available library that essentially defines the format is written in C++ and, while I can imitate existing code, I quickly tie myself in knots trying to access the heavily templated C++ code in a C function that can be called through ccall.

The file contains the binary representations of a number of columns, all the same length but not necessarily the same type. We want to return copies of the contents of the columns and their names and possibly other metadata.  Before I open the file I don't know the number of rows, number of columns or types of columns.  This information is all embedded in the binary file, the format of which is really only accessible through the C++ functions and methods.

I want to somehow create a C function that will take the path name, and possibly a pointer to a struct, open the file, determine the number of rows and the number and types of the columns, allocate storage that belongs to Julia and populate it.  If I have a pointer to an array of n Float64 values, say, how would I create a Julia Vector{Float64} of length n so that I can copy the contents into it?  And once I have created and populated the vector, how to I return it?  I'm sort-of thinking of passing a Ref{<immutable type>} and assigning a field in there but that is just a guess.

Scott Jones

unread,
Apr 1, 2016, 9:30:54 PM4/1/16
to julia-dev
I was told on Twitter by the great Hadley Wickham 🤓 himself a couple of days ago:
@GandalfSoftware @wesmckinn  if it was blocking you, I think we could add a C API fairly quickly

You should also comment on these issues (about Julia support and C99 support):

It might be easier to wait until they produce a C API as part of their library, before trying to get a Julia wrapper for it.
Reply all
Reply to author
Forward
0 new messages