Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBZ-8586 add array accessors #2

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions debezium.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ func Get(proxyPtr uint32, fieldName string) uint32 {
return envGet(proxyPtr, uint32(uintptr(fieldNamePtr)))
}

// access the elemnt at index of the array
func GetArrayElem(proxyPtr uint32, elementIdx uint32) uint32 {
return envGetArrayElem(proxyPtr, uint32(elementIdx))
}

// returns the dimension of the array
func GetArraySize(proxyPtr uint32) uint32 {
return envGetArraySize(proxyPtr)
}

// materialize the String content referenced
func GetString(proxyPtr uint32) string {
var resultPtr = envGetString(proxyPtr)
Expand Down Expand Up @@ -121,6 +131,14 @@ func envSetBool(valuePtr uint32) uint32
//export get
func envGet(proxyPtr, fieldNamePtr uint32) uint32

//go:wasm-module env
//export get_array_elem
func envGetArrayElem(proxyPtr, elemIdx uint32) uint32

//go:wasm-module env
//export get_array_size
func envGetArraySize(proxyPtr uint32) uint32

//go:wasm-module env
//export get_bool
func envGetBool(proxyPtr uint32) uint32
Expand Down
10 changes: 10 additions & 0 deletions it/debezium_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ func wazeroStub(ctx context.Context) wazero.Runtime {
return 14
}).
Export("is_null").
NewFunctionBuilder().
WithFunc(func(v1, v2 uint32) uint32 {
return 15
}).
Export("get_array_elem").
NewFunctionBuilder().
WithFunc(func(v uint32) uint32 {
return 16
}).
Export("get_array_size").
Instantiate(ctx)

if err != nil {
Expand Down
Loading