Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[[constraint]]
name = "gopkg.in/src-d/go-mysql-server.v0"
revision = "3dd441325d1731821eff0495fbf63747c258b8ff"
revision = "bb5fe96ff756e5b25ec53c68c92d92c108832a65"

[[constraint]]
name = "github.com/jessevdk/go-flags"
Expand Down Expand Up @@ -84,7 +84,6 @@
[[prune.project]]
name = "gopkg.in/src-d/go-mysql-server.v0"
go-tests = true
non-go = true
unused-packages = true
[[prune.project]]
name = "gopkg.in/src-d/go-git.v4"
Expand Down
2 changes: 1 addition & 1 deletion cmd/gitbase/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (c *Server) buildDatabase() error {
c.engine.Catalog.SetCurrentDatabase(c.Name)
logrus.WithField("db", c.Name).Debug("registered database to catalog")

c.engine.Catalog.RegisterFunctions(function.Functions)
c.engine.Catalog.MustRegister(function.Functions...)
logrus.Debug("registered all available functions in catalog")

if err := c.registerDrivers(); err != nil {
Expand Down
14 changes: 14 additions & 0 deletions docs/using-gitbase/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@
| `GITBASE_MAX_UAST_BLOB_SIZE` | Max size of blobs to send to be parsed by bblfsh. Default: 5242880 (5MB) |
| `GITBASE_LOG_LEVEL` | minimum logging level to show, use `fatal` to suppress most messages. Default: `info` |

## Configuration from `go-mysql-server`

<!-- BEGIN CONFIG -->
| Name | Type | Description |
|:-----|:-----|:------------|
|`INMEMORY_JOINS`|environment|If set it will perform all joins in memory. Default is off.|
|`inmemory_joins`|session|If set it will perform all joins in memory. Default is off. This has precedence over `INMEMORY_JOINS`.|
|`MAX_MEMORY_INNER_JOIN`|environment|The maximum number of memory, in megabytes, that can be consumed by go-mysql-server before switching to multipass mode in inner joins. Default is the 20% of all available physical memory.|
|`max_memory_joins`|session|The maximum number of memory, in megabytes, that can be consumed by go-mysql-server before switching to multipass mode in inner joins. Default is the 20% of all available physical memory. This has precedence over `MAX_MEMORY_INNER_JOIN`.|
|`DEBUG_ANALYZER`|environment|If set, the analyzer will print debug messages. Default is off.|
|`PILOSA_INDEX_THREADS`|environment|Number of threads used in index creation. Default is the number of cores available in the machine.|
|`pilosa_index_threads`|environment|Number of threads used in index creation. Default is the number of cores available in the machine. This has precedence over `PILOSA_INDEX_THREADS`.|
<!-- END CONFIG -->

### Jaeger tracing variables

*Extracted from https://github.com/jaegertracing/jaeger-client-go/blob/master/README.md*
Expand Down
85 changes: 73 additions & 12 deletions docs/using-gitbase/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,80 @@ To make some common tasks easier for the user, there are some functions to inter

| Name | Description |
|:-------------|:-------------------------------------------------------------------------------------------------------------------------------|
|is_remote(reference_name)bool| check if the given reference name is from a remote one |
|is_tag(reference_name)bool| check if the given reference name is a tag |
|language(path, [blob])text| gets the language of a file given its path and the optional content of the file |
|uast(blob, [lang, [xpath]]) blob| returns a node array of UAST nodes in semantic mode |
|uast_mode(mode, blob, lang) blob| returns a node array of UAST nodes specifying its language and mode (semantic, annotated or native) |
|uast_xpath(blob, xpath) blob| performs an XPath query over the given UAST nodes |
|uast_extract(blob, key) text array| extracts information identified by the given key from the uast nodes |
|uast_children(blob) blob| returns a flattened array of the children UAST nodes from each one of the UAST nodes in the given array |
|`is_remote(reference_name)bool`| check if the given reference name is from a remote one |
|`is_tag(reference_name)bool`| check if the given reference name is a tag |
|`language(path, [blob])text`| gets the language of a file given its path and the optional content of the file |
|`uast(blob, [lang, [xpath]]) blob`| returns a node array of UAST nodes in semantic mode |
|`uast_mode(mode, blob, lang) blob`| returns a node array of UAST nodes specifying its language and mode (semantic, annotated or native) |
|`uast_xpath(blob, xpath) blob`| performs an XPath query over the given UAST nodes |
|`uast_extract(blob, key) text array`| extracts information identified by the given key from the uast nodes |
|`uast_children(blob) blob`| returns a flattened array of the children UAST nodes from each one of the UAST nodes in the given array |

## Standard functions

These are all functions that are available because they are implemented in `go-mysql-server`, used by gitbase.

<!-- BEGIN FUNCTIONS -->
| Name | Description |
|:-------------|:-------------------------------------------------------------------------------------------------------------------------------|
|`ARRAY_LENGTH(json)`|If the json representation is an array, this function returns its size.|
|`AVG(expr)`|Returns the average value of expr in all rows.|
|`CEIL(number)`|Return the smallest integer value that is greater than or equal to `number`.|
|`CEILING(number)`|Return the smallest integer value that is greater than or equal to `number`.|
|`COALESCE(...)`|The function returns the first non-null value in a list.|
|`CONCAT(...)`|Concatenate any group of fields into a single string.|
|`CONCAT_WS(sep, ...)`|Concatenate any group of fields into a single string. The first argument is the separator for the rest of the arguments. The separator is added between the strings to be concatenated. The separator can be a string, as can the rest of the arguments. If the separator is NULL, the result is NULL.|
|`CONNECTION_ID()`|Return the current connection ID.|
|`COUNT(expr)`| Returns a count of the number of non-NULL values of expr in the rows retrieved by a SELECT statement.|
|`DATE_ADD(date, interval)`|Adds the interval to the given date.|
|`DATE_SUB(date, interval)`|Subtracts the interval from the given date.|
|`DAY(date)`|Synonym for DAYOFMONTH().|
|`DATE(date)`|Returns the date part of the given date.|
|`DAYOFMONTH(date)`|Return the day of the month (0-31).|
|`DAYOFWEEK(date)`|Returns the day of the week of the given date.|
|`DAYOFYEAR(date)`|Returns the day of the year of the given date.|
|`FLOOR(number)`|Return the largest integer value that is less than or equal to `number`.|
|`HOUR(date)`|Returns the hours of the given date.|
|`IFNULL(expr1, expr2)`|If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2.|
|`IS_BINARY(blob)`|Returns whether a BLOB is a binary file or not.|
|`JSON_EXTRACT(json_doc, path, ...)`|Extracts data from a json document using json paths.|
|`LN(X)`|Return the natural logarithm of X.|
|`LOG(X), LOG(B, X)`|If called with one parameter, this function returns the natural logarithm of X. If called with two parameters, this function returns the logarithm of X to the base B. If X is less than or equal to 0, or if B is less than or equal to 1, then NULL is returned.|
|`LOG10(X)`|Returns the base-10 logarithm of X.|
|`LOG2(X)`|Returns the base-2 logarithm of X.|
|`LOWER(str)`|Returns the string str with all characters in lower case.|
|`LPAD(str, len, padstr)`|Return the string argument, left-padded with the specified string.|
|`LTRIM(str)`|Returns the string str with leading space characters removed.|
|`MAX(expr)`|Returns the maximum value of expr in all rows.|
|`MID(str, pos, [len])`|Return a substring from the provided string starting at `pos` with a length of `len` characters. If no `len` is provided, all characters from `pos` until the end will be taken.|
|`MIN(expr)`|Returns the minimum value of expr in all rows.|
|`MINUTE(date)`|Returns the minutes of the given date.|
|`MONTH(date)`|Returns the month of the given date.|
|`NOW()`|Returns the current timestamp.|
|`NULLIF(expr1, expr2)`|Returns NULL if expr1 = expr2 is true, otherwise returns expr1.|
|`POW(X, Y)`|Returns the value of X raised to the power of Y.|
|`REPEAT(str, count)`|Returns a string consisting of the string str repeated count times.|
|`REPLACE(str,from_str,to_str)`|Returns the string str with all occurrences of the string from_str replaced by the string to_str.|
|`REVERSE(str)`|Returns the string str with the order of the characters reversed.|
|`ROUND(number, decimals)`|Round the `number` to `decimals` decimal places.|
|`RPAD(str, len, padstr)`|Returns the string str, right-padded with the string padstr to a length of len characters.|
|`RTRIM(str)`|Returns the string str with trailing space characters removed.|
|`SECOND(date)`|Returns the seconds of the given date.|
|`SLEEP(seconds)`|Wait for the specified number of seconds (can be fractional).|
|`SOUNDEX(str)`|Returns the soundex of a string.|
|`SPLIT(str,sep)`|Receives a string and a separator and returns the parts of the string split by the separator as a JSON array of strings.|
|`SQRT(X)`|Returns the square root of a nonnegative number X.|
|`SUBSTR(str, pos, [len])`|Return a substring from the provided string starting at `pos` with a length of `len` characters. If no `len` is provided, all characters from `pos` until the end will be taken.|
|`SUBSTRING(str, pos, [len])`|Return a substring from the provided string starting at `pos` with a length of `len` characters. If no `len` is provided, all characters from `pos` until the end will be taken.|
|`SUM(expr)`|Returns the sum of expr in all rows.|
|`TO_BASE64(str)`|Encodes the string str in base64 format.|
|`FROM_BASE64(str)`|Decodes the base64-encoded string str.|
|`TRIM(str)`|Returns the string str with all spaces removed.|
|`UPPER(str)`|Returns the string str with all characters in upper case.|
|`WEEKDAY(date)`|Returns the weekday of the given date.|
|`YEAR(date)`|Returns the year of the given date.|
|`YEARWEEK(date, mode)`|Returns year and week for a date. The year in the result may be different from the year in the date argument for the first and the last week of the year.|
<!-- END FUNCTIONS -->

## Note about uast, uast_mode, uast_xpath and uast_children functions

Expand Down Expand Up @@ -92,7 +157,3 @@ Nodes that have no value for the requested property will not be present in any w
Also, if you want to retrieve values from a non common property, you can pass it directly

> uast_extract(nodes_column, 'some-property')

## Standard functions

You can check standard functions in [`go-mysql-server` documentation](https://github.com/src-d/go-mysql-server/tree/3dd441325d1731821eff0495fbf63747c258b8ff#custom-functions).
2 changes: 1 addition & 1 deletion docs/using-gitbase/indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ and for the second query also two indexes will be used and the result will be a

You can find some more examples in the [examples](./examples.md#create-an-index-for-columns-on-a-table) section.

See [go-mysql-server](https://github.com/src-d/go-mysql-server/tree/3dd441325d1731821eff0495fbf63747c258b8ff#indexes) documentation for more details
See [go-mysql-server](https://github.com/src-d/go-mysql-server/tree/bb5fe96ff756e5b25ec53c68c92d92c108832a65#indexes) documentation for more details
Loading