//Preloads preloads relations, don`t touch out
9503
func (s *DB) Preloads(out interface{}) *DB {
	return s.NewScope(out).InstanceSet("gorm:only_preload", 1).callCallbacks(s.parent.callbacks.queries).db
}
1150312
func (l *TeamLoader) userPreload(ctx context.Context, links []*ChainLinkUnpacked, fullVerifyCutoff keybase1.Seqno) (cancel func()) {
	ctx, cancel = context.WithCancel(ctx)
	if teamEnv.UserPreloadEnable {
		uidSet := make(map[keybase1.UID]struct{})
		for _, link := range links {
			// fullVerify definition copied from verifyLink
			fullVerify := (link.LinkType() != libkb.SigchainV2TypeTeamLeave) ||
				(link.Seqno() >= fullVerifyCutoff) ||
				(link.source.EldestSeqno == 0)
			if !link.isStubbed() && fullVerify {
				uidSet[link.inner.Body.Key.UID] = struct{}{}
			}
		}
		l.G().Log.CDebugf(ctx, "TeamLoader userPreload uids: %v", len(uidSet))
		if teamEnv.UserPreloadParallel {
			// Note this is full-parallel. Probably want pipelining if this is to be turned on by default.
			var wg sync.WaitGroup
			for uid := range uidSet {
				wg.Add(1)
				go func(uid keybase1.UID) {
					_, _, err := l.G().GetUPAKLoader().LoadV2(
						libkb.NewLoadUserArg(l.G()).WithUID(uid).WithPublicKeyOptional().WithNetContext(ctx))
					if err != nil {
						l.G().Log.CDebugf(ctx, "error preloading uid %v", uid)
					}
					wg.Done()
				}(uid)
			}
			if teamEnv.UserPreloadWait {
				wg.Wait()
			}
		} else {
			for uid := range uidSet {
				_, _, err := l.G().GetUPAKLoader().LoadV2(
					libkb.NewLoadUserArg(l.G()).WithUID(uid).WithPublicKeyOptional().WithNetContext(ctx))
				if err != nil {
					l.G().Log.CDebugf(ctx, "error preloading uid %v", uid)
				}
			}
		}
	}
	return cancel
}
232589
func (s *RediStore) load(session *sessions.Session) (bool, error) {
	conn := s.Pool.Get()
	defer conn.Close()
	if err := conn.Err(); err != nil {
		return false, err
	}
	data, err := conn.Do("GET", s.keyPrefix+session.ID)
	if err != nil {
		return false, err
	}
	if data == nil {
		return false, nil // no data was associated with this key
	}
	b, err := redis.Bytes(data, err)
	if err != nil {
		return false, err
	}
	return true, s.serializer.Deserialize(b, session)
}
1078419
func CacheLoad(c context.Context, b backend.B, k Key, v *Value) (rv *Value, err error) {
	switch k.Op {
	case OpGet:
		rv, err = doGet(c, b, k.ConfigSet, k.Path, v, k.Params())
	case OpGetAll:
		rv, err = doGetAll(c, b, k.GetAllTarget, k.Path, v, k.Params())
	default:
		return nil, errors.Reason("unknown operation: %v", k.Op).Err()
	}
	if err != nil {
		return nil, err
	}
	return
}
73246
func (i *smallIndex) load() {
	it := i.db.NewIterator(util.BytesPrefix(i.prefix), nil)
	defer it.Release()
	for it.Next() {
		val := string(it.Value())
		id := binary.BigEndian.Uint32(it.Key()[len(i.prefix):])
		if val != "" {
			// Empty value means the entry has been deleted.
			i.id2val[id] = val
			i.val2id[val] = id
		}
		if id >= i.nextID {
			i.nextID = id + 1
		}
	}
}
1201458
func (h Middleware) servePreloadLinks(pusher http.Pusher, headers http.Header, resources []string) {
outer:
	for _, resource := range resources {
		for _, resource := range parseLinkHeader(resource) {
			if _, exists := resource.params["nopush"]; exists {
				continue
			}

			if h.isRemoteResource(resource.uri) {
				continue
			}

			err := pusher.Push(resource.uri, &http.PushOptions{
				Method: http.MethodGet,
				Header: headers,
			})

			if err != nil {
				break outer
			}
		}
	}
}
1163633
func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, cfg vm.Config, interrupt *uint32) {
	var (
		header  = block.Header()
		gaspool = new(GasPool).AddGas(block.GasLimit())
	)
	// Iterate over and process the individual transactions
	for i, tx := range block.Transactions() {
		// If block precaching was interrupted, abort
		if interrupt != nil && atomic.LoadUint32(interrupt) == 1 {
			return
		}
		// Block precaching permitted to continue, execute the transaction
		statedb.Prepare(tx.Hash(), block.Hash(), i)
		if err := precacheTransaction(p.config, p.bc, nil, gaspool, statedb, header, tx, cfg); err != nil {
			return // Ugh, something went horribly wrong, bail out
		}
	}
}
1129870
func (env *environ) PrecheckInstance(ctx context.ProviderCallContext, args environs.PrecheckInstanceParams) error {
	volumeAttachmentsZone, err := volumeAttachmentsZone(args.VolumeAttachments)
	if err != nil {
		return errors.Trace(err)
	}
	if _, err := env.instancePlacementZone(ctx, args.Placement, volumeAttachmentsZone); err != nil {
		return errors.Trace(err)
	}

	if args.Constraints.HasInstanceType() {
		if !checkInstanceType(args.Constraints) {
			return errors.Errorf("invalid GCE instance type %q", *args.Constraints.InstanceType)
		}
	}

	return nil
}
1030861
func (env *sessionEnviron) PrecheckInstance(ctx context.ProviderCallContext, args environs.PrecheckInstanceParams) error {
	if _, err := env.parsePlacement(ctx, args.Placement); err != nil {
		return errors.Trace(err)
	}
	if err := env.checkZones(ctx, args.Constraints.Zones); err != nil {
		return errors.Trace(err)
	}
	err := env.checkDatastore(ctx, args.Constraints.RootDiskSource)
	return errors.Trace(err)
}
559501
func Preload(t *testing.T, repo grimoire.Repo) {
	// preparte tests data
	user := User{Name: "preload", Gender: "male", Age: 10}
	repo.From(users).MustSave(&user)

	userAddresses := []Address{
		{Address: "preload1", UserID: &user.ID},
		{Address: "preload2", UserID: &user.ID},
		{Address: "preload3", UserID: &user.ID},
	}

	repo.From(addresses).MustSave(&userAddresses[0])
	repo.From(addresses).MustSave(&userAddresses[1])
	repo.From(addresses).MustSave(&userAddresses[2])

	assert.Nil(t, user.Addresses)

	t.Run("Preload Addresses", func(t *testing.T) {
		repo.From(addresses).Preload(&user, "Addresses")
		assert.Equal(t, userAddresses, user.Addresses)
	})

	t.Run("Preload Addresses with query", func(t *testing.T) {
		repo.From(addresses).Where(c.Eq(address, "preload1")).Preload(&user, "Addresses")
		assert.Equal(t, 1, len(user.Addresses))
		assert.Equal(t, userAddresses[0], user.Addresses[0])
	})

	user.Addresses = nil

	t.Run("Preload User", func(t *testing.T) {
		repo.From(users).Preload(&userAddresses[0], "User")
		assert.Equal(t, user, userAddresses[0].User)
	})

	t.Run("Preload User slice", func(t *testing.T) {
		repo.From(users).Preload(&userAddresses, "User")
		assert.Equal(t, user, userAddresses[0].User)
		assert.Equal(t, user, userAddresses[1].User)
		assert.Equal(t, user, userAddresses[2].User)
	})
}
239883
func (tl TypeLoader) LoadRelkind(args *ArgType, relType RelType) (map[string]*Type, error) {
	var err error

	// load tables
	tableList, err := tl.TableList(args.DB, args.Schema, tl.Relkind(relType))
	if err != nil {
		return nil, err
	}

	// tables
	tableMap := make(map[string]*Type)
	for _, ti := range tableList {
		// create template
		typeTpl := &Type{
			Name:    SingularizeIdentifier(ti.TableName),
			Schema:  args.Schema,
			RelType: relType,
			Fields:  []*Field{},
			Table:   ti,
		}

		// process columns
		err = tl.LoadColumns(args, typeTpl)
		if err != nil {
			return nil, err
		}

		tableMap[ti.TableName] = typeTpl
	}

	// generate table templates
	for _, t := range tableMap {
		err = args.ExecuteTemplate(TypeTemplate, t.Name, "", t)
		if err != nil {
			return nil, err
		}
	}

	return tableMap, nil
}
590881
func (st *State) precheckInstance(
	series string,
	cons constraints.Value,
	placement string,
	volumeAttachments []storage.VolumeAttachmentParams,
) error {
	if st.policy == nil {
		return nil
	}
	prechecker, err := st.policy.Prechecker()
	if errors.IsNotImplemented(err) {
		return nil
	} else if err != nil {
		return err
	}
	if prechecker == nil {
		return errors.New("policy returned nil prechecker without an error")
	}
	return prechecker.PrecheckInstance(
		CallContext(st),
		environs.PrecheckInstanceParams{
			Series:            series,
			Constraints:       cons,
			Placement:         placement,
			VolumeAttachments: volumeAttachments,
		})
}
15407
func (s *SeesawECU) ConfigReload(ctx *ipc.Context, reply *int) error {
	s.trace("ConfigReload", ctx)

	authConn, err := s.ecu.authConnect(ctx)
	if err != nil {
		return err
	}
	defer authConn.Close()

	if err := authConn.ConfigReload(); err != nil {
		return err
	}
	return nil
}
139700
func (s *SeesawEngine) ConfigReload(ctx *ipc.Context, reply *int) error {
	s.trace("ConfigReload", ctx)
	if ctx == nil {
		return errors.New("context is nil")
	}

	if !ctx.IsTrusted() {
		return errors.New("insufficient access")
	}

	return s.engine.notifier.Reload()
}
339542
func (e *ListTrackersEngine) Prereqs() Prereqs {
	session := false
	if e.uid.IsNil() && len(e.username) == 0 {
		session = true
	}
	return Prereqs{Device: session}
}
381981
func PrefetchCount(count int) Option {
	return func(r *Rabbus) error {
		r.config.qos.prefetchCount = count
		return nil
	}
}
1232192
func (d *DefaultLoader) MustLoad(conf interface{}) {
	if err := d.Load(conf); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(2)
	}

	// we at koding, believe having sane defaults in our system, this is the
	// reason why we have default validators in DefaultLoader. But do not cause
	// nil pointer panics if one uses DefaultLoader directly.
	if d.Validator != nil {
		d.MustValidate(conf)
	}
}