@@ -2,16 +2,20 @@ package command
22
33import (
44 "net"
5+ "os"
56 "path/filepath"
67 "strconv"
78
9+ "github.com/prometheus/common/log"
810 "github.com/src-d/gitbase"
911 "github.com/src-d/gitbase/internal/function"
1012 "github.com/src-d/gitbase/internal/rule"
1113
14+ gopilosa "github.com/pilosa/go-pilosa"
1215 "github.com/sirupsen/logrus"
1316 sqle "gopkg.in/src-d/go-mysql-server.v0"
1417 "gopkg.in/src-d/go-mysql-server.v0/server"
18+ "gopkg.in/src-d/go-mysql-server.v0/sql/index/pilosa"
1519 "gopkg.in/src-d/go-vitess.v0/mysql"
1620)
1721
@@ -28,13 +32,15 @@ const (
2832
2933// Server represents the `server` command of gitbase cli tool.
3034type Server struct {
31- Verbose bool `short:"v" description:"Activates the verbose mode"`
32- Git []string `short:"g" long:"git" description:"Path where the git repositories are located, multiple directories can be defined. Accepts globs."`
33- Siva []string `long:"siva" description:"Path where the siva repositories are located, multiple directories can be defined. Accepts globs."`
34- Host string `short:"h" long:"host" default:"localhost" description:"Host where the server is going to listen"`
35- Port int `short:"p" long:"port" default:"3306" description:"Port where the server is going to listen"`
36- User string `short:"u" long:"user" default:"root" description:"User name used for connection"`
37- Password string `short:"P" long:"password" default:"" description:"Password used for connection"`
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"`
43+ IndexDir string `short:"i" long:"index" default:"/var/gitbase/index" description:"Directory where the gitbase indexes information will be persisted."`
3844
3945 // UnstableSquash quashing tables and pushing down join conditions is still
4046 // a work in progress and unstable. To enable it, the GITBASE_UNSTABLE_SQUASH_ENABLE
@@ -104,6 +110,18 @@ func (c *Server) buildDatabase() error {
104110 c .engine .Catalog .RegisterFunctions (function .Functions )
105111 logrus .Debug ("registered all available functions in catalog" )
106112
113+ if err := os .MkdirAll (c .IndexDir , 0755 ); err != nil {
114+ return err
115+ }
116+
117+ client , err := gopilosa .NewClient (c .PilosaURL )
118+ if err != nil {
119+ return err
120+ }
121+
122+ c .engine .Catalog .RegisterIndexDriver (pilosa .NewDriver (c .IndexDir , client ))
123+ log .Debug ("registered pilosa index driver" )
124+
107125 if c .UnstableSquash {
108126 logrus .Warn ("unstable squash tables rule is enabled" )
109127 c .engine .Analyzer .AddRule (rule .SquashJoinsRule , rule .SquashJoins )
0 commit comments