// DumpModel returns the serialized database agnostic model representation.
548303
func (c *Client) DumpModel(model names.ModelTag, simplified bool) (map[string]interface{}, error) {
	if bestVer := c.BestAPIVersion(); bestVer < 3 {
		logger.Debugf("calling older dump model on v%d", bestVer)
		if simplified {
			logger.Warningf("simplified dump-model not available, server too old")
		}
		return c.dumpModelV2(model)
	}

	var results params.StringResults
	entities := params.DumpModelRequest{
		Entities:   []params.Entity{{Tag: model.String()}},
		Simplified: simplified,
	}

	err := c.facade.FacadeCall("DumpModels", entities, &results)
	if err != nil {
		return nil, errors.Trace(err)
	}
	if count := len(results.Results); count != 1 {
		return nil, errors.Errorf("unexpected result count: %d", count)
	}
	result := results.Results[0]
	if result.Error != nil {
		return nil, result.Error
	}
	// Parse back into a map.
	var asMap map[string]interface{}
	err = yaml.Unmarshal([]byte(result.Result), &asMap)
	if err != nil {
		return nil, errors.Trace(err)
	}

	return asMap, nil
}
935623
func (b *PgsqlBuilder) Model(model interface{}) *ModelQuery {
	return NewModelQuery(model, b.db.FieldMapper, b.db, b)
}
333651
func (n *DebugMsg) DumpJSON(cpuPrefix string) {
	fmt.Println(n.getJSON(cpuPrefix))
}
455242
func (st *State) DumpAll() (map[string]interface{}, error) {
	result := make(map[string]interface{})
	// Add in the model document itself.
	doc, err := getModelDoc(st)
	if err != nil {
		return nil, err
	}
	result[modelsC] = doc
	for name, info := range allCollections() {
		if !info.global {
			docs, err := getAllModelDocs(st, name)
			if err != nil {
				return nil, errors.Trace(err)
			}
			if len(docs) > 0 {
				result[name] = docs
			}
		}
	}
	return result, nil
}
14395
func (c *Conn) Dump(w io.Writer) error {
	if _, err := w.Write([]byte("PRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\n")); err != nil {
		return err
	}

	// Get the schema.
	query := `SELECT "name", "type", "sql" FROM "sqlite_master"
              WHERE "sql" NOT NULL AND "type" == 'table' ORDER BY "name"`
	rows, err := c.Query([]string{query}, false, false)
	if err != nil {
		return err
	}
	row := rows[0]
	for _, v := range row.Values {
		table := v[0].(string)
		var stmt string

		if table == "sqlite_sequence" {
			stmt = `DELETE FROM "sqlite_sequence";`
		} else if table == "sqlite_stat1" {
			stmt = `ANALYZE "sqlite_master";`
		} else if strings.HasPrefix(table, "sqlite_") {
			continue
		} else {
			stmt = v[2].(string)
		}

		if _, err := w.Write([]byte(fmt.Sprintf("%s;\n", stmt))); err != nil {
			return err
		}

		tableIndent := strings.Replace(table, `"`, `""`, -1)
		query = fmt.Sprintf(`PRAGMA table_info("%s")`, tableIndent)
		r, err := c.Query([]string{query}, false, false)
		if err != nil {
			return err
		}
		var columnNames []string
		for _, w := range r[0].Values {
			columnNames = append(columnNames, fmt.Sprintf(`'||quote("%s")||'`, w[1].(string)))
		}

		query = fmt.Sprintf(`SELECT 'INSERT INTO "%s" VALUES(%s)' FROM "%s";`,
			tableIndent,
			strings.Join(columnNames, ","),
			tableIndent)
		r, err = c.Query([]string{query}, false, false)
		if err != nil {
			return err
		}
		for _, x := range r[0].Values {
			y := fmt.Sprintf("%s;\n", x[0].(string))
			if _, err := w.Write([]byte(y)); err != nil {
				return err
			}
		}
	}

	// Do indexes, triggers, and views.
	query = `SELECT "name", "type", "sql" FROM "sqlite_master"
			  WHERE "sql" NOT NULL AND "type" IN ('index', 'trigger', 'view')`
	rows, err = c.Query([]string{query}, false, false)
	if err != nil {
		return err
	}
	row = rows[0]
	for _, v := range row.Values {
		if _, err := w.Write([]byte(fmt.Sprintf("%s;\n", v[2]))); err != nil {
			return err
		}
	}

	if _, err := w.Write([]byte("COMMIT;\n")); err != nil {
		return err
	}

	return nil
}
215123
func registerModel(prefix string, model interface{}) {
	val := reflect.ValueOf(model)
	ind := reflect.Indirect(val)
	typ := ind.Type()

	if val.Kind() != reflect.Ptr {
		panic(fmt.Errorf("<orm.RegisterModel> cannot use non-ptr model struct `%s`", getFullName(typ)))
	}

	table := getTableName(val)

	if prefix != "" {
		table = prefix + table
	}

	name := getFullName(typ)
	if _, ok := modelCache.getByFN(name); ok {
		fmt.Printf("<orm.RegisterModel> model `%s` repeat register, must be unique\n", name)
		os.Exit(2)
	}

	if _, ok := modelCache.get(table); ok {
		fmt.Printf("<orm.RegisterModel> table name `%s` repeat register, must be unique\n", table)
		os.Exit(2)
	}

	info := newModelInfo(val)
	if info.fields.pk == nil {
	outFor:
		for _, fi := range info.fields.fieldsDB {
			if strings.ToLower(fi.name) == "id" {
				switch fi.addrValue.Elem().Kind() {
				case reflect.Int, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint32, reflect.Uint64:
					fi.auto = true
					fi.pk = true
					info.fields.pk = fi
					break outFor
				}
			}
		}

		if info.fields.pk == nil {
			fmt.Printf("<orm.RegisterModel> `%s` need a primary key field\n", name)
			os.Exit(2)
		}

	}

	info.table = table
	info.pkg = typ.PkgPath()
	info.model = model
	info.manual = true

	modelCache.set(table, info)
}
918568
func (kvmsg *Kvmsg) Dump() {
	size := kvmsg.Size()
	body, _ := kvmsg.GetBody()
	seq, _ := kvmsg.GetSequence()
	key, _ := kvmsg.GetKey()
	fmt.Fprintf(os.Stderr, "[seq:%v][key:%v][size:%v]", seq, key, size)
	for char_nbr := 0; char_nbr < size; char_nbr++ {
		fmt.Fprintf(os.Stderr, "%02X", body[char_nbr])
	}
	fmt.Fprintln(os.Stderr)
}
565996
func (m *ModelManagerAPI) DumpModelsDB(args params.Entities) params.MapResults {
	results := params.MapResults{
		Results: make([]params.MapResult, len(args.Entities)),
	}
	for i, entity := range args.Entities {
		dumped, err := m.dumpModelDB(entity)
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		results.Results[i].Result = dumped
	}
	return results
}
631678
func dumpConfig(Opts map[string]string) {
	opts := []string{}
	for k := range Opts {
		opts = append(opts, k)
	}
	sort.Strings(opts)

	for _, k := range opts {
		// XXX: Reuse the format function from *option.Library
		value = Opts[k]
		if enabled, err := option.NormalizeBool(value); err != nil {
			// If it cannot be parsed as a bool, just format the value.
			fmt.Printf("%-24s %s\n", k, color.Green(value))
		} else if enabled == option.OptionDisabled {
			fmt.Printf("%-24s %s\n", k, color.Red("Disabled"))
		} else {
			fmt.Printf("%-24s %s\n", k, color.Green("Enabled"))
		}
	}
}
622071
func DumpImage(prefix string, img image.Image) error {
	_, src, err := inspect(img, false)
	if err != nil {
		return err
	}
	for i, p := range src {
		err = dumpPlane(prefix, &p, i)
		if err != nil {
			return err
		}
	}
	return nil
}
299526
func (p *StatePool) GetModel(modelUUID string) (*Model, PoolHelper, error) {
	ps, err := p.Get(modelUUID)
	if err != nil {
		return nil, nil, errors.Trace(err)
	}

	model, err := ps.Model()
	if err != nil {
		ps.Release()
		return nil, nil, errors.Trace(err)
	}

	return model, ps, nil
}
287660
func (h *Handle) DumpStatsToJSON(dbName string, tableInfo *model.TableInfo) (*JSONTable, error) {
	pi := tableInfo.GetPartitionInfo()
	if pi == nil {
		return h.tableStatsToJSON(dbName, tableInfo, tableInfo.ID)
	}
	jsonTbl := &JSONTable{
		DatabaseName: dbName,
		TableName:    tableInfo.Name.L,
		Partitions:   make(map[string]*JSONTable, len(pi.Definitions)),
	}
	for _, def := range pi.Definitions {
		tbl, err := h.tableStatsToJSON(dbName, tableInfo, def.ID)
		if err != nil {
			return nil, errors.Trace(err)
		}
		if tbl == nil {
			continue
		}
		jsonTbl.Partitions[def.Name.L] = tbl
	}
	return jsonTbl, nil
}
30233
func Dump(c context.Context, w io.Writer) (n int, err error) {
	return logging.Get(c).(*MemLogger).Dump(w)
}
922022
func (e *Enforcer) LoadModel() {
	e.model = NewModel()
	e.model.LoadModel(e.modelPath)
	e.model.PrintModel()
	e.fm = model.LoadFunctionMap()
}
707194
func (b *OciBuilder) Model(model interface{}) *ModelQuery {
	return NewModelQuery(model, b.db.FieldMapper, b.db, b)
}
474405
func (surface *Surface) ColorModel() color.Model {
	switch surface.Format.Format {
	case PIXELFORMAT_ARGB8888, PIXELFORMAT_ABGR8888:
		return color.RGBAModel
	case PIXELFORMAT_RGB888:
		return color.RGBAModel
	default:
		panic("Not implemented yet")
	}
}
608374
func (n *DebugMsg) Dump(prefix string) {
	fmt.Printf("%s MARK %#x FROM %d DEBUG: %s\n", prefix, n.Hash, n.Source, n.subTypeString())
}