Skip to content

Commit 568a476

Browse files
authored
Merge pull request #516 from mcarmonaa/improvement/doc-uast-serialization
docs: explain how uast and uast_mode functions serilize data
2 parents 20dc87f + dab6abb commit 568a476

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/using-gitbase/functions.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ To make some common tasks easier for the user, there are some functions to inter
1515
|uast_extract(blob, key)| extracts information identified by the given key from the uast nodes |
1616
|uast_children(blob)| returns a flattened array of the children UAST nodes from each one of the UAST nodes in the given sequence |
1717

18+
19+
## Note about uast and uast_mode functions
20+
21+
The data returned by these functions are a list of UAST nodes serialized as explained below.
22+
23+
Each node is serialized sequentially using [protobuf](https://developers.google.com/protocol-buffers/) and prefixed by an Int32 (in big endian byte order) specifying the length of the serialized node. The [bblfsh/sdk](https://github.com/bblfsh/sdk) contains the proto files and the tools to do it.
24+
25+
It results in a byte stream following this structure:
26+
```
27+
BigEndianInt32(len(marhsal(node))+marshal(node)+
28+
BigEndianInt32(len(marhsal(node))+marshal(node)+
29+
BigEndianInt32(len(marhsal(node))+marshal(node)+
30+
...
31+
```
32+
1833
## Standard functions
1934

2035
You can check standard functions in [`go-mysql-server` documentation](https://github.com/src-d/go-mysql-server/tree/1fa8e98aab8f06ae1569c4d381ccc9d3051f761a#custom-functions).

0 commit comments

Comments
 (0)