@@ -2,16 +2,20 @@ package command
2
2
3
3
import (
4
4
"net"
5
+ "os"
5
6
"path/filepath"
6
7
"strconv"
7
8
9
+ "github.com/prometheus/common/log"
8
10
"github.com/src-d/gitbase"
9
11
"github.com/src-d/gitbase/internal/function"
10
12
"github.com/src-d/gitbase/internal/rule"
11
13
14
+ gopilosa "github.com/pilosa/go-pilosa"
12
15
"github.com/sirupsen/logrus"
13
16
sqle "gopkg.in/src-d/go-mysql-server.v0"
14
17
"gopkg.in/src-d/go-mysql-server.v0/server"
18
+ "gopkg.in/src-d/go-mysql-server.v0/sql/index/pilosa"
15
19
"gopkg.in/src-d/go-vitess.v0/mysql"
16
20
)
17
21
@@ -28,13 +32,15 @@ const (
28
32
29
33
// Server represents the `server` command of gitbase cli tool.
30
34
type 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."`
38
44
39
45
// UnstableSquash quashing tables and pushing down join conditions is still
40
46
// a work in progress and unstable. To enable it, the GITBASE_UNSTABLE_SQUASH_ENABLE
@@ -104,6 +110,18 @@ func (c *Server) buildDatabase() error {
104
110
c .engine .Catalog .RegisterFunctions (function .Functions )
105
111
logrus .Debug ("registered all available functions in catalog" )
106
112
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
+
107
125
if c .UnstableSquash {
108
126
logrus .Warn ("unstable squash tables rule is enabled" )
109
127
c .engine .Analyzer .AddRule (rule .SquashJoinsRule , rule .SquashJoins )
0 commit comments