func NewWriteQTree(bs *bstore.BlockStore, id uuid.UUID) (*QTree, error) { gen := bs.ObtainGeneration(id) rv := &QTree{ sb: gen.New_SB, gen: gen, bs: bs, } //If there is an existing root node, we need to load it so that it //has the correct values if rv.sb.Root() != 0 { rt, err := rv.LoadNode(rv.sb.Root(), rv.sb.Gen(), ROOTPW, ROOTSTART) if err != nil { log.Panicf("%v", err) return nil, err } rv.root = rt } else { rt, err := rv.NewCoreNode(ROOTSTART, ROOTPW) if err != nil { log.Panicf("%v", err) return nil, err } rv.root = rt } return rv, nil }
/** * Load a quasar tree */ func NewReadQTree(bs *bstore.BlockStore, id uuid.UUID, generation uint64) (*QTree, error) { sb := bs.LoadSuperblock(id, generation) if sb == nil { return nil, ErrNoSuchStream } rv := &QTree{sb: sb, bs: bs} if sb.Root() != 0 { rt, err := rv.LoadNode(sb.Root(), sb.Gen(), ROOTPW, ROOTSTART) if err != nil { log.Panicf("%v", err) return nil, err } //log.Debug("The start time for the root is %v",rt.StartTime()) rv.root = rt } return rv, nil }