Description
We are using proto3
to serialize our records and we wanted to create an
index based on an enum.
Unfortunately, it seems the ordinal 0 cannot be indexed at all and is ignored.
I cannot find anything on the documentation but according to the tests it seems
to be something “expected” or at least known.
- fdb-record-layer/index_build.proto at fbd60ce6c3189c06fb891fd957d37f3fc07c0b9b · FoundationDB/fdb-record-layer · GitHub
- fdb-record-layer/record_metadata_options.proto at 036443fe91fe822422fe0d732bfade3c91d68441 · FoundationDB/fdb-record-layer · GitHub
- fdb-record-layer/record_cursor.proto at b75305a69eefcc33f934d12dd299197c832273b0 · FoundationDB/fdb-record-layer · GitHub
As proto3
requires a 0 for an enum, I end up with the following definition.
enum Payment {
INVALID = 0; // proto3 requires an enum to start with 0 but it's an invalid value for FDB Record Layer
PREPAID = 1;
POSTPAID = 2;
WIRED = 3;
}
And then, after inserting a bunch of data of all those types, I end up with the following keys.
Everything created as INVALID
hasn’t be indexed at all.
fdb> clearrange \x00 \xff
Committed (44052630238)
fdb> getrange \x00 \xff 1000
Range limited to 1000 keys
`\x15\x01\x02demostore\x00\x15\x02\x02account_payment_count\x00\x15\x01' is `\x01\x00\x00\x00\x00\x00\x00\x00'
`\x15\x01\x02demostore\x00\x15\x02\x02account_payment_count\x00\x15\x02' is `\x01\x00\x00\x00\x00\x00\x00\x00'
`\x15\x01\x02demostore\x00\x15\x02\x02account_payment_count\x00\x15\x03' is `\x03\x00\x00\x00\x00\x00\x00\x00'
Questions
- Is the behaviour expected?
- Am I reaching the wrong conclusions here?