Working on view pair crash.
This commit is contained in:
parent
4a7ab1bc85
commit
930d064962
@ -35,14 +35,28 @@ type BoltBucket struct {
|
|||||||
errorFlag bool
|
errorFlag bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BoltBucket) SetName(nm []byte) {
|
func NewBoltBucket(parent *BoltBucket, name []byte) *BoltBucket {
|
||||||
b.name = nm
|
ret := new(BoltBucket)
|
||||||
|
ret.parent = parent
|
||||||
|
ret.name = name
|
||||||
for _, dtk := range dataTypeNameSlice {
|
for _, dtk := range dataTypeNameSlice {
|
||||||
if _, err := datatypes[dtk].ToString(nm); err == nil {
|
if _, err := datatypes[dtk].ToString(name); err == nil {
|
||||||
b.nameDatatype = datatypes[dtk]
|
ret.nameDatatype = datatypes[dtk]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BoltBucket) GetPathNode() PathNode {
|
||||||
|
return PathNode{
|
||||||
|
name: b.name,
|
||||||
|
dataType: b.nameDatatype,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BoltBucket) SetName(nm []byte) {
|
||||||
|
b.name = nm
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -76,6 +90,13 @@ func NewBoltPair(parent *BoltBucket, key, val []byte) *BoltPair {
|
|||||||
return &tp
|
return &tp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *BoltPair) GetPathNode() PathNode {
|
||||||
|
return PathNode{
|
||||||
|
name: p.key,
|
||||||
|
dataType: p.keyDatatype,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (bd *BoltDB) getGenericFromStringPath(path []PathNode) (*BoltBucket, *BoltPair, error) {
|
func (bd *BoltDB) getGenericFromStringPath(path []PathNode) (*BoltBucket, *BoltPair, error) {
|
||||||
return bd.getGenericFromPath(path)
|
return bd.getGenericFromPath(path)
|
||||||
}
|
}
|
||||||
@ -319,7 +340,7 @@ func (b *BoltBucket) GetStringName() string {
|
|||||||
GetPath returns the database path leading to this BoltBucket
|
GetPath returns the database path leading to this BoltBucket
|
||||||
*/
|
*/
|
||||||
func (b *BoltBucket) GetPath() []PathNode {
|
func (b *BoltBucket) GetPath() []PathNode {
|
||||||
bktPath := PathNode{name: b.name, dataType: b.nameDatatype}
|
bktPath := b.GetPathNode()
|
||||||
if b.parent != nil {
|
if b.parent != nil {
|
||||||
return append(b.parent.GetPath(), bktPath)
|
return append(b.parent.GetPath(), bktPath)
|
||||||
}
|
}
|
||||||
@ -333,7 +354,7 @@ The passed prefix is the path leading to the current bucket
|
|||||||
func (b *BoltBucket) buildVisiblePathSlice(prefix []PathNode) ([][]PathNode, error) {
|
func (b *BoltBucket) buildVisiblePathSlice(prefix []PathNode) ([][]PathNode, error) {
|
||||||
var retSlice [][]PathNode
|
var retSlice [][]PathNode
|
||||||
var retErr error
|
var retErr error
|
||||||
bucketNode := PathNode{b.name, b.nameDatatype}
|
bucketNode := b.GetPathNode()
|
||||||
retSlice = append(retSlice, append(prefix, bucketNode))
|
retSlice = append(retSlice, append(prefix, bucketNode))
|
||||||
if b.expanded {
|
if b.expanded {
|
||||||
// Add subbuckets
|
// Add subbuckets
|
||||||
@ -346,7 +367,7 @@ func (b *BoltBucket) buildVisiblePathSlice(prefix []PathNode) ([][]PathNode, err
|
|||||||
}
|
}
|
||||||
// Add pairs
|
// Add pairs
|
||||||
for i := range b.pairs {
|
for i := range b.pairs {
|
||||||
retSlice = append(retSlice, append(append(prefix, bucketNode, PathNode{b.pairs[i].key, b.pairs[i].keyDatatype})))
|
retSlice = append(retSlice, append(append(prefix, bucketNode, b.pairs[i].GetPathNode())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retSlice, retErr
|
return retSlice, retErr
|
||||||
@ -417,7 +438,10 @@ func (p *BoltPair) GetStringVal() string {
|
|||||||
GetPath Returns the path of the BoltPair
|
GetPath Returns the path of the BoltPair
|
||||||
*/
|
*/
|
||||||
func (p *BoltPair) GetPath() []PathNode {
|
func (p *BoltPair) GetPath() []PathNode {
|
||||||
return append(p.parent.GetPath(), PathNode{name: p.key, dataType: p.keyDatatype})
|
return append(
|
||||||
|
p.parent.GetPath(),
|
||||||
|
p.GetPathNode(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is a go-between function (between the boltbrowser structs
|
/* This is a go-between function (between the boltbrowser structs
|
||||||
@ -429,7 +453,7 @@ func (p *BoltPair) GetPath() []PathNode {
|
|||||||
*/
|
*/
|
||||||
func addBucketFromBoltBucket(path []PathNode, bb *BoltBucket) error {
|
func addBucketFromBoltBucket(path []PathNode, bb *BoltBucket) error {
|
||||||
if err := insertBucket(path, bb.name); err == nil {
|
if err := insertBucket(path, bb.name); err == nil {
|
||||||
bucketPath := append(path, PathNode{name: bb.name, dataType: bb.nameDatatype})
|
bucketPath := append(path, bb.GetPathNode())
|
||||||
for i := range bb.pairs {
|
for i := range bb.pairs {
|
||||||
if err = insertPair(bucketPath, bb.pairs[i].key, bb.pairs[i].val); err != nil {
|
if err = insertPair(bucketPath, bb.pairs[i].key, bb.pairs[i].val); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user