Skip to content

Commit

Permalink
latest from "v2" branch
Browse files Browse the repository at this point in the history
- commit ref: 34d92ce
  • Loading branch information
kocubinski committed Feb 28, 2024
1 parent 5b4efe3 commit 936064d
Show file tree
Hide file tree
Showing 20 changed files with 1,696 additions and 913 deletions.
63 changes: 0 additions & 63 deletions v2/cache.go

This file was deleted.

6 changes: 2 additions & 4 deletions v2/cmd/latest.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"github.com/cosmos/iavl/v2"
"github.com/cosmos/iavl/v2/metrics"
"github.com/spf13/cobra"
)

Expand All @@ -27,13 +26,12 @@ func latestCommand() *cobra.Command {
)
for _, path := range paths {
cnt++
m := &metrics.TreeMetrics{}
sqlOpts := iavl.SqliteDbOptions{Path: path, Metrics: m}
sqlOpts := iavl.SqliteDbOptions{Path: path}
sql, err := iavl.NewSqliteDb(pool, sqlOpts)
if err != nil {
return err
}
tree := iavl.NewTree(sql, pool, iavl.TreeOptions{Metrics: m})
tree := iavl.NewTree(sql, pool, iavl.TreeOptions{})
if err = tree.LoadVersion(version); err != nil {
return err
}
Expand Down
8 changes: 7 additions & 1 deletion v2/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ func RootCommand() (*cobra.Command, error) {
Use: "iavl",
Short: "benchmark cosmos/iavl",
}
cmd.AddCommand(gen.Command(), snapshot.Command(), rollback.Command(), scan.Command(), latestCommand())
cmd.AddCommand(
gen.Command(),
snapshot.Command(),
rollback.Command(),
scan.Command(),
latestCommand(),
)
return cmd, nil
}
31 changes: 30 additions & 1 deletion v2/cmd/scan/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (
"os"

"github.com/bvinc/go-sqlite-lite/sqlite3"
"github.com/cosmos/iavl/v2"
"github.com/spf13/cobra"
)

func Command() *cobra.Command {
cmd := &cobra.Command{
Use: "scan",
}
cmd.AddCommand(probeCommand())
cmd.AddCommand(probeCommand(), rootsCommand())
return cmd
}

Expand Down Expand Up @@ -72,3 +73,31 @@ func probeCommand() *cobra.Command {
}
return cmd
}

func rootsCommand() *cobra.Command {
var (
dbPath string
version int64
)
cmd := &cobra.Command{
Use: "roots",
Short: "list roots",
RunE: func(cmd *cobra.Command, args []string) error {
sql, err := iavl.NewSqliteDb(iavl.NewNodePool(), iavl.SqliteDbOptions{Path: dbPath})
if err != nil {
return err
}
node, err := sql.LoadRoot(version)
if err != nil {
return err
}
fmt.Printf("root: %+v\n", node)
return sql.Close()
},
}
cmd.Flags().StringVar(&dbPath, "db", "", "path to sqlite db")
cmd.Flags().Int64Var(&version, "version", 0, "version to query")
cmd.MarkFlagRequired("db")
cmd.MarkFlagRequired("version")
return cmd
}
6 changes: 2 additions & 4 deletions v2/cmd/snapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"time"

"github.com/cosmos/iavl/v2"
"github.com/cosmos/iavl/v2/metrics"
"github.com/rs/zerolog"
zlog "github.com/rs/zerolog/log"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -39,13 +38,12 @@ func Command() *cobra.Command {
)
for _, path := range paths {
cnt++
m := &metrics.TreeMetrics{}
sqlOpts := iavl.SqliteDbOptions{Path: path, Metrics: m}
sqlOpts := iavl.SqliteDbOptions{Path: path}
sql, err := iavl.NewSqliteDb(pool, sqlOpts)
if err != nil {
return err
}
tree := iavl.NewTree(sql, pool, iavl.TreeOptions{Metrics: m})
tree := iavl.NewTree(sql, pool, iavl.TreeOptions{})
if err = tree.LoadVersion(version); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ go 1.18
require (
github.com/aybabtme/uniplot v0.0.0-20151203143629-039c559e5e7e
github.com/bvinc/go-sqlite-lite v0.6.1
github.com/cosmos/iavl-bench/bench v0.0.3
github.com/cosmos/iavl-bench/bench v0.0.4
github.com/dustin/go-humanize v1.0.1
github.com/emicklei/dot v1.6.0
github.com/kocubinski/costor-api v1.1.1
github.com/prometheus/client_golang v1.16.0
github.com/rs/zerolog v1.30.0
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.4
Expand All @@ -25,7 +26,6 @@ require (
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ github.com/bvinc/go-sqlite-lite v0.6.1/go.mod h1:2GiE60NUdb0aNhDdY+LXgrqAVDpi2Ij
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cosmos/iavl-bench/bench v0.0.3 h1:PL9PP4+1y+iMblB0EYv+G91posLO4VGJiQ1Wg47ABXM=
github.com/cosmos/iavl-bench/bench v0.0.3/go.mod h1:j2rLae77EffacWcp7mmj3Uaa4AOAmZA7ymvhsuBQKKI=
github.com/cosmos/iavl-bench/bench v0.0.4 h1:J6zQPiBqF4CXMM3QBsLqZgQEBGY0taX85vLIZMhmAfQ=
github.com/cosmos/iavl-bench/bench v0.0.4/go.mod h1:j2rLae77EffacWcp7mmj3Uaa4AOAmZA7ymvhsuBQKKI=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
Loading

0 comments on commit 936064d

Please sign in to comment.