// LoadIndexes loads schema index definitions.
971991
func (tl TypeLoader) LoadIndexes(args *ArgType, tableMap map[string]*Type) (map[string]*Index, error) {
	var err error

	ixMap := map[string]*Index{}
	for _, t := range tableMap {
		// load table indexes
		err = tl.LoadTableIndexes(args, t, ixMap)
		if err != nil {
			return nil, err
		}
	}

	// generate templates
	for _, ix := range ixMap {
		err = args.ExecuteTemplate(IndexTemplate, ix.Type.Name, ix.Index.IndexName, ix)
		if err != nil {
			return nil, err
		}
	}

	return ixMap, nil
}
389556
func loadModules() {
	keys := []string{}
	for _, key := range Config.Options("module.") {
		keys = append(keys, key)
	}

	// Reorder module order by key name, a poor mans sort but at least it is consistent
	sort.Strings(keys)
	for _, key := range keys {
		moduleLog.Debug("Sorted keys", "keys", key)

	}
	for _, key := range keys {
		moduleImportPath := Config.StringDefault(key, "")
		if moduleImportPath == "" {
			continue
		}

		modulePath, err := ResolveImportPath(moduleImportPath)
		if err != nil {
			moduleLog.Error("Failed to load module.  Import of path failed", "modulePath", moduleImportPath, "error", err)
		}
		// Drop anything between module.???.<name of module>
		subKey := key[len("module."):]
		if index := strings.Index(subKey, "."); index > -1 {
			subKey = subKey[index+1:]
		}
		addModule(subKey, moduleImportPath, modulePath)
	}

	// Modules loaded, now show module path
	for key, callback := range appModule.initializedModules {
		if m := ModuleFromPath(key, false); m != nil {
			callback(m)
		} else {
			RevelLog.Error("Callback for non registered module initializing with application module", "modulePath", key)
			callback(appModule)
		}
	}
}
640408
func (ut *URLTransformer) LoadPaths(paths []string) error {
	for _, path := range paths {
		err := ut.LoadPath(path)
		if err != nil {
			return err
		}
	}
	return nil
}
38671
func (c *cache) ListIndexFuncValues(indexName string) []string {
	return c.cacheStorage.ListIndexFuncValues(indexName)
}
897000
func (p *Engine) LoadAssets(virtualDirectory string, virtualExtension string, assetFn func(name string) ([]byte, error), namesFn func() []string) error {
	var templateErr error
	/*fsLoader, err := pongo2.NewLocalFileSystemLoader(virtualDirectory)
	if err != nil {
		return err
	}*/
	set := pongo2.NewSet("", pongo2.DefaultLoader)
	set.Globals = getPongoContext(p.Config.Globals)

	// set the filters
	filters := p.convertFilters()
	for filterName, filterFunc := range filters {
		pongo2.RegisterFilter(filterName, filterFunc)
	}

	if len(virtualDirectory) > 0 {
		if virtualDirectory[0] == '.' { // first check for .wrong
			virtualDirectory = virtualDirectory[1:]
		}
		if virtualDirectory[0] == '/' || virtualDirectory[0] == os.PathSeparator { // second check for /something, (or ./something if we had dot on 0 it will be removed
			virtualDirectory = virtualDirectory[1:]
		}
	}

	p.mu.Lock()
	defer p.mu.Unlock()

	names := namesFn()
	for _, path := range names {
		if !strings.HasPrefix(path, virtualDirectory) {
			continue
		}

		rel, err := filepath.Rel(virtualDirectory, path)
		if err != nil {
			templateErr = err
			return err
		}

		ext := filepath.Ext(rel)
		if ext == virtualExtension {

			buf, err := assetFn(path)
			if err != nil {
				templateErr = err
				return err
			}
			name := filepath.ToSlash(rel)
			p.templateCache[name], err = set.FromString(string(buf))
			if err != nil {
				templateErr = err
				return err
			}
		}
	}
	return templateErr
}
366253
func (e *Engine) LoadAssets(virtualDirectory string, virtualExtension string, assetFn func(name string) ([]byte, error), namesFn func() []string) error {
	// register the global helpers
	if len(e.templateCache) == 0 && e.Config.Helpers != nil {
		raymond.RegisterHelpers(e.Config.Helpers)
	}
	if len(virtualDirectory) > 0 {
		if virtualDirectory[0] == '.' { // first check for .wrong
			virtualDirectory = virtualDirectory[1:]
		}
		if virtualDirectory[0] == '/' || virtualDirectory[0] == os.PathSeparator { // second check for /something, (or ./something if we had dot on 0 it will be removed
			virtualDirectory = virtualDirectory[1:]
		}
	}
	var templateErr error

	e.mu.Lock()
	defer e.mu.Unlock()

	names := namesFn()
	for _, path := range names {
		if !strings.HasPrefix(path, virtualDirectory) {
			continue
		}
		ext := filepath.Ext(path)
		if ext == virtualExtension {

			rel, err := filepath.Rel(virtualDirectory, path)
			if err != nil {
				templateErr = err
				return err
			}

			buf, err := assetFn(path)
			if err != nil {
				templateErr = err
				return err
			}
			contents := string(buf)
			name := filepath.ToSlash(rel)

			tmpl, err := raymond.Parse(contents)
			if err != nil {
				templateErr = err
				return err
			}
			e.templateCache[name] = tmpl

		}
	}
	return templateErr
}
324228
func (b *BaggedModel) LoadWithPrefix(reader *base.ClassifierDeserializer, prefix string) error {
	b.lock.Lock()
	defer b.lock.Unlock()

	pI := func(n string, i int) string {
		return reader.Prefix(prefix, reader.Prefix(n, fmt.Sprintf("%d", i)))
	}

	// Read the essential info
	randomFeaturesKey := reader.Prefix(prefix, "NUM_RANDOM_FEATURES")
	randomFeatures, err := reader.GetU64ForKey(randomFeaturesKey)
	if err != nil {
		return base.DescribeError("Can't read NUM_RANDOM_FEATURES", err)
	}

	b.RandomFeatures = int(randomFeatures)

	// Reload the classifiers
	for i, m := range b.Models {
		clsPrefix := fmt.Sprintf("%s/", pI("CLASSIFIERS", i))
		err := m.LoadWithPrefix(reader, clsPrefix)
		if err != nil {
			return base.DescribeError("Can't read classifier", err)
		}
	}

	// Load the instances template
	tmp, err := reader.GetInstancesForKey(reader.Prefix(prefix, "REFERENCE_INSTANCES"))
	if err != nil {
		return base.DescribeError("Can't read REFERENCE_INSTACES", err)
	}
	b.fitOn = tmp

	// Reload the selected attributes
	selectedAttributesKey := reader.Prefix(prefix, "SELECTED_ATTRIBUTES")
	ser := make(map[int][][]byte)
	err = reader.GetJSONForKey(selectedAttributesKey, &ser)
	if err != nil {
		return base.DescribeError("Can't reload selected attributes", err)
	}

	b.selectedAttributes = make(map[int][]base.Attribute)

	for key := range ser {
		b.selectedAttributes[key] = make([]base.Attribute, len(ser[key]))
		for i, attrBytes := range ser[key] {
			attr, err := base.DeserializeAttribute(attrBytes)
			if err != nil {
				return base.DescribeError("Can't deserialize attribute", err)
			}
			attrNew, err := base.ReplaceDeserializedAttributeWithVersionFromInstances(attr, b.fitOn)
			if err != nil {
				return base.DescribeError("Can't replace attribute", err)
			}
			b.selectedAttributes[key][i] = attrNew
		}
	}
	return nil
}
618080
func (a *ACLs) loadReaders(ctx *validation.Context, readers []string) []string {
	known := stringset.New(len(readers))
	for _, r := range readers {
		id := r
		switch {
		case strings.HasPrefix(r, "group:"):
			if r[len("group:"):] == "" {
				ctx.Errorf("invalid readers %q: needs a group name", r)
			}
		case !strings.ContainsRune(r, ':'):
			id = "user:" + r
			fallthrough
		default:
			if _, err := identity.MakeIdentity(id); err != nil {
				ctx.Error(errors.Annotate(err, "invalid readers %q", r).Err())
				continue
			}
		}
		if !known.Add(id) {
			ctx.Errorf("duplicate readers %q", r)
		}
	}
	res := known.ToSlice()
	sort.Strings(res)
	return res
}
197291
func (tl TypeLoader) LoadSchema(args *ArgType) error {
	var err error

	// load enums
	_, err = tl.LoadEnums(args)
	if err != nil {
		return err
	}

	// load procs
	_, err = tl.LoadProcs(args)
	if err != nil {
		return err
	}

	// load tables
	tableMap, err := tl.LoadRelkind(args, Table)
	if err != nil {
		return err
	}

	// load views
	viewMap, err := tl.LoadRelkind(args, View)
	if err != nil {
		return err
	}

	// merge views with the tableMap
	for k, v := range viewMap {
		tableMap[k] = v
	}

	// load foreign keys
	_, err = tl.LoadForeignKeys(args, tableMap)
	if err != nil {
		return err
	}

	// load indexes
	_, err = tl.LoadIndexes(args, tableMap)
	if err != nil {
		return err
	}

	return nil
}
820269
func (i18n *I18n) LoadTranslations() map[string]map[string]*Translation {
	var translations = map[string]map[string]*Translation{}

	for i := len(i18n.Backends); i > 0; i-- {
		backend := i18n.Backends[i-1]
		for _, translation := range backend.LoadTranslations() {
			if translations[translation.Locale] == nil {
				translations[translation.Locale] = map[string]*Translation{}
			}
			translations[translation.Locale][translation.Key] = translation
		}
	}
	return translations
}
572734
func (db *DB) schemaIndexPrefix(name string) (id byte, err error) {
	if name == "" {
		return 0, errors.New("index name can not be blank")
	}
	s, err := db.getSchema()
	if err != nil {
		return 0, err
	}
	nextID := keyPrefixIndexStart
	for i, f := range s.Indexes {
		if i >= nextID {
			nextID = i + 1
		}
		if f.Name == name {
			return i, nil
		}
	}
	id = nextID
	s.Indexes[id] = indexSpec{
		Name: name,
	}
	return id, db.putSchema(s)
}
295432
func (s *DescribeIndexFieldsOutput) SetIndexFields(v []*IndexFieldStatus) *DescribeIndexFieldsOutput {
	s.IndexFields = v
	return s
}
595020
func LoadFiles(config interface{}, files []string, opts Options) error {
	if len(files) == 0 {
		return errNoFilesToLoad
	}
	for _, name := range files {
		data, err := ioutil.ReadFile(name)
		if err != nil {
			return err
		}
		unmarshal := yaml.UnmarshalStrict
		if opts.DisableUnmarshalStrict {
			unmarshal = yaml.Unmarshal
		}
		if err := unmarshal(data, config); err != nil {
			return err
		}
	}
	if opts.DisableValidate {
		return nil
	}
	return validator.Validate(config)
}
516570
func (p *postgresql) LoadSchema(r io.Reader) error {
	return genericLoadSchema(p.ConnectionDetails, p.MigrationURL(), r)
}
519404
func (c *SQLiteConn) LoadExtension(lib string, entry string) error {
	rv := C.sqlite3_enable_load_extension(c.db, 1)
	if rv != C.SQLITE_OK {
		return errors.New(C.GoString(C.sqlite3_errmsg(c.db)))
	}

	clib := C.CString(lib)
	defer C.free(unsafe.Pointer(clib))
	centry := C.CString(entry)
	defer C.free(unsafe.Pointer(centry))

	rv = C.sqlite3_load_extension(c.db, clib, centry, nil)
	if rv != C.SQLITE_OK {
		return errors.New(C.GoString(C.sqlite3_errmsg(c.db)))
	}

	rv = C.sqlite3_enable_load_extension(c.db, 0)
	if rv != C.SQLITE_OK {
		return errors.New(C.GoString(C.sqlite3_errmsg(c.db)))
	}

	return nil
}
831487
func (r *Registry) SearchIndex() *SearchIndex {
	return r.Get(r.content().SearchIndex.Reference()).(*SearchIndex)
}
547977
func (ind *Indices) extractIndexes(indexIds []string) IndexMetadataSlice {
	result := make(IndexMetadataSlice, 0, len(ind.Indexes))
	if len(indexIds) == 0 {
		// No ids specified so return everything.
		for _, metadata := range ind.Indexes {
			result = append(result, metadata)
		}
	} else {
		// Return metadata for just the specified ids.
		for _, id := range indexIds {
			if metadata, ok := ind.Indexes[id]; ok {
				result = append(result, metadata)
			}
		}
	}
	return result
}