bptree does not work well for auto-increasing keys
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
package bptree
|
||||
|
||||
var (
|
||||
protoNodeId = int64(0)
|
||||
)
|
||||
func GetProtoNodeId() int64 {
|
||||
protoNodeId++
|
||||
return protoNodeId
|
||||
}
|
||||
|
||||
func (self *BpMap) getRoot() *BpNode {
|
||||
return self.root
|
||||
}
|
||||
@@ -26,3 +34,39 @@ func (self *BpNode) getPrev() *BpNode {
|
||||
func (self *BpNode) setPrev(prev *BpNode) {
|
||||
self.prev = prev
|
||||
}
|
||||
func (self *BpNode) getNode(x int)(*BpNode) {
|
||||
return self.pointers[x]
|
||||
}
|
||||
|
||||
func (self *BpNode) maybePersist(shouldPersist bool) error {
|
||||
if !shouldPersist {
|
||||
return nil
|
||||
}
|
||||
return self.persist()
|
||||
}
|
||||
func (self *BpNode) persist() error {
|
||||
if PersistFn != nil {
|
||||
return PersistFn(self)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (self *BpNode) destroy() error {
|
||||
if DestroyFn != nil {
|
||||
return DestroyFn(self)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func persist(a, b *BpNode) error {
|
||||
if a != nil {
|
||||
if err := a.persist(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if b != nil {
|
||||
if err := b.persist(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user