Skip to content

Commit

Permalink
feat(otelbench): use zstd compression
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Nov 29, 2024
1 parent e81bbab commit 87973fe
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/otelbench/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func newDumpCreateCommand() *cobra.Command {
})
g.Go(func() error {
// Wait for port-forward to be ready.
defer close(done)
for {
if err := checkConnection(ctx); err == nil {
break
Expand Down Expand Up @@ -241,6 +242,7 @@ func newDumpRestoreCommand() *cobra.Command {
}

tables := dumpTables()
var found bool
for _, table := range tables {
file := filepath.Join(arg.Input, fmt.Sprintf("%s.bin.%s", table, arg.Compression))
if _, err := os.Stat(file); err != nil {
Expand All @@ -256,6 +258,7 @@ func newDumpRestoreCommand() *cobra.Command {
}
}

found = true
if err := func() error {
q := fmt.Sprintf("INSERT INTO %s.%s FROM INFILE '%s' COMPRESSION '%s' FORMAT Native",
arg.Database, table, file, arg.Compression,
Expand All @@ -280,6 +283,9 @@ func newDumpRestoreCommand() *cobra.Command {
return errors.Wrapf(err, "restore %s", file)
}
}
if !found {
return errors.New("no tables found")
}
return nil
},
}
Expand All @@ -290,6 +296,7 @@ func newDumpRestoreCommand() *cobra.Command {
f.IntVar(&arg.Port, "port", 9000, "Clickhouse port")
f.StringVar(&arg.Host, "host", "localhost", "Clickhouse host")
f.BoolVar(&arg.Truncate, "truncate", false, "Truncate tables before restore")
f.StringVar(&arg.Compression, "compression", "zstd", "Compression algorithm")

return rootCmd
}

0 comments on commit 87973fe

Please sign in to comment.