Skip to content

Commit c128497

Browse files
committed
Add NAK to typed array
1 parent cc1e33a commit c128497

File tree

3 files changed

+20
-40
lines changed

3 files changed

+20
-40
lines changed

docs/protocol/data-types.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ sayan\n # the element 'sayan' itself
2929

3030
| Type symbol (tsymbol) | Type | Additional notes |
3131
| --------------------- | --------------- | -------------------------------------------------------- |
32-
| + | String | a string |
33-
| ! | Response Code | a response code |
34-
| $ | JSON | a `JSON` value |
35-
| . | smallint | An integer in the range: [0, 255] |
36-
| - | smallint signed | An integer in the range: [-128, 127] |
37-
| : | int | An integer in the range: [0, 4,294,967,295] |
38-
| ; | int signed | An integer in the range: [-2,147,483,647, 2,147,483,647] |
39-
| % | float | A 32-bit floating point value |
40-
| ? | binary string | the next line contains binary data (often called a blob) |
32+
| `+` | String | a string |
33+
| `!` | Response Code | a response code |
34+
| `$` (reserved) | JSON | a `JSON` value |
35+
| `.` (reserved) | smallint | An integer in the range: [0, 255] |
36+
| `-` (reserved) | smallint signed | An integer in the range: [-128, 127] |
37+
| `:` | int | An integer in the range: [0, 4,294,967,295] |
38+
| `;` (reserved) | int signed | An integer in the range: [-2,147,483,647, 2,147,483,647] |
39+
| `%` (reserved) | float | A 32-bit floating point value |
40+
| `?` | binary string | the next line contains binary data (often called a blob) |
4141

4242
Do keep the matching for this symbol _non-exhaustive_ since we might add more types in future revisions of the protocol.
4343

@@ -89,10 +89,13 @@ A flat array is currently a response specific data type (only sent by the server
8989
### Typed array
9090

9191
A typed array is like a flat array, but with the exception that it can only hold
92-
two types: either a [simple type](#simple-types) or a `NUL`. You can think of it to
93-
be like: there is either an element of one type -- or there is no element. Since
94-
this array just has one type -- unlike flat arrays, they don't have any tsymbol
95-
for every element.
92+
two types: either a [simple type](#simple-types) or a `NUL`. Since this array just has a specific type in its declaration, unlike flat arrays, `tsymbol`s are not required.
93+
94+
You can think of it to be like:
95+
96+
- there is either no element (integer value of `0`; also called `NULL`)
97+
- there is an error (integer value of `21`; also called `NAK`)
98+
- or there is an element of the declared type
9699

97100
Say a programming language represents an array like:
98101

@@ -123,8 +126,8 @@ Line-by-line explanation:
123126
- `happened\n`, the element itself
124127

125128
:::note
126-
A typed array is currently a response specific data type (only sent by the server and never by the client). The `NULL`s correspond to the cases when the server can't find the requested
127-
item.
129+
A typed array is currently a response specific data type (only sent by the server and never by the client). The `NULL`s correspond to the cases when the server can't find the requested item.
130+
The `NAK` is context dependent.
128131
:::
129132

130133
### Any array
@@ -137,7 +140,7 @@ may sound -- `AnyArray`s are extremely performant. Also, **no element in an `Any
137140

138141
If you have a programming language that represents a **singly-typed** array like:
139142

140-
```cpp
143+
```rust
141144
["sayan", "is", "hiking"]
142145
```
143146

docs/protocol/skyhash.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -192,29 +192,6 @@ Where `<c>` is the number of characters in the code and `<code>` is the code its
192192

193193
You find a full list of response codes [in this table](response-codes).
194194

195-
### Flat arrays (\_)
196-
197-
Flat arrays are arrays that only contain strings. Let's say we represent an array like this in
198-
pseudocode:
199-
200-
```js
201-
["hello", "world", "once", "again"];
202-
```
203-
204-
It has 4 elements. Great, so this is how Skyhash will serialize it:
205-
206-
```sh
207-
&4\n # four elements
208-
+5\n # 'hello' has 5 chars
209-
hello\n # 'hello' itself
210-
+5\n # 'world' has 5 chars
211-
world\n # 'world' itself
212-
+4\n # 'once' has 4 chars
213-
once\n # 'once' itself
214-
+5\n # 'again' has 5 chars
215-
again\n # 'again' itself
216-
```
217-
218195
## A full example
219196

220197
Let's take a look at what happens when we send `SET x ex`. First, the client needs to serialize

docusaurus.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111
projectName: "docs",
1212
themeConfig: {
1313
prism: {
14-
additionalLanguages: ["toml"],
14+
additionalLanguages: ["toml", "rust"],
1515
},
1616
navbar: {
1717
title: "Skytable Documentation",

0 commit comments

Comments
 (0)