Skip to content

Commit ed9528a

Browse files
authored
widen fill value of bytes dtype (#38)
1 parent 052377b commit ed9528a

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

data-types/bytes/README.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22

33
Defines a data type for variable-length byte strings.
44

5-
## Permitted fill values
5+
## Fill value encoding
66

7-
The value of the `fill_value` metadata key must be an array of byte values.
7+
The value of the `fill_value` metadata key must be one of:
8+
- an array of integers from the closed interval `[0, 255]`, where each value encodes a byte from a byte string.
9+
- a string produced by applying [base64 encoding](https://en.wikipedia.org/wiki/Base64) to a byte string.
810

9-
## Example
11+
As the string form is more compact, it may be preferred where brevity is desired.
1012

11-
For example, the array metadata below specifies that the array contains variable-length byte strings:
13+
## Examples
14+
15+
### Array fill value encoding
16+
17+
The example below shows a fragment of an array metadata document using the `bytes` data type. The
18+
fill value is the byte string `0x01 0x02 0x03` encoded as an array of integers:
1219

1320
```json
1421
{
@@ -19,14 +26,29 @@ For example, the array metadata below specifies that the array contains variable
1926
}],
2027
}
2128
```
29+
### String fill value encoding
30+
31+
The example below shows a fragment of an array metadata document using the `bytes` data type. The
32+
fill value is the byte string `0x01 0x02 0x03` encoded as a string using base64:
33+
34+
```json
35+
{
36+
"data_type": "bytes",
37+
"fill_value": "AQID",
38+
"codecs": [{
39+
"name": "vlen-bytes"
40+
}],
41+
}
42+
```
2243

23-
## Notes
44+
## Codec compatibility
2445

25-
Currently, this data type is only compatible with the [`"vlen-bytes"`](../../codecs/vlen-bytes/README.md) codec.
46+
This data type is compatible with any codec that can encode variable-length sequences of bytes.
47+
For example, the [`"vlen-bytes"`](../../codecs/vlen-bytes/README.md) codec.
2648

2749
## Change log
2850

29-
No changes yet.
51+
- Addition of the string-based fill value encoding.
3052

3153
## Current maintainers
3254

0 commit comments

Comments
 (0)