// Load writes the given Unit to disk, subscribing to relevant dbus
// events and caching the Unit's Hash.
543066
func (m *systemdUnitManager) Load(name string, u unit.UnitFile) error {
	m.mutex.Lock()
	defer m.mutex.Unlock()
	err := m.writeUnit(name, u.String())
	if err != nil {
		return err
	}
	if _, exists := u.Contents["Install"]; exists {
		log.Debugf("Detected [Install] section in the systemd unit (%s)", name)
		ok, err := m.enableUnit(name)
		if err != nil || !ok {
			m.removeUnit(name)
			return fmt.Errorf("Failed to enable systemd unit %s: %v", name, err)
		}
	}
	m.hashes[name] = u.Hash()
	return nil
}
320490
func (s *Script) Load(c Conn) error {
	_, err := c.Do("SCRIPT", "LOAD", s.src)
	return err
}
321483
func (r *GormWorkItemTypeGroupRepository) Load(ctx context.Context, groupID uuid.UUID) (*WorkItemTypeGroup, error) {
	defer goa.MeasureSince([]string{"goa", "db", "workitemtypegroup", "load"}, time.Now())
	log.Debug(ctx, map[string]interface{}{"witg_id": groupID}, "loading work item type group ")
	res := WorkItemTypeGroup{}
	db := r.db.Model(&res).Where("id=?", groupID).First(&res)
	if db.RecordNotFound() {
		log.Error(ctx, map[string]interface{}{"witg_id": groupID}, "work item type group not found")
		return nil, errors.NewNotFoundError("work item type group", groupID.String())
	}
	if err := db.Error; err != nil {
		return nil, errors.NewInternalError(ctx, err)
	}
	typeList, err := r.loadTypeList(ctx, res.ID)
	if err != nil {
		return nil, errs.WithStack(err)
	}
	res.TypeList = typeList
	return &res, nil
}
1028452
func (m *deviceMounter) Load(devPrefixes []string) error {
	return m.load(devPrefixes, deviceFindMountPoint)
}
66784
func Load(ctx context.Context, g *libkb.GlobalContext, lArg keybase1.LoadTeamArg) (*Team, error) {
	teamData, err := g.GetTeamLoader().Load(ctx, lArg)
	if err != nil {
		return nil, err
	}
	ret := NewTeam(ctx, g, teamData)

	if lArg.RefreshUIDMapper {
		// If we just loaded the group, then inform the UIDMapper of any UID->EldestSeqno
		// mappings, so that we're guaranteed they aren't stale.
		ret.refreshUIDMapper(ctx, g)
	}

	return ret, nil
}
896588
func (db *PGStore) load(session *sessions.Session) error {
	var s PGSession

	err := db.selectOne(&s, session.ID)
	if err != nil {
		return err
	}

	return securecookie.DecodeMulti(session.Name(), string(s.Data), &session.Values, db.Codecs...)
}
333338
func Load(content string) (tree *Tree, err error) {
	return LoadBytes([]byte(content))
}
255148
func (s *Service) load(m Module) {
	moduleName := getModuleName(m)
	config, ok := s.configs[moduleName]
	if ok {
		panic("cycle: " + moduleName)
	} else if config != nil {
		BootPrintln("skipping already initialized module", moduleName)
		return
	}

	s.configs[moduleName] = nil
	config = &Config{parent: m, service: s}
	BootPrintln("[service] initializing", moduleName)
	m.Init(config)

	v := reflect.ValueOf(m)
	if v.Kind() == reflect.Ptr {
		v = v.Elem()
	}
	for i := 0; i < v.NumField(); i++ {
		f := v.Field(i)
		if f.Kind() != reflect.Ptr {
			continue
		}

		// check if field is a module
		val := reflect.New(f.Type().Elem())
		dep, ok := val.Interface().(Module)
		if !ok {
			continue
		}

		// warn on unexported modules
		if !f.CanSet() {
			BootPrintln("[service] warning: unexported module in", moduleName, f.String())
			continue
		}

		// reuse already initialized values
		if n := s.configs[getModuleName(dep)]; n != nil {
			f.Set(reflect.ValueOf(n.parent))
			continue
		}

		// set the field and initialize the field
		f.Set(val)
		s.load(dep)
	}
	s.modules = append(s.modules, m)
	s.configs[moduleName] = config
}
662555
func Load(dir string) (train, test *Set, err error) {
	if train, err = ReadSet(path.Join(dir, "train-images-idx3-ubyte.gz"), path.Join(dir, "train-labels-idx1-ubyte.gz")); err != nil {
		return nil, nil, err
	}
	if test, err = ReadSet(path.Join(dir, "t10k-images-idx3-ubyte.gz"), path.Join(dir, "t10k-labels-idx1-ubyte.gz")); err != nil {
		return nil, nil, err
	}
	return
}
1157231
func (che *ContainerHistoryEvent) Load() (*LaunchConfig, error) {
	return LoadLaunchConfig(che.history.s3Client, che.history.s3Bucket, che.history.s3Prefix, che.Hash)
}
481123
func (r *GormWorkItemTypeRepository) Load(ctx context.Context, id uuid.UUID) (*WorkItemType, error) {
	defer goa.MeasureSince([]string{"goa", "db", "workitemtype", "load"}, time.Now())
	log.Debug(ctx, map[string]interface{}{
		"wit_id": id,
	}, "Loading work item type")
	res, ok := cache.Get(id)
	if !ok {
		log.Info(ctx, map[string]interface{}{
			"wit_id": id,
		}, "Work item type doesn't exist in the cache. Loading from DB...")
		res = WorkItemType{}

		db := r.db.Model(&res).Where("id=?", id).First(&res)
		if db.RecordNotFound() {
			log.Error(ctx, map[string]interface{}{
				"wit_id": id,
			}, "work item type not found")
			return nil, errors.NewNotFoundError("work item type", id.String())
		}
		if err := db.Error; err != nil {
			return nil, errors.NewInternalError(ctx, err)
		}
		childTypes, err := r.loadChildTypeList(ctx, res.ID)
		if err != nil {
			return nil, errs.Wrapf(err, `failed to load child types for WIT "%s" (%s)`, res.Name, res.ID)
		}
		res.ChildTypeIDs = childTypes
		cache.Put(res)
	}
	return &res, nil
}
1197504
func (c *CasIdx) load(defs []schema.MetricDefinition, iter cqlIterator, now time.Time) []schema.MetricDefinition {
	defsByNames := make(map[string][]*schema.MetricDefinition)
	var id, name, unit, mtype string
	var orgId, interval int
	var partition int32
	var lastupdate int64
	var tags []string
	for iter.Scan(&id, &orgId, &partition, &name, &interval, &unit, &mtype, &tags, &lastupdate) {
		mkey, err := schema.MKeyFromString(id)
		if err != nil {
			log.Errorf("cassandra-idx: load() could not parse ID %q: %s -> skipping", id, err)
			continue
		}
		if orgId < 0 {
			orgId = int(idx.OrgIdPublic)
		}

		mdef := &schema.MetricDefinition{
			Id:         mkey,
			OrgId:      uint32(orgId),
			Partition:  partition,
			Name:       name,
			Interval:   interval,
			Unit:       unit,
			Mtype:      mtype,
			Tags:       tags,
			LastUpdate: lastupdate,
		}
		nameWithTags := mdef.NameWithTags()
		defsByNames[nameWithTags] = append(defsByNames[nameWithTags], mdef)
	}
	if err := iter.Close(); err != nil {
		log.Fatalf("Could not close iterator: %s", err.Error())
	}

	// getting all cutoffs once saves having to recompute everytime we have a match
	cutoffs := memory.IndexRules.Cutoffs(now)

NAMES:
	for nameWithTags, defsByName := range defsByNames {
		irId, _ := memory.IndexRules.Match(nameWithTags)
		cutoff := cutoffs[irId]
		for _, def := range defsByName {
			if def.LastUpdate >= cutoff {
				// if any of the defs for a given nameWithTags is not stale, then we need to load
				// all the defs for that nameWithTags.
				for _, defToAdd := range defsByNames[nameWithTags] {
					defs = append(defs, *defToAdd)
				}
				continue NAMES
			}
		}
	}

	return defs
}
510506
func (f *FastTeamChainLoader) load(m libkb.MetaContext, arg fastLoadArg) (res *fastLoadRes, err error) {

	defer m.Trace(fmt.Sprintf("FastTeamChainLoader#load(%+v)", arg), func() error { return err })()

	// Single-flight lock by team ID.
	lock := f.locktab.AcquireOnName(m.Ctx(), m.G(), arg.ID.String())
	defer lock.Release(m.Ctx())

	return f.loadLockedWithRetries(m, arg)
}
702175
func (m *nfsMounter) Load(source []string) error {
	info, err := mount.GetMounts()
	if err != nil {
		return err
	}
	re := regexp.MustCompile(`,addr=(.*)`)
MountLoop:
	for _, v := range info {
		host := "localhost"
		if len(m.servers) != 0 {
			if !strings.HasPrefix(v.Fstype, "nfs") {
				continue
			}
			matches := re.FindStringSubmatch(v.VfsOpts)
			if len(matches) != 2 {
				continue
			}

			if exists := m.serverExists(matches[1]); !exists {
				continue
			}
			host = matches[1]
		}
		m.normalizeSource(v, host)
		mount, ok := m.mounts[v.Source]
		if !ok {
			mount = &Info{
				Device:     v.Source,
				Fs:         v.Fstype,
				Minor:      v.Minor,
				Mountpoint: make([]*PathInfo, 0),
			}
			m.mounts[v.Source] = mount
		}
		// Allow Load to be called multiple times.
		for _, p := range mount.Mountpoint {
			if p.Path == v.Mountpoint {
				continue MountLoop
			}
		}
		mount.Mountpoint = append(mount.Mountpoint,
			&PathInfo{
				Path: normalizeMountPath(v.Mountpoint),
			},
		)
	}
	return nil
}
1219859
func (c *baseCache) load(key interface{}, cb func(interface{}, *time.Duration, error) (interface{}, error), isWait bool) (interface{}, bool, error) {
	v, called, err := c.loadGroup.Do(key, func() (v interface{}, e error) {
		defer func() {
			if r := recover(); r != nil {
				e = fmt.Errorf("Loader panics: %v", r)
			}
		}()
		return cb(c.loaderExpireFunc(key))
	}, isWait)
	if err != nil {
		return nil, called, err
	}
	return v, called, nil
}
373041
func (m *MemDB) load(kvOffset int) (b []byte) {
	if kvOffset < 0 {
		return nil
	}
	bLen, n := binary.Uvarint(m.kvData[kvOffset:])
	i, j := kvOffset+n, kvOffset+n+int(bLen)
	return m.kvData[i:j:j]
}
171257
func (c *config) load() error {
	path, err := c.path()
	if err != nil {
		return nil
	}
	return c.loadFromPath(path)
}