Versions in this module Expand all Collapse all v1 v1.1.3 Jul 18, 2025 Changes in this version + const GenDataFileFirstLinePrefix type TableGen + Rows int + StreamloadColMapping string v1.1.2 Jul 3, 2025 Changes in this version + const AnonymizeHashBytes + const AnonymizeHashFmt + const ColumnSeparator + const DefaultGenRowCount + const LLMOutputPrefix + const MaxGenRowCount + const ReplayCustomClientPrefix + const ReplayResultFileExt + const ReplaySqlPrefix + const ReplaySqlSuffix + const StreamLoadMaxRetries + var InternalSqlComment = "/*dodo*/" + var NumberRe = regexp.MustCompile(`\d+`) + func Anonymize(method string, s string) string + func AnonymizeSql(method string, sqlId, sql string) string + func CheckGenRowCount(rows int) error + func Choose(msg string, items []string) (string, error) + func Confirm(msg string) bool + func CountAuditlogs(ctx context.Context, db *sqlx.DB, dbname, table string, opts AuditLogScanOpts) (int, error) + func DecodeReplaySqls(s *bufio.Scanner, dbs, users map[string]struct{}, from, to int64, ...) (map[string][]*ReplaySql, int64, int, error) + func DetectCharset(r *bufio.Reader) (string, error) + func EncodeReplaySql(ts, client, user, db, queryId, stmt string, durationMs int64) string + func ExpandHome(path string) string + func ExtractQueriesFromAuditLogs(writers []SqlWriter, auditlogPaths []string, encoding string, ...) (int, error) + func FileGlob(paths []string) ([]string, error) + func GetDBAuditLogs(ctx context.Context, w SqlWriter, db *sqlx.DB, dbname, table string, ...) (int, error) + func GetEncoding(name string) (encoding.Encoding, error) + func IsStringType(colType string) bool + func LLMGendataConfig(ctx context.Context, apiKey, baseURL, model, prompt_ string, ...) (string, error) + func MustJsonMarshal(v any) []byte + func MustYamlMarshal(v any) []byte + func NewDB(host string, port uint16, user, password, db string) (*sqlx.DB, error) + func ParallelGroup(parallel int) *errgroup.Group + func ReadFileOrStdin(path string) (string, error) + func ReplaySqls(ctx context.Context, host string, port uint16, user, password, cluster string, ...) error + func RunCreateSQL(ctx context.Context, conn *sqlx.DB, db string, sqlFile string, beCount int, ...) (needDependence string, err error) + func SanitizeLike(s string) string + func ScpFromRemote(ctx context.Context, privKey, remoteUrl, localPath string) error + func SetupAnonymizer(method, hashdictPath string, idMinLength int, reserveIds ...string) + func ShowBackendCount(ctx context.Context, conn *sqlx.DB) (count int, err error) + func ShowDatabases(ctx context.Context, conn *sqlx.DB, dbnamePrefix string) ([]string, error) + func ShowFronendsDisksDir(ctx context.Context, conn *sqlx.DB, diskType string) (dir string, err error) + func SshLs(_ context.Context, privKey, remoteUrl string) ([]string, error) + func StoreMiniHashDict(method, hashdictPath string) + func StreamLoad(ctx context.Context, ...) error + func WriteFile(path string, content string) error + type AuditLogScanOpts struct + DBs []string + From string + OnlySelect bool + QueryMinDurationMs int64 + QueryStates []string + Strict bool + To string + type AuditLogScanner interface + Close func() + Consume func(w SqlWriter) (int, error) + Init func() + ScanOne func(oneLine []byte) error + func NewAuditLogScanner(opts AuditLogScanOpts) AuditLogScanner + type BytesEncoder interface + Encode func(b []byte) ([]byte, error) + func NewBytesEncoder(srcEncoding encoding.Encoding) BytesEncoder + type ClientSqls struct + Client string + Sqls []*ReplaySql + type ColumnStats struct + AvgSizeByte int64 + Count int64 + DataSize int64 + Max string + Method string + Min string + Name string + Ndv int64 + NullCount int64 + type CreateParserListener struct + func (l *CreateParserListener) ExitPropertyItem(ctx *parser.PropertyItemContext) + type DBSchema struct + Name string + Schemas []*Schema + Stats []*TableStats + type DummyEncoder struct + func (*DummyEncoder) Encode(b []byte) ([]byte, error) + type GenRule = gen.GenRule + type ReplayClient struct + func (c *ReplayClient) Close(closefile bool) + type ReplayResult struct + DurationMs int64 + Err string + QueryId string + ReturnRows int + ReturnRowsHash string + Stmt string + Ts string + func (re *ReplayResult) String() string + type ReplaySql struct + Stmt string + func (s *ReplaySql) ToReplayResult() *ReplayResult + type ReplaySqlMeta struct + Client string + Db string + DurationMs int64 + QueryId string + Ts int64 + Ts_ string + User string + func (m *ReplaySqlMeta) Timestamp() (ms int64, err error) + type Schema struct + CreateStmt string + DB string + Name string + Type SchemaType + func ShowCreateTables(ctx context.Context, conn *sqlx.DB, db string, dbTables ...string) (schemas []*Schema, err error) + func ShowTables(ctx context.Context, conn *sqlx.DB, dbname string, tablenamePrefix ...string) (tables []*Schema, err error) + func (s *Schema) String() string + type SchemaType string + var SchemaTypeMaterializedView SchemaType = "MATERIALIZED_VIEW" + var SchemaTypeTable SchemaType = "TABLE" + var SchemaTypeView SchemaType = "VIEW" + func (s SchemaType) Lower() string + type SimpleAuditLogScanner struct + func NewSimpleAuditLogScanner(opts AuditLogScanOpts) *SimpleAuditLogScanner + func (*SimpleAuditLogScanner) Close() + func (s *SimpleAuditLogScanner) Consume(w SqlWriter) (int, error) + func (s *SimpleAuditLogScanner) Init() + func (s *SimpleAuditLogScanner) ScanOne(oneLog []byte) error + type SqlWriter interface + WriteSql func(s string) error + type TableGen struct + Columns []string + DDLFile string + Name string + RefToTable map[string]struct{} + func NewTableGen(ddlfile, createTableStmt string, stats *TableStats) (*TableGen, error) + func (tg *TableGen) GenCSV(w *bufio.Writer, rows int) error + func (tg *TableGen) RecordRefTables(ts ...string) + func (tg *TableGen) RemoveRefTable(t string) + type TableStats struct + Columns []*ColumnStats + Name string + RowCount int64 + func GetTablesStats(ctx context.Context, conn *sqlx.DB, analyze bool, dbname string, ...) ([]*TableStats, error) + type Utf8Encoder struct + func (e *Utf8Encoder) Encode(b []byte) ([]byte, error)