Documentation ¶
Overview ¶
Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0 Package txkey consolidates in one place the use of keys to index into our various storage/txn back-ends. The short_txkey version omits the index and shard, since these are implicitly part of our database-per-shard in an index scheme. In other words, every database is only in exactly one shard of one index already. There is no need to repeat the index and shard in these keys.
Index ¶
- func AllShardPrefix(index, field, view string) (r []byte)
- func FieldPrefix(index, field string) (r []byte)
- func IndexOnlyPrefix(indexName string) (r []byte)
- func Key(index, field, view string, shard, roaringContainerKey uint64) (r []byte)
- func KeyAndPrefix(index, field, view string, shard, roaringContainerKey uint64) (key, prefix []byte)
- func KeyExtractContainerKey(bkey []byte) (containerKey uint64)
- func MustValidateKey(bkey []byte)
- func Prefix(index, field, view string, shard uint64) (r []byte)
- func PrefixFromKey(bkey []byte) (prefix []byte)
- func PrefixToString(pre []byte) (r string)
- func Split(bkey []byte) (field, view string, ckey uint64)
- func SplitPrefix(pre []byte) (field, view string)
- func ToString(bkey []byte) (r string)
- type FieldView
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllShardPrefix ¶
func FieldPrefix ¶
same for deleting a whole field.
func IndexOnlyPrefix ¶
IndexOnlyPrefix returns a "~" prefix suitable for DeleteIndex and a key-scan to remove all storage. We assume only one index in this database, so delete everything.
func Key ¶
Key produces the bytes that we use as a key to query the storage/tx engine. The roaringContainerKey argument to Key() is a container key into a roaring Container. The return value from Key() is constructed as follows:
~field;view<ckey#
where ckey is always exactly 8 bytes, uint64 big-endian encoded.
Keys always start with either '~' or '>'. Keys always end with '#'. Keys always contain exactly one each of ';' and '<', in that order. The field is between the '~' and the ';'. It must be at least 1 byte long. The view is between the ';' and the '<'. It must be at least 1 byte long. The ckey is the 8 bytes between the '<' and the '#'. The Prefix of a key ends at, and includes, the '<'. It is at least 13 bytes long. The index, field, and view are not allowed to contain these reserved bytes:
{'~', '>', ';', ':', '<', '#', '$', '%', '^', '(', ')', '*', '!'}
The bytes {'+', '/', '-', '_', '.', and '=' can be used in index, field, and view; to enable base-64 encoding.
The shortest possible key is 14 bytes. It would be laid out like this:
~f;v<12345678# 12345678901234
keys starting with '~' are regular value keys. keys starting with '>' are symlink keys.
NB must be kept in sync with Prefix() and KeyExtractContainerKey().
func KeyAndPrefix ¶
func KeyAndPrefix(index, field, view string, shard, roaringContainerKey uint64) (key, prefix []byte)
KeyAndPrefix returns the equivalent of Key() and Prefix() calls.
func KeyExtractContainerKey ¶
KeyExtractContainerKey extracts the containerKey from bkey. key example: field;view<ckey shortest: ~f;v<12345678#
1234567890123456789012345 numbering len(bkey) - i: 5432109876543210987654321
func MustValidateKey ¶
func MustValidateKey(bkey []byte)
func Prefix ¶
Prefix returns everything from Key up to and including the '<' byte in a Key. The prefix excludes the roaring container key itself. NB must be kept in sync with Key() and KeyExtractContainerKey().
func PrefixFromKey ¶
PrefixFromKey key example: ~field;view<ckey#
n-9 n-1
... : 01234567 < 01234567 #
view ckey
func PrefixToString ¶
func SplitPrefix ¶
full key: ~field;view<ckey# prefix : ~field;view<