Closed taniabogatsch closed 1 month ago
Nice! A few suggestions on the public interface.
Perhaps InitFromTypes
and SetSize
should be private methods (for now)? InitFromTypes
because it's using internal arguments and SetSize
since it's likely not necessary to expose publicly?
Destroy
can also be private until we have cases where it needs to be public. If/when it goes public I think the signature should be Close() error
to follow go naming conventions.
@ajzo90, good call, I've made them private. Do you have any other suggestions?
Small question, is there a reason projection support wasn't added? If not could this still be added via another PR? and if yet should we make a new type to support projection?
Also for table functions SetSize
is must be exposed, as a tablefunction might not want to fill the entire chunk, I will expose this in my PR. (Same for GetSize
)
This PR introduces a new
DataChunk
API. See the discussion here. Ideally, all interaction between go-duckdb and duckdb's data chunks eventually goes through this API without compromising performance. As an outlook, in #219, I further used this API for go-duckdb's scanner.As a first step, this PR moves all interaction between the
Appender
and data chunks to theDataChunk
API and its setter functions, further decreasing the complexity of theAppender
code.This PR adds the following functions:
func (chunk *DataChunk) InitFromTypes(ptr unsafe.Pointer, types []C.duckdb_logical_type) error
func (chunk *DataChunk) Destroy()
func (chunk *DataChunk) SetSize() error
func (chunk *DataChunk) SetValue(colIdx int, rowIdx int, val any) error
Additionally, I reverted the column index in the data chunk when returning an unsupported type error message to 0-based indexing.
Questions
helper.go
file. However, I recommend renaming this file or moving its functions to a different place. What do you think?DataChunk
, and by implication, thevector
structs are becoming universal components without ties to theAppender
. Thus, I renamedappender_vector.go
tovector.go
. Also, I added a new file,vector_setters.go
, to create some functionality separation and decrease file sizes. Is this a good approach?