Documentation
¶
Index ¶
- func MBRToTuple(m MBR) tuple.Tuple
- type ArithmeticError
- type ChildSlot
- type IndexOutOfBoundsError
- type ItemSlot
- type MBR
- type NegativeArraySizeError
- type NodeKind
- type NullPointerError
- type Point
- type RTree
- func (rt *RTree) Clear(tx fdb.WritableTransaction) error
- func (rt *RTree) Delete(tx fdb.WritableTransaction, point Point, keySuffix tuple.Tuple) error
- func (rt *RTree) InsertOrUpdate(tx fdb.WritableTransaction, point Point, keySuffix tuple.Tuple, ...) error
- func (rt *RTree) Scan(tx fdb.ReadTransaction, lastHV *big.Int, lastKey tuple.Tuple, ...) ([]ItemSlot, error)
- func (rt *RTree) ScanIterator(tx fdb.ReadTransaction, lastHV *big.Int, lastKey tuple.Tuple, ...) *RTreeIterator
- type RTreeConfig
- type RTreeIterator
- type RTreeStorage
- type StorageAdapter
- type VerifyError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MBRToTuple ¶
MBRToTuple serializes an MBR to a flat tuple [low0, ..., lowN-1, high0, ..., highN-1]. Matches Java's ChildSlot MBR serialization.
Types ¶
type ArithmeticError ¶
type ArithmeticError struct{ Message string }
ArithmeticError is Java's ArithmeticException.
func (*ArithmeticError) Error ¶
func (e *ArithmeticError) Error() string
type ChildSlot ¶
type ChildSlot struct {
SmallestHV *big.Int
SmallestKey tuple.Tuple
LargestHV *big.Int
LargestKey tuple.Tuple
ChildID []byte
ChildMBR MBR
}
ChildSlot is an intermediate node slot referencing a child node.
type IndexOutOfBoundsError ¶
type IndexOutOfBoundsError struct{ Index, Length int }
IndexOutOfBoundsError is Java's IndexOutOfBoundsException.
func (*IndexOutOfBoundsError) Error ¶
func (e *IndexOutOfBoundsError) Error() string
type ItemSlot ¶
ItemSlot is a leaf node slot containing a data item.
type MBR ¶
MBR is a minimum bounding rectangle for N dimensions. Stored as [low0, low1, ..., lowN-1, high0, high1, ..., highN-1].
func MBRFromPoint ¶
MBRFromPoint creates a degenerate MBR containing only a single point.
func MBRFromTuple ¶
MBRFromTuple deserializes an MBR from a flat tuple.
func (MBR) ContainsPoint ¶
ContainsPoint returns true if the MBR contains the given point.
func (MBR) NumDimensions ¶
NumDimensions returns the number of dimensions.
type NegativeArraySizeError ¶
type NegativeArraySizeError struct{ Size int }
NegativeArraySizeError is Java's NegativeArraySizeException.
func (*NegativeArraySizeError) Error ¶
func (e *NegativeArraySizeError) Error() string
type NullPointerError ¶
type NullPointerError struct{}
NullPointerError is Java's NullPointerException, from Objects.requireNonNull with no message.
func (*NullPointerError) Error ¶
func (*NullPointerError) Error() string
type Point ¶
Point represents an N-dimensional point with int64 coordinates. Null coordinates are represented as nil in the tuple.
func (Point) Coordinate ¶
Coordinate returns the coordinate at the given dimension index, or MinInt64 if nil.
func (Point) NumDimensions ¶
NumDimensions returns the number of dimensions.
type RTree ¶
type RTree struct {
// contains filtered or unexported fields
}
RTree is a Hilbert R-tree backed by FDB. Matches Java's com.apple.foundationdb.async.rtree.RTree.
func NewRTree ¶
func NewRTree(storage *StorageAdapter, config RTreeConfig) (*RTree, error)
NewRTree creates a new R-tree. Like Java's RTree it takes any minM, maxM and splitS: a configuration that cannot keep the node invariants fails at the operation where Java's fails (see errors.go).
func (*RTree) Clear ¶
func (rt *RTree) Clear(tx fdb.WritableTransaction) error
Clear removes all data from the R-tree.
func (*RTree) InsertOrUpdate ¶
func (rt *RTree) InsertOrUpdate(tx fdb.WritableTransaction, point Point, keySuffix tuple.Tuple, value tuple.Tuple) error
InsertOrUpdate inserts a new item or updates an existing one. Matches Java's RTree.insertOrUpdate().
func (*RTree) Scan ¶
func (rt *RTree) Scan(tx fdb.ReadTransaction, lastHV *big.Int, lastKey tuple.Tuple, mbrPredicate func(MBR) bool) ([]ItemSlot, error)
Scan returns all items matching the MBR predicate, starting after (lastHV, lastKey). Items are returned in Hilbert value order. Convenience wrapper around ScanIterator.
func (*RTree) ScanIterator ¶
func (rt *RTree) ScanIterator(tx fdb.ReadTransaction, lastHV *big.Int, lastKey tuple.Tuple, mbrPredicate func(MBR) bool) *RTreeIterator
ScanIterator returns a lazy iterator over items matching the MBR predicate, starting after (lastHV, lastKey). Items are yielded one at a time in Hilbert value order. Only fetches leaf nodes from FDB on demand.
type RTreeConfig ¶
type RTreeConfig struct {
MinM int // Min slots per non-root node (default 16)
MaxM int // Max slots per node (default 32)
SplitS int // Siblings involved in split/fuse (default 2)
Storage RTreeStorage // Node layout (default BY_NODE)
StoreHilbertValues bool // Store HV in leaf slots (default true)
UseNodeSlotIndex bool // Maintain the node slot index (default false)
NumDimensions int // Number of spatial dimensions
}
RTreeConfig configures the R-tree behavior. Matches Java's RTree.Config.
func DefaultRTreeConfig ¶
func DefaultRTreeConfig(numDimensions int) RTreeConfig
DefaultRTreeConfig returns the default R-tree configuration, Java's RTree.DEFAULT_CONFIG.
type RTreeIterator ¶
type RTreeIterator struct {
// contains filtered or unexported fields
}
RTreeIterator lazily walks the R-tree depth-first in Hilbert order, fetching one leaf node at a time from FDB.
type RTreeStorage ¶
type RTreeStorage string
RTreeStorage is Java's RTree.Storage: how a node's slots are laid out.
const ( // RTreeStorageByNode stores a node as one key/value pair, its slots a // nested tuple in the value (Java's ByNodeStorageAdapter). The default. RTreeStorageByNode RTreeStorage = "BY_NODE" // RTreeStorageBySlot stores each slot of a node as its own key/value pair // under the node's key (Java's BySlotStorageAdapter). RTreeStorageBySlot RTreeStorage = "BY_SLOT" )
type StorageAdapter ¶
type StorageAdapter struct {
// contains filtered or unexported fields
}
StorageAdapter serializes R-tree nodes in FDB in the layout the index's StorageAdapter option names (RTreeConfig.Storage):
- BY_NODE (Java's ByNodeStorageAdapter): each node is one key-value pair, subspace.pack(nodeId) → tuple(nodeKind, slotList), slotList a nested tuple holding each slot as a sub-tuple (its key items, then its value items).
- BY_SLOT (Java's BySlotStorageAdapter): each slot is its own pair under the node, subspace.pack(nodeId, nodeKind, slotKey...) → tuple(slotValue...).
With the rtreeUseNodeSlotIndex option it also maintains Java's node slot index (NodeSlotIndexAdapter): an empty-valued key (level, largestHilbertValue, largestKey items..., childId) in the index's secondary subspace for every child slot of every intermediate node, level being the child's (a leaf is level 0). The index is a function of the tree alone, so Go maintains it as the difference the operation made to the intermediate nodes it touched (flushNodeSlotIndex) rather than per slot change as Java's change sets do; the stored entries are the same.
func NewStorageAdapter ¶
func NewStorageAdapter(ss subspace.Subspace, config RTreeConfig) *StorageAdapter
func (*StorageAdapter) WithEnv ¶
func (s *StorageAdapter) WithEnv(env *dst.Env) *StorageAdapter
WithEnv routes node-ID entropy through env (nil keeps production).
func (*StorageAdapter) WithNodeSlotIndex ¶
func (s *StorageAdapter) WithNodeSlotIndex(sub subspace.Subspace) *StorageAdapter
WithNodeSlotIndex sets the node slot index's subspace, which an R-tree with the rtreeUseNodeSlotIndex option maintains.
type VerifyError ¶
type VerifyError struct{}
VerifyError is Guava's VerifyException from one of RTree's Verify.verify checks, which carry no message.
func (*VerifyError) Error ¶
func (*VerifyError) Error() string