stenlarsson commented on PR #48491:
URL: https://github.com/apache/arrow/pull/48491#issuecomment-3701793436

   > I can understand your motivation (providing the same API as doc for easy 
to code generation) but non GObject Introspection friendly API isn't expected.
   
   I was hoping that GObject Introspection could support this in the future, 
but I can also see that it will be very difficult to express the types of the 
key and values inside a hash table inside an array.
   
   > In general, using GArray/GPtrArray in API is one of "Things to avoid": 
https://gi.readthedocs.io/en/latest/writingbindableapis.html#arrays
   >
   > > In a general-purpose library, it’s best not to expose GLib array and 
hash types such as GArray, GPtrArray, GByteArray, GList, GSList, GQueue, and 
GHashTable in the public API. They are fine for internal libraries, but 
difficult in general for consumers of introspected libraries to deal with.
   
   That makes sense, but we are already using GHashTable for the field 
metadata, so I thought that was fine: 
https://github.com/apache/arrow/blob/43273fde11aae439df7f0c7034f8dfaf9b2bc661/c_glib/arrow-glib/field.cpp#L328-L329
   
   > GLib's main target is Ruby but I want to keep GLib API usable for other 
languages such as Vala and Lua.
   
   I agree, and again I was hoping this API could be supported by GObject 
Introspection in the future, but I see now that it won't.
   
   > Can we avoid using this approach (using GArray and GPtrArray properties)?
   >
   > My suggestion:
   > 
   > * Provide garrow_make_struct_options_add_field() in GLib
   > * Provide Arrow::FunctionOptions#keywords or something for code generation 
in Ruby
   > * Provide Arrow::MakeStructOptions#fields= in Ruby
   > * Provide Arrow::MakeStructOptions#keywords (or something) that includes 
fields in Ruby
   
   I feels like the keywords will be very specific to my use case, and not very 
useful in general? If you were to dynamically generate code you wouldn't need 
to know exactly what the options are. You could just accept `**options` and 
pass that `Arrow::Function#resolve_options`.
   
   I think I need to give up on the idea that I can generate code for all 
functions. How about this:
   
   * Provide garrow_make_struct_options_add_field() in GLib
   * Remove the `field-names` property to avoid inconsistency
   * Provide `Arrow::MakeStructOptions#try_convert` as you suggested earlier
   * In my code: Override the `make_struct` function with a specific 
implementation
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to