Commit 8d21e8cc authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb/btree: Rearrange data structure definitions

In the next patch we are going to expose access to BTree/Bucket entries
as public API. This will turn _BTreeItem into Entry and will also add
BucketEntry data type. Before doing that rearrange the order in which
the data structure go:

	- BTree,
	- Entry (_BTreeItem for now),
	- Bucket
	- BucketEntry (not present for now).

Only code movement - no other change.
parent d124ea04
......@@ -29,33 +29,6 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb/internal/pickletools"
)
// Bucket is a leaf node of a B tree.
//
// It mimics Bucket from btree/py.
type Bucket struct {
zodb.Persistent
// https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BTreeModuleTemplate.c#L179:
//
// A Bucket wraps contiguous vectors of keys and values. Keys are unique,
// and stored in sorted order. The 'values' pointer may be NULL if the
// Bucket is used to implement a set. Buckets serving as leafs of BTrees
// are chained together via 'next', so that the entire BTree contents
// can be traversed in sorted order quickly and easily.
next *Bucket // the bucket with the next-larger keys
keys []KEY // 'len' keys, in increasing order
values []interface{} // 'len' corresponding values
}
// _BTreeItem mimics BTreeItem from btree/py.
//
// XXX export for BTree.Children?
type _BTreeItem struct {
key KEY
child interface{} // BTree or Bucket
}
// BTree is a non-leaf node of a B tree.
//
// It mimics BTree from btree/py.
......@@ -79,6 +52,33 @@ type BTree struct {
data []_BTreeItem
}
// _BTreeItem mimics BTreeItem from btree/py.
//
// XXX export for BTree.Children?
type _BTreeItem struct {
key KEY
child interface{} // BTree or Bucket
}
// Bucket is a leaf node of a B tree.
//
// It mimics Bucket from btree/py.
type Bucket struct {
zodb.Persistent
// https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BTreeModuleTemplate.c#L179:
//
// A Bucket wraps contiguous vectors of keys and values. Keys are unique,
// and stored in sorted order. The 'values' pointer may be NULL if the
// Bucket is used to implement a set. Buckets serving as leafs of BTrees
// are chained together via 'next', so that the entire BTree contents
// can be traversed in sorted order quickly and easily.
next *Bucket // the bucket with the next-larger keys
keys []KEY // 'len' keys, in increasing order
values []interface{} // 'len' corresponding values
}
// Get searches BTree by key.
//
// It loads intermediate BTree nodes from database on demand as needed.
......
......@@ -31,33 +31,6 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb/internal/pickletools"
)
// IOBucket is a leaf node of a B⁺ tree.
//
// It mimics IOBucket from btree/py.
type IOBucket struct {
zodb.Persistent
// https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BTreeModuleTemplate.c#L179:
//
// A IOBucket wraps contiguous vectors of keys and values. Keys are unique,
// and stored in sorted order. The 'values' pointer may be NULL if the
// IOBucket is used to implement a set. Buckets serving as leafs of BTrees
// are chained together via 'next', so that the entire IOBTree contents
// can be traversed in sorted order quickly and easily.
next *IOBucket // the bucket with the next-larger keys
keys []int32 // 'len' keys, in increasing order
values []interface{} // 'len' corresponding values
}
// _IOBTreeItem mimics BTreeItem from btree/py.
//
// XXX export for IOBTree.Children?
type _IOBTreeItem struct {
key int32
child interface{} // IOBTree or IOBucket
}
// IOBTree is a non-leaf node of a B⁺ tree.
//
// It mimics IOBTree from btree/py.
......@@ -81,6 +54,33 @@ type IOBTree struct {
data []_IOBTreeItem
}
// _IOBTreeItem mimics BTreeItem from btree/py.
//
// XXX export for IOBTree.Children?
type _IOBTreeItem struct {
key int32
child interface{} // IOBTree or IOBucket
}
// IOBucket is a leaf node of a B⁺ tree.
//
// It mimics IOBucket from btree/py.
type IOBucket struct {
zodb.Persistent
// https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BTreeModuleTemplate.c#L179:
//
// A IOBucket wraps contiguous vectors of keys and values. Keys are unique,
// and stored in sorted order. The 'values' pointer may be NULL if the
// IOBucket is used to implement a set. Buckets serving as leafs of BTrees
// are chained together via 'next', so that the entire IOBTree contents
// can be traversed in sorted order quickly and easily.
next *IOBucket // the bucket with the next-larger keys
keys []int32 // 'len' keys, in increasing order
values []interface{} // 'len' corresponding values
}
// Get searches IOBTree by key.
//
// It loads intermediate IOBTree nodes from database on demand as needed.
......
......@@ -31,33 +31,6 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb/internal/pickletools"
)
// LOBucket is a leaf node of a B⁺ tree.
//
// It mimics LOBucket from btree/py.
type LOBucket struct {
zodb.Persistent
// https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BTreeModuleTemplate.c#L179:
//
// A LOBucket wraps contiguous vectors of keys and values. Keys are unique,
// and stored in sorted order. The 'values' pointer may be NULL if the
// LOBucket is used to implement a set. Buckets serving as leafs of BTrees
// are chained together via 'next', so that the entire LOBTree contents
// can be traversed in sorted order quickly and easily.
next *LOBucket // the bucket with the next-larger keys
keys []int64 // 'len' keys, in increasing order
values []interface{} // 'len' corresponding values
}
// _LOBTreeItem mimics BTreeItem from btree/py.
//
// XXX export for LOBTree.Children?
type _LOBTreeItem struct {
key int64
child interface{} // LOBTree or LOBucket
}
// LOBTree is a non-leaf node of a B⁺ tree.
//
// It mimics LOBTree from btree/py.
......@@ -81,6 +54,33 @@ type LOBTree struct {
data []_LOBTreeItem
}
// _LOBTreeItem mimics BTreeItem from btree/py.
//
// XXX export for LOBTree.Children?
type _LOBTreeItem struct {
key int64
child interface{} // LOBTree or LOBucket
}
// LOBucket is a leaf node of a B⁺ tree.
//
// It mimics LOBucket from btree/py.
type LOBucket struct {
zodb.Persistent
// https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BTreeModuleTemplate.c#L179:
//
// A LOBucket wraps contiguous vectors of keys and values. Keys are unique,
// and stored in sorted order. The 'values' pointer may be NULL if the
// LOBucket is used to implement a set. Buckets serving as leafs of BTrees
// are chained together via 'next', so that the entire LOBTree contents
// can be traversed in sorted order quickly and easily.
next *LOBucket // the bucket with the next-larger keys
keys []int64 // 'len' keys, in increasing order
values []interface{} // 'len' corresponding values
}
// Get searches LOBTree by key.
//
// It loads intermediate LOBTree nodes from database on demand as needed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment