// Root returns the Root Iteration for a space
10099
func (m *GormIterationRepository) Root(ctx context.Context, spaceID uuid.UUID) (*Iteration, error) {
	defer goa.MeasureSince([]string{"goa", "db", "iteration", "query"}, time.Now())
	var itr Iteration

	tx := m.db.Where("space_id = ? AND nlevel(path)=1", spaceID).First(&itr)
	if tx.Error != nil {
		log.Error(ctx, map[string]interface{}{
			"space_id": spaceID,
			"err":      tx.Error,
		}, "unable to get the root iteration")
		if tx.Error == gorm.ErrRecordNotFound {
			return nil, errors.NewNotFoundError("root iteration for space", spaceID.String())
		}
		return nil, errors.NewInternalError(ctx, tx.Error)
	}
	return &itr, nil
}
1266137
func (s *storage) RootKey() ([]byte, []byte, error) {
	storage, closer := s.getStorage()
	defer closer()
	return storage.RootKey()
}
647230
func (gi Instance) RootDiskGB() uint64 {
	if gi.spec == nil {
		return 0
	}
	attached := gi.RootDisk()
	return uint64(attached.InitializeParams.DiskSizeGb)
}
1155380
func (self *Tree) Root() *Node {
	if self.Nodes == nil {
		return nil
	} else {
		return &self.Levels[0][0]
	}
}
446848
func (db *MemDB) getRoot() *iradix.Tree {
	root := (*iradix.Tree)(atomic.LoadPointer(&db.root))
	return root
}
304441
func (t *TimeoutExecution) Root(c context.Context) *ds.Key {
	return model.AttemptKeyFromID(c, t.For.AttemptID())
}
447458
func (nb *NodeBuilder) Root() (Node, error) {
	if !nb.done {
		return nil, errors.New(ErrBuilder, errorMessages, "building is not yet done")
	}
	return nb.stack[0], nil
}
630503
func (m *GormAreaRepository) Root(ctx context.Context, spaceID uuid.UUID) (*Area, error) {
	defer goa.MeasureSince([]string{"goa", "db", "Area", "root"}, time.Now())
	var rootArea []Area

	rootArea, err := m.Query(FilterBySpaceID(spaceID), func(db *gorm.DB) *gorm.DB {
		return db.Where("space_id = ? AND nlevel(path)=1", spaceID)
	})

	if len(rootArea) != 1 {
		return nil, errors.NewInternalError(ctx, errs.Errorf("single Root area not found for space %s", spaceID))
	}
	if err != nil {
		return nil, err
	}
	return &rootArea[0], nil
}
283664
func ParseRoot(str string) (Root, error) {
	str = strings.TrimSpace(str)
	switch {
	case strings.HasPrefix(str, gitPrefix):
		root := Root{Type: GitRoot}
		if err := setRoot(&root, str[len(gitPrefix):]); err != nil {
			return Root{}, err
		}
		return root, nil
	case strings.HasPrefix(str, kbfsPrefix):
		root := Root{Type: KBFSRoot}
		if err := setRoot(&root, str[len(kbfsPrefix):]); err != nil {
			return Root{}, err
		}
		return root, nil

	default:
		return Root{}, ErrInvalidKeybasePagesRecord{}
	}
}
798616
func (group *ExampleGroup) Root() *ExampleGroup {
	if group.Parent == nil {
		return group
	}
	ancestors := group.Ancestors()
	return ancestors[len(ancestors) - 1]
}
405353
func (f *NotifyExecution) Root(c context.Context) *ds.Key {
	return model.ExecutionKeyFromID(c, f.Notification.ID)
}
397405
func RootCause(err error) error {
	if ex, ok := err.(Err); ok {
		return RootCause(ex.Err())
	}
	return err
}
341528
func (fs *FS) Root() string {
	return path.Join(fs.h.GetCanonicalPath(), fs.subdir)
}
597031
func (v *JSVal) SetRoot(c Constraint) *JSVal {
	v.root = c
	return v
}
268663
func (t *Trie) Hash() common.Hash {
	hash, cached, _ := t.hashRoot(nil, nil)
	t.root = cached
	return common.BytesToHash(hash.(hashNode))
}
787083
func (i *IdentityMapping) RootPair() Identity {
	uid, gid, _ := GetRootUIDGID(i.uids, i.gids)
	return Identity{UID: uid, GID: gid}
}
988869
func (c *Context) Root() *Context {
	if c.Parent != nil {
		return c.Parent.Root()
	}
	return c
}