Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
lidavidm committed Jul 12, 2023
1 parent 025d45b commit 4d430a9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
12 changes: 8 additions & 4 deletions go/adbc/pkg/_tmpl/driver.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/apache/arrow-adbc/go/adbc"
"github.com/apache/arrow/go/v13/arrow/array"
"github.com/apache/arrow/go/v13/arrow/cdata"
"github.com/apache/arrow/go/v13/arrow/memory"
"github.com/apache/arrow/go/v13/arrow/memory/mallocator"
)

Expand Down Expand Up @@ -201,8 +202,9 @@ func getFromHandle[T any](ptr unsafe.Pointer) *T {
func exportStringOption(val string, out *C.char, length *C.size_t) C.AdbcStatusCode {
lenWithTerminator := C.size_t(len(val) + 1)
if lenWithTerminator <= *length {
// TODO: doesn't this reallocate the string? can we avoid this?
C.strncpy(out, (*C.char)(C.CString(val)), lenWithTerminator)
sink := fromCArr[byte]((*byte)(unsafe.Pointer(out)), int(*length))
copy(sink, val)
sink[lenWithTerminator] = 0
}
*length = lenWithTerminator
return C.ADBC_STATUS_OK
Expand Down Expand Up @@ -1689,9 +1691,11 @@ func {{.Prefix}}DriverInit(version C.int, rawDriver *C.void, err *C.struct_AdbcE

switch version {
case C.ADBC_VERSION_1_0_0:
C.memset(unsafe.Pointer(driver), 0, C.ADBC_DRIVER_1_0_0_SIZE)
sink := fromCArr[byte]((*byte)(unsafe.Pointer(driver)), C.ADBC_DRIVER_1_0_0_SIZE)
memory.Set(sink, 0)
case C.ADBC_VERSION_1_1_0:
C.memset(unsafe.Pointer(driver), 0, C.ADBC_DRIVER_1_1_0_SIZE)
sink := fromCArr[byte]((*byte)(unsafe.Pointer(driver)), C.ADBC_DRIVER_1_1_0_SIZE)
memory.Set(sink, 0)
default:
setErr(err, "Only version 1.0.0/1.1.0 supported, got %d", int(version))
return C.ADBC_STATUS_NOT_IMPLEMENTED
Expand Down
12 changes: 8 additions & 4 deletions go/adbc/pkg/flightsql/driver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions go/adbc/pkg/panicdummy/driver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions go/adbc/pkg/snowflake/driver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4d430a9

Please sign in to comment.