func countEntriesWithPrefix(ctx context.Context, prefix []byte) (int, error) { txn, err := ctx.GetTxn(false) if err != nil { return 0, err } cnt := 0 err = util.ScanMetaWithPrefix(txn, prefix, func(k kv.Key, v []byte) bool { cnt++ return true }) return cnt, err }
func (do *Domain) loadInfoSchema(txn kv.Transaction) (err error) { var schemas []*model.DBInfo err = util.ScanMetaWithPrefix(txn, meta.SchemaMetaPrefix, func(key []byte, value []byte) bool { di := &model.DBInfo{} err := json.Unmarshal(value, di) if err != nil { log.Fatal(err) } schemas = append(schemas, di) return true }) if err != nil { return errors.Trace(err) } schemaMetaVersion, err := txn.GetInt64(meta.SchemaMetaVersionKey) if err != nil { return } log.Info("loadInfoSchema %d", schemaMetaVersion) do.infoHandle.Set(schemas, schemaMetaVersion) return }