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

Add binding for tiledb_array_consolidate_fragments. #322

Merged
merged 5 commits into from
Jul 19, 2024

Conversation

shaunrd0
Copy link
Contributor

@shaunrd0 shaunrd0 commented Jun 20, 2024

This adds the tiledb_array_consolidate_fragments binding required for cloud fragment list consolidation.

CI will fail on this PR until TileDB-Inc/TileDB#5135 is merged and backported to the core version in use by TileDB-Go.

@shaunrd0 shaunrd0 force-pushed the smr/sc-49723/add-array-consolidate-fragments branch from 927bba4 to c0aa2c1 Compare June 21, 2024 16:23
@shaunrd0 shaunrd0 force-pushed the smr/sc-49723/add-array-consolidate-fragments branch from c0aa2c1 to 0e1a439 Compare July 16, 2024 12:34
@shaunrd0
Copy link
Contributor Author

shaunrd0 commented Jul 16, 2024

I opened a story for follow up to enable the test added in this PR. The test fails on 2.24.X but passes on 2.25.0 with the fix in TileDB-Inc/TileDB#5135.

This is ready for review, the test failure was the only thing keeping this PR in draft.

@shaunrd0 shaunrd0 marked this pull request as ready for review July 16, 2024 19:11
@shaunrd0 shaunrd0 force-pushed the smr/sc-49723/add-array-consolidate-fragments branch from b4165a6 to 2e35c1f Compare July 16, 2024 19:24
@ypatia
Copy link
Member

ypatia commented Jul 18, 2024

@NullHypothesis @thetorpedodog this is now ready for review. I don't feel yet confident in reviewing Go code :/

Copy link
Contributor

@thetorpedodog thetorpedodog left a comment

Choose a reason for hiding this comment

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

overall very good. a few minor suggestions that you can clean up at your leisure

Comment on lines +28 to +41
// cStringArray takes an array of Go strings and converts it to an array of CStrings.
// The function returned should be deferred by the caller to free allocated memory.
func cStringArray(stringList []string) ([]*C.char, func()) {
list := make([]*C.char, len(stringList))
for i, str := range stringList {
list[i] = C.CString(str)
}

return list, func() {
for _, str := range list {
C.free(unsafe.Pointer(str))
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this a lot.

list, freeMemory := cStringArray(fragmentList)
defer freeMemory()

ret := C.tiledb_array_consolidate_fragments(a.context.tiledbContext, curi, (**C.char)(unsafe.Pointer(&list[0])), C.uint64_t(len(list)), config.tiledbConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

(unsafe.Pointer(&list[0])) can be slicePtr(list).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

func TestGetConsolidationPlan(t *testing.T) {
// Create an 1d array
func createTestArray(t *testing.T) *Array {
// Create a 1d array
Copy link
Contributor

Choose a reason for hiding this comment

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

since the function createTestArray would be visible to all tests in this package, it might be worth making the name more specific, since the array created may not be suitable for all tests. maybe create1DTestArray?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


array := createTestArray(t)

numFrags := uint32(5)
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like you’re doing this for the assert.Equal below…

require.NoError(t, err)
fragToVacuumNum, err := fragmentInfo.GetToVacuumNum()
require.NoError(t, err)
require.Equal(t, numFrags, fragToVacuumNum)
Copy link
Contributor

Choose a reason for hiding this comment

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

…but instead, you can write require.EqualValues(t, numFrags, fragToVacuumNum) (or require.Equal(t, uint32(numFrags), ...)) to avoid having a bunch of uint32(n)s above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much better, very nice 👍

@shaunrd0 shaunrd0 merged commit 8fda6ba into master Jul 19, 2024
7 checks passed
@shaunrd0 shaunrd0 deleted the smr/sc-49723/add-array-consolidate-fragments branch July 19, 2024 12:43
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.

3 participants