Skip to content

Commit 4201a8d

Browse files
authored
Merge branch 'master' into feature/config-bblfsh-size
2 parents 7cd125e + 2dbc45e commit 4201a8d

File tree

41 files changed

+928
-2299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+928
-2299
lines changed

Gopkg.lock

Lines changed: 8 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@
5454

5555
[[constraint]]
5656
name = "gopkg.in/bblfsh/client-go.v3"
57-
version = "3.0.0"
57+
version = "3.1.0"
5858

5959
[[override]]
6060
name = "gopkg.in/bblfsh/sdk.v1"
6161
version = "1.16.0"
6262

6363
[[constraint]]
6464
name = "gopkg.in/bblfsh/sdk.v2"
65-
version = "2.3.0"
65+
version = "2.7.0"
6666

6767
[[constraint]]
6868
name = "github.com/uber/jaeger-client-go"

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
**gitbase**, is a SQL database interface to Git repositories.
44

5+
This project is now part of [source{d} Engine](https://sourced.tech/engine),
6+
which provides the simplest way to get started with a single command.
7+
Visit [sourced.tech/engine](https://sourced.tech/engine) for more information.
8+
59
It can be used to perform SQL queries about the Git history and
610
about the [Universal AST](https://doc.bblf.sh/) of the code itself. gitbase is being built to work on top of any number of git repositories.
711

docs/using-gitbase/examples.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,41 @@ The UDF `uast_children` will return a flattened array of the children nodes from
202202
```sql
203203
SELECT file_path, uast_children(uast(blob_content, language(file_path), "//uast:Alias")) FROM files;
204204
```
205+
206+
## Monitor the progress of a query
207+
208+
You can monitor the progress of a gitbase query (either a regular query or an index creation query using `SHOW PROCESSLIST`).
209+
210+
Let's say we do the following query over a huge repository:
211+
212+
```sql
213+
SELECT language(file_path, blob_content) FROM files
214+
```
215+
216+
With this query we can monitor its progress:
217+
218+
```sql
219+
SHOW PROCESSLIST
220+
```
221+
222+
We'll get the following output:
223+
224+
```
225+
+------+------+----------------+---------+---------+------+------------+-----------------------------------------------------+
226+
| Id | User | Host | db | Command | Time | State | Info |
227+
+------+------+----------------+---------+---------+------+------------+-----------------------------------------------------+
228+
| 2 | root | 127.0.0.1:3306 | gitbase | query | 36 | files(1/3) | select language(file_path, blob_content) from files |
229+
| 12 | root | 127.0.0.1:3306 | gitbase | query | 0 | running | show processlist |
230+
+------+------+----------------+---------+---------+------+------------+-----------------------------------------------------+
231+
2 rows in set (0,00 sec)
232+
```
233+
234+
From this output, we can obtain some information about our query:
235+
- It's been running for 36 seconds.
236+
- It's only querying files table and has processed 1 out of 3 partitions.
237+
238+
To kill a query that's currently running you can use the value in `Id`. If we were to kill the previous query, we would need to use the following query:
239+
240+
```sql
241+
KILL QUERY 2
242+
```

internal/function/uast.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
lru "github.com/hashicorp/golang-lru"
1313
"github.com/sirupsen/logrus"
1414
bblfsh "gopkg.in/bblfsh/client-go.v3"
15+
derrors "gopkg.in/bblfsh/sdk.v2/driver/errors"
1516
"gopkg.in/bblfsh/sdk.v2/uast"
1617
"gopkg.in/bblfsh/sdk.v2/uast/nodes"
1718

@@ -224,12 +225,11 @@ func (u *uastFunc) getUAST(
224225
var err error
225226
node, err = getUASTFromBblfsh(ctx, blob, lang, xpath, mode)
226227
if err != nil {
227-
if ErrParseBlob.Is(err) {
228+
if ErrParseBlob.Is(err) || derrors.ErrSyntax.Is(err) {
228229
return nil, nil
229230
}
230231

231-
logrus.WithField("err", err).Error("unable to get UAST from bblfsh")
232-
return nil, nil
232+
return nil, err
233233
}
234234

235235
uastCache.Add(key, node)

session.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (s *Session) BblfshClient() (*BblfshClient, error) {
177177
var attempts, totalAttempts int
178178
for {
179179
if attempts > bblfshMaxAttempts || totalAttempts > 3*bblfshMaxAttempts {
180-
return nil, ErrBblfshConnection.New()
180+
return nil, ErrBblfshConnection.New("max attempts exceeded")
181181
}
182182

183183
switch s.bblfshClient.GetState() {
@@ -190,7 +190,7 @@ func (s *Session) BblfshClient() (*BblfshClient, error) {
190190
time.Sleep(100 * time.Millisecond)
191191
default:
192192
if err := s.bblfshClient.Close(); err != nil {
193-
return nil, err
193+
return nil, ErrBblfshConnection.New(err)
194194
}
195195

196196
logrus.Debug("bblfsh connection is closed, opening a new one")
@@ -223,10 +223,10 @@ func connectToBblfsh(endpoint string) (*bblfsh.Client, error) {
223223
client, err := bblfsh.NewClient(endpoint)
224224
if err != nil {
225225
if err == context.DeadlineExceeded {
226-
return nil, ErrBblfshConnection.New()
226+
return nil, ErrBblfshConnection.New(err)
227227
}
228228

229-
return nil, err
229+
return nil, ErrBblfshConnection.New(err)
230230
}
231231

232232
return client, nil
@@ -252,7 +252,7 @@ var ErrInvalidGitbaseSession = errors.NewKind("expecting gitbase session, but re
252252
var ErrInvalidContext = errors.NewKind("invalid context received: %v")
253253

254254
// ErrBblfshConnection is returned when it's impossible to connect to bblfsh.
255-
var ErrBblfshConnection = errors.NewKind("unable to establish a connection with the bblfsh server")
255+
var ErrBblfshConnection = errors.NewKind("unable to establish a connection with the bblfsh server: %s")
256256

257257
func shouldSkipErrors(ctx *sql.Context) bool {
258258
s, err := getSession(ctx)

vendor/github.com/golang/glog/LICENSE

Lines changed: 0 additions & 191 deletions
This file was deleted.

0 commit comments

Comments
 (0)