diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-01-26 15:29:06 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-01-26 15:29:06 -0700 |
commit | 1baa6d576a5f13a55d81c83a167efe0953c0d143 (patch) | |
tree | 83f10236ee028b8e6ef559a6ca53f1d81ad39cba /cursor.go | |
parent | Remove RWCursor. (diff) | |
download | dedo-1baa6d576a5f13a55d81c83a167efe0953c0d143.tar.gz dedo-1baa6d576a5f13a55d81c83a167efe0953c0d143.tar.xz |
Initialize transaction/rwtransaction.
Diffstat (limited to 'cursor.go')
-rw-r--r-- | cursor.go | 40 |
1 files changed, 10 insertions, 30 deletions
@@ -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 } |