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

feat(kv): define forward cursor interface #16212

Merged
merged 8 commits into from
Dec 19, 2019
Merged

feat(kv): define forward cursor interface #16212

merged 8 commits into from
Dec 19, 2019

Conversation

GeorgeMac
Copy link
Contributor

@GeorgeMac GeorgeMac commented Dec 12, 2019

Closes #5367

This PR introduces the concept for a ForwardCursor as described in the issue above. It's purpose is to create a contract in cursor creators declare upfront the direction and start position in which to create a cursor. This will promote healthier access patterns to the existing cursor. Allowing us to optimize a lot easier in the kv bucket implementations.

  1. Define the forward cursor interface. A single direction cursor which is configured with a direction on creation.
c := bucket.ForwardCursor([]byte("runs/"),
        kv.WithCursorDirection(kv.CursorDescending),
        kv.WithCursorHints(kv.WithCursorHintKeyStart("runs/12345")))
  1. Update all bucket implementations to adhere to new ForwardCursor() method.
  • CHANGELOG.md updated with a link to the PR (not the Issue)
  • Well-formatted commit messages
  • Rebased/mergeable
  • Tests pass
  • http/swagger.yml updated (if modified Go structs or API)
  • Documentation updated or issue created (provide link to issue/pr)
  • Signed CLA (if not already signed)

kv/store.go Outdated Show resolved Hide resolved
@GeorgeMac GeorgeMac marked this pull request as ready for review December 12, 2019 15:51
Copy link
Contributor

@stuartcarnie stuartcarnie left a comment

Choose a reason for hiding this comment

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

Looks great George. I found that that inmem goroutine for the ForwardCursor can leak if the consumer does not call Next to completion.

bolt/kv.go Show resolved Hide resolved
inmem/kv.go Outdated Show resolved Hide resolved
kv/cursor.go Outdated Show resolved Hide resolved
Copy link
Contributor

@stuartcarnie stuartcarnie left a comment

Choose a reason for hiding this comment

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

Great improvements – one minor suggestion to simplify the Close logic

inmem/kv.go Outdated Show resolved Hide resolved
inmem/kv.go Outdated Show resolved Hide resolved
@GeorgeMac GeorgeMac force-pushed the gm/forward-cursor branch 2 times, most recently from 05b9693 to d6fcc65 Compare December 19, 2019 10:39
Copy link
Contributor

@stuartcarnie stuartcarnie left a comment

Choose a reason for hiding this comment

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

Awesome stuff – this is the beginning to improving the K/V APIs 🏆

@GeorgeMac GeorgeMac merged commit 48b8cb8 into master Dec 19, 2019
@GeorgeMac GeorgeMac deleted the gm/forward-cursor branch December 19, 2019 16:30
alexpaxton pushed a commit that referenced this pull request Jan 9, 2020
* feat(kv): define forward cursor interface

* feat(kv): implement ForwardCursor on bolt and inmem buckets

* feat(kv): update tests to capture forward cursor

* fix(kv): typo in docs

* feat(kv): add Err method to ForwardCursor interface

* feat(inmem): batch pair channel sends in forward cursor

* fix(kv): remove Err field from kv.Pair

* feat(kv): add Close to kv.ForwardCursor interface
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.

process map shard error on influxdb 0.9.6.1
2 participants