353solutions / carrow

Go wrapper for Apache Arrow C++
https://arrow.apache.org/
BSD 3-Clause "New" or "Revised" License
15 stars 0 forks source link

Expose CSV options to Go #63

Open tebeka opened 4 years ago

tebeka commented 4 years ago

The arrow CSV package has the following options: ReadOptions, ParseOptions & ConvertOptions. Expose them to Go.

tebeka commented 4 years ago

Maybe use functional options

tebeka commented 4 years ago

Problem

These option structs are C++ structs, they have a static Defaults function that returns a struct (not pointer). When creating an arrow::csv::Reader you need to pass options by reference.

cgo can’t work directly with C++, which means we can use them directly as C.ParseOptions.

Possible Solutions

new function

A C function that will get all the parameters for an options struct and create it.

Problems

Use Pointers

Have C wrappers that will create a pointer to options struct and have setters.

Problems

C Shadow struct

Have a C struct that will be a copy of the C++ struct. Can be used directly from Go and passed around by value.

Problems

SWIG

Use swig to generate wrappers.

Problems


1: If you have a procedure with 10 parameters, you probably missed some. - Alan Perlis

tebeka commented 4 years ago

@yonidavidson Care to weigh in on the above?

yonidavidson commented 4 years ago

This can be a good POC for SWIG, yet I don't think SWIG will be our silver bullet so It might not be worth to add complexity to our system with it. I think a functional API is a good choice, it gives you an ability to have a good default and to expose the parameters in a need to have way (easy to extend).

tebeka commented 4 years ago

I'll probably go with C shadow struct for now. I'll defer SWIG for when we go all-in on it.