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

Migrate away from deprecated TileDB C APIs. #306

Merged
merged 3 commits into from
May 8, 2024

Conversation

teo-tsirpanis
Copy link
Member

SC-45987

This PR updates TileDB-Go's usage of deprecated C APIs. The first commit migrates the Group.GetMember*** functions to use tiledb_group_get_member_by_(index|name)_v2, while also adding code to work with TileDB string handles. The second commit deprecates Query.SubmitAsync, whose underlying C API has been deprecated since 2.15.

After that, the only deprecated C APIs used by TileDB-Go are inside deprecated Go APIs.

if ret != C.TILEDB_OK {
return "", "", TILEDB_INVALID, fmt.Errorf("Error getting member by index for group: %s", g.context.LastError())
}
defer C.tiledb_string_free(&curi)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiledb_string_free returns a result, which I don't know what to do with here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it always returns TILEDB_OK. I think it's safe to ignore the return value; especially since tiledb_group_get_member_by_index_v2 succeeded at this point, which is what the caller cares about.

@teo-tsirpanis
Copy link
Member Author

CI is green.

@teo-tsirpanis teo-tsirpanis marked this pull request as ready for review April 24, 2024 17:03
Copy link
Contributor

@NullHypothesis NullHypothesis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for this!

@@ -274,42 +274,47 @@ func (g *Group) GetMemberCount() (uint64, error) {
}

func (g *Group) GetMemberFromIndex(index uint64) (string, string, ObjectTypeEnum, error) {
var curi *C.char
defer C.free(unsafe.Pointer(curi))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this could have resulted in NULL pointer dereference segfaults if tiledb_group_get_member_by_index returned with an error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so; free(null) is a no-op.

if ret != C.TILEDB_OK {
return "", "", TILEDB_INVALID, fmt.Errorf("Error getting member by index for group: %s", g.context.LastError())
}
defer C.tiledb_string_free(&curi)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it always returns TILEDB_OK. I think it's safe to ignore the return value; especially since tiledb_group_get_member_by_index_v2 succeeded at this point, which is what the caller cares about.

@NullHypothesis NullHypothesis merged commit 3951f3b into master May 8, 2024
7 checks passed
@teo-tsirpanis teo-tsirpanis deleted the teo/deprecated-apis branch May 8, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants