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

Use z.Buffer backing for B+ tree #268

Merged
merged 9 commits into from
Apr 28, 2021
Merged

Use z.Buffer backing for B+ tree #268

merged 9 commits into from
Apr 28, 2021

Conversation

ajeetdsouza
Copy link
Contributor

@ajeetdsouza ajeetdsouza commented Apr 21, 2021

  • z.Tree should use a z.Buffer backing.
  • z.Buffer should use a z.MmapFile backing.
  • Add persistent API to z.Buffer, so it doesn't delete the file after closing.
  • Add persistent API to z.Tree, so that we can use it for persistent storage.

This change is Reviewable

z/btree.go Outdated Show resolved Hide resolved
z/buffer.go Outdated
if b.maxSz-int(b.offset) < n {
panic(fmt.Sprintf("Buffer max size exceeded: %d."+
" Offset: %d. Grow: %d", b.maxSz, b.offset, n))
if b.maxSz != 0 && int(b.offset)+n > b.maxSz {
Copy link
Contributor

Choose a reason for hiding this comment

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

When can b.maxSz be 0? It should always have a valid value.

Copy link
Contributor Author

@ajeetdsouza ajeetdsouza Apr 22, 2021

Choose a reason for hiding this comment

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

I've kept the zero value as an "unbounded" buffer. The earlier API set maxSz = math.MaxInt32 (roughly 2.1GB) by default. The caller is expected to set this using the WithMaxSize API now. Should I change it back?

Copy link
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 4 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ajeetdsouza and @jarifibrahim)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants