![]() |
Storage Engine API
|
Encodes info needed to restore the original BSONTypes from a KeyString. More...
#include <key_string.h>
Encodes info needed to restore the original BSONTypes from a KeyString.
They cannot be stored in place since we don't want them to affect the ordering (1 and 1.0 compare as equal).
Classes | |
class | Reader |
Public Member Functions | |
MONGO_STATIC_ASSERT_MSG (kMaxTypeBitsPerDecimal *kMaxDecimalsPerKey< kMaxBytesNeeded *8UL, "encoding needs change to contain all type bits for worst case key") | |
TypeBits (Version version) | |
void | resetFromBuffer (BufReader *reader) |
If there are no bytes remaining, assumes AllZeros. More... | |
bool | isAllZeros () const |
If true, no bits have been set to one. More... | |
const uint8_t * | getBuffer () const |
These methods return a buffer and size which encodes all of the type bits in this instance. More... | |
size_t | getSize () const |
void | reset () |
void | appendString () |
void | appendSymbol () |
void | appendNumberDouble () |
void | appendNumberInt () |
void | appendNumberLong () |
void | appendNumberDecimal () |
void | appendZero (uint8_t zeroType) |
void | appendDecimalZero (uint32_t whichZero) |
void | appendDecimalExponent (uint8_t storedExponentBits) |
Static Public Member Functions | |
static TypeBits | fromBuffer (Version version, BufReader *reader) |
Public Attributes | |
const Version | version |
Static Public Attributes | |
static const uint8_t | kMaxBytesNeeded = 127 |
static const uint32_t | kMaxKeyBytes = 1024 |
static const uint32_t | kMaxTypeBitsPerDecimal = 17 |
static const uint32_t | kBytesForTypeAndEmptyKey = 2 |
static const uint32_t | kMaxDecimalsPerKey |
static const uint8_t | kStoredDecimalExponentBits = 6 |
static const uint32_t | kStoredDecimalExponentMask = (1U << kStoredDecimalExponentBits) - 1 |
static const uint8_t | kString = 0x0 |
static const uint8_t | kSymbol = 0x1 |
static const uint8_t | kInt = 0x0 |
static const uint8_t | kLong = 0x1 |
static const uint8_t | kDouble = 0x2 |
static const uint8_t | kDecimal = 0x3 |
static const uint8_t | kSpecialZeroPrefix = 0x3 |
static const uint8_t | kNegativeDoubleZero = 0x3 |
static const uint8_t | kV0NegativeDoubleZero = 0x3 |
static const uint8_t | kV1NegativeDoubleZero = 0x18 |
static const uint8_t | kUnusedEncoding = 0x19 |
static const uint8_t | kDecimalZero0xxx = 0x1a |
static const uint8_t | kDecimalZero1xxx = 0x1b |
static const uint8_t | kDecimalZero2xxx = 0x1c |
static const uint8_t | kDecimalZero3xxx = 0x1d |
static const uint8_t | kDecimalZero4xxx = 0x1e |
static const uint8_t | kDecimalZero5xxx = 0x1f |
Private Member Functions | |
uint8_t | getSizeByte () const |
size only includes data bytes, not the size byte itself. More... | |
void | setSizeByte (uint8_t size) |
void | appendBit (uint8_t oneOrZero) |
Private Attributes | |
size_t | _curBit |
bool | _isAllZeros |
uint8_t | _buf [1+kMaxBytesNeeded] |
|
inlineexplicit |
|
private |
void mongo::KeyString::TypeBits::appendDecimalExponent | ( | uint8_t | storedExponentBits | ) |
void mongo::KeyString::TypeBits::appendDecimalZero | ( | uint32_t | whichZero | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void mongo::KeyString::TypeBits::appendZero | ( | uint8_t | zeroType | ) |
|
inlinestatic |
|
inline |
These methods return a buffer and size which encodes all of the type bits in this instance.
Encoded format: Case 1 (first byte has high bit set to 1): Remaining bits of first byte encode number of follow-up bytes that are data bytes. Note that _buf is always maintained in this format but these methods may return one of the other formats, if possible, by skipping over the first byte.
Case 2 (first byte is 0x0): This encodes the "AllZeros" state which represents an infinite stream of bits set to 0. Callers may optionally encode this case as an empty buffer if they have another way to mark the end of the buffer. There are no follow-up bytes.
Case 3 (first byte isn't 0x0 but has high bit set to 0): The first byte is the only data byte. This can represent any 7-bit sequence or an 8-bit sequence if the 8th bit is 0, since the 8th bit is the same as the bit that is 1 if the first byte is the size byte. There are no follow-up bytes.
Within data bytes (ie everything excluding the size byte if there is one), bits are packed in from low to high.
|
inline |
|
inlineprivate |
size only includes data bytes, not the size byte itself.
|
inline |
If true, no bits have been set to one.
This is true if no bits have been set at all.
mongo::KeyString::TypeBits::MONGO_STATIC_ASSERT_MSG | ( | ) |
|
inline |
void mongo::KeyString::TypeBits::resetFromBuffer | ( | BufReader * | reader | ) |
If there are no bytes remaining, assumes AllZeros.
Otherwise, reads bytes out of the BufReader in the format described on the getBuffer() method.
|
inlineprivate |
|
private |
|
private |
|
private |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
const Version mongo::KeyString::TypeBits::version |