Skip to content

Commit 54e69c2

Browse files
authored
Merge pull request #345 from erizocosmico/feature/squash-default
cmd/gitbase: make squash rule active by default
2 parents d3db798 + 3000d47 commit 54e69c2

File tree

3 files changed

+27
-30
lines changed

3 files changed

+27
-30
lines changed

cmd/gitbase/command/server.go

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,23 @@ import (
2222
const (
2323
ServerDescription = "Starts a gitbase server instance"
2424
ServerHelp = ServerDescription + "\n\n" +
25-
"The squashing tables and pushing down join conditions is still a\n" +
26-
"work in progress and unstable, disabled by default. It can be enabled\n" +
27-
"using a not empty value at GITBASE_UNSTABLE_SQUASH_ENABLE env variable.\n\n" +
28-
"By default when gitbase encounters an error in a repository it\n" +
25+
"By default when gitbase encounters and error in a repository it\n" +
2926
"stops the query. With GITBASE_SKIP_GIT_ERRORS variable it won't\n" +
3027
"complain and just skip those rows or repositories."
3128
)
3229

3330
// Server represents the `server` command of gitbase cli tool.
3431
type Server struct {
35-
Verbose bool `short:"v" description:"Activates the verbose mode"`
36-
Git []string `short:"g" long:"git" description:"Path where the git repositories are located, multiple directories can be defined. Accepts globs."`
37-
Siva []string `long:"siva" description:"Path where the siva repositories are located, multiple directories can be defined. Accepts globs."`
38-
Host string `short:"h" long:"host" default:"localhost" description:"Host where the server is going to listen"`
39-
Port int `short:"p" long:"port" default:"3306" description:"Port where the server is going to listen"`
40-
User string `short:"u" long:"user" default:"root" description:"User name used for connection"`
41-
Password string `short:"P" long:"password" default:"" description:"Password used for connection"`
42-
PilosaURL string `long:"pilosa" default:"http://localhost:10101" description:"URL to your pilosa server" env:"PILOSA_ENDPOINT"`
43-
IndexDir string `short:"i" long:"index" default:"/var/lib/gitbase/index" description:"Directory where the gitbase indexes information will be persisted." env:"GITBASE_INDEX_DIR"`
44-
45-
// UnstableSquash quashing tables and pushing down join conditions is still
46-
// a work in progress and unstable. To enable it, the GITBASE_UNSTABLE_SQUASH_ENABLE
47-
// must not be empty.
48-
UnstableSquash bool
32+
Verbose bool `short:"v" description:"Activates the verbose mode"`
33+
Git []string `short:"g" long:"git" description:"Path where the git repositories are located, multiple directories can be defined. Accepts globs."`
34+
Siva []string `long:"siva" description:"Path where the siva repositories are located, multiple directories can be defined. Accepts globs."`
35+
Host string `short:"h" long:"host" default:"localhost" description:"Host where the server is going to listen"`
36+
Port int `short:"p" long:"port" default:"3306" description:"Port where the server is going to listen"`
37+
User string `short:"u" long:"user" default:"root" description:"User name used for connection"`
38+
Password string `short:"P" long:"password" default:"" description:"Password used for connection"`
39+
PilosaURL string `long:"pilosa" default:"http://localhost:10101" description:"URL to your pilosa server" env:"PILOSA_ENDPOINT"`
40+
IndexDir string `short:"i" long:"index" default:"/var/lib/gitbase/index" description:"Directory where the gitbase indexes information will be persisted." env:"GITBASE_INDEX_DIR"`
41+
DisableSquash bool `long:"no-squash" description:"Disables the table squashing."`
4942
// IgnoreGitErrors by default when gitbase encounters and error in a
5043
// repository it stops the query. With this parameter it won't complain and
5144
// just skip those rows or repositories.
@@ -114,14 +107,16 @@ func (c *Server) buildDatabase() error {
114107
return err
115108
}
116109

117-
if c.UnstableSquash {
118-
logrus.Warn("unstable squash tables rule is enabled")
110+
if !c.DisableSquash {
111+
logrus.Info("squash tables rule is enabled")
119112
a := analyzer.NewBuilder(c.engine.Catalog).
120113
AddPostAnalyzeRule(rule.SquashJoinsRule, rule.SquashJoins).
121114
Build()
122115

123116
a.CurrentDatabase = c.engine.Analyzer.CurrentDatabase
124117
c.engine.Analyzer = a
118+
} else {
119+
logrus.Warn("squash tables rule is disabled")
125120
}
126121

127122
return c.engine.Init()

cmd/gitbase/main.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/src-d/gitbase/cmd/gitbase/command"
77

88
"github.com/jessevdk/go-flags"
9+
"github.com/sirupsen/logrus"
910
)
1011

1112
const (
@@ -15,18 +16,23 @@ const (
1516
func main() {
1617
parser := flags.NewNamedParser(name, flags.Default)
1718

18-
parser.AddCommand("server", command.ServerDescription, command.ServerHelp,
19+
_, err := parser.AddCommand("server", command.ServerDescription, command.ServerHelp,
1920
&command.Server{
20-
UnstableSquash: os.Getenv("GITBASE_UNSTABLE_SQUASH_ENABLE") != "",
21-
SkipGitErrors: os.Getenv("GITBASE_SKIP_GIT_ERRORS") != "",
21+
SkipGitErrors: os.Getenv("GITBASE_SKIP_GIT_ERRORS") != "",
2222
})
23+
if err != nil {
24+
logrus.Fatal(err)
25+
}
2326

24-
parser.AddCommand("version", command.VersionDescription, command.VersionHelp,
27+
_, err = parser.AddCommand("version", command.VersionDescription, command.VersionHelp,
2528
&command.Version{
2629
Name: name,
2730
})
31+
if err != nil {
32+
logrus.Fatal(err)
33+
}
2834

29-
_, err := parser.Parse()
35+
_, err = parser.Parse()
3036
if err != nil {
3137
if e, ok := err.(*flags.Error); ok && e.Type == flags.ErrCommandRequired {
3238
parser.WriteHelp(os.Stdout)

docs/using-gitbase/configuration.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
| `PILOSA_ENDPOINT` | pilosa endpoint, default "http://localhost:10101" |
99
| `GITBASE_BLOBS_MAX_SIZE` | maximum blob size to return in MiB, default 5 MiB |
1010
| `GITBASE_BLOBS_ALLOW_BINARY` | enable retrieval of binary blobs, default `false` |
11-
| `GITBASE_UNSTABLE_SQUASH_ENABLE` | enable join squash rule to improve query performance **experimental**. This optimization collects inner joins between tables with a set of supported conditions and converts them into a single node that retrieves the data in chained steps (getting first the commits and then the blobs of every commit instead of joining all commits and all blobs, for example).|
1211
| `GITBASE_SKIP_GIT_ERRORS` | do not stop queries on git errors, default disabled |
1312

1413
## Command line arguments
@@ -34,10 +33,6 @@ Usage:
3433

3534
Starts a gitbase server instance
3635

37-
The squashing tables and pushing down join conditions is still a
38-
work in progress and unstable, disable by default. It can be enabled
39-
using a not empty value at GITBASE_UNSTABLE_SQUASH_ENABLE env variable.
40-
4136
By default when gitbase encounters an error in a repository it
4237
stops the query. With GITBASE_SKIP_GIT_ERRORS variable it won't
4338
complain and just skip those rows or repositories.
@@ -55,4 +50,5 @@ Help Options:
5550
-P, --password= Password used for connection
5651
--pilosa= URL to your pilosa server (default: http://localhost:10101)
5752
-i, --index= Directory where the gitbase indexes information will be persisted. (default: /var/lib/gitbase/index)
53+
--no-squash Disables the table squashing.
5854
```

0 commit comments

Comments
 (0)