aboutsummaryrefslogtreecommitdiff
path: root/cursor.go
diff options
context:
space:
mode:
Diffstat (limited to 'cursor.go')
-rw-r--r--cursor.go40
1 files changed, 10 insertions, 30 deletions
diff --git a/cursor.go b/cursor.go
index d1990dc..b93178e 100644
--- a/cursor.go
+++ b/cursor.go
@@ -1,29 +1,24 @@
package bolt
type Cursor struct {
- transaction *Transaction
bucket *Bucket
- stack []stackelem
+ stack []elem
}
-type stackelem struct {
+// elem represents a node on a page that's on the cursor's stack.
+type elem struct {
page *page
index int
}
-func (c *Cursor) Transaction() *Transaction {
- return c.transaction
-}
-
func (c *Cursor) Bucket() *Bucket {
return c.bucket
}
-func (c *Cursor) Get(key []byte) ([]byte, error) {
- // TODO: Move to key
- // TODO: If it doesn't exist, return nil, nil
- // TODO: Otherwise return node key+data.
- return nil, nil
+// First moves the cursor to the first item in the bucket and returns its key and data.
+func (c *Cursor) First() ([]byte, []byte, error) {
+ // TODO: Traverse to the first key.
+ return nil, nil, nil
}
// Move the cursor to the next key/value.
@@ -31,27 +26,12 @@ func (c *Cursor) Next() ([]byte, []byte, error) {
return nil, nil, nil
}
-// First moves the cursor to the first item in the bucket and returns its key and data.
-func (c *Cursor) First() ([]byte, []byte, error) {
- // TODO: Traverse to the first key.
- return nil, nil, nil
-}
-
-// Set the cursor on a specific data item.
-// (bool return is whether it is exact).
-func (c *Cursor) set(key []byte, data []byte, op int) (error, bool) {
+// Goto positions the cursor at a specific key.
+func (c *Cursor) Goto(key []byte) ([]byte, error) {
// TODO(benbjohnson): Optimize for specific use cases.
// TODO: Check if len(key) > 0.
// TODO: Start from root page and traverse to correct page.
- return nil, false
-}
-
-func (c *Cursor) insert(key []byte, data []byte) error {
- // TODO: If there is not enough space on page for key+data then split.
- // TODO: Move remaining data on page forward.
- // TODO: Write leaf node to current location.
- // TODO: Adjust available page size.
- return nil
+ return nil, nil
}