Storage Engine API
mongo::KeyString Class Reference

#include <key_string.h>

Classes

class  TypeBits
 Encodes info needed to restore the original BSONTypes from a KeyString. More...
 

Public Types

enum  Version : uint8_t { Version::V0 = 0, Version::V1 = 1 }
 Selects version of KeyString to use. More...
 
enum  Discriminator { kInclusive, kExclusiveBefore, kExclusiveAfter }
 
enum  DecimalContinuationMarker { kDCMEqualToDouble = 0x0, kDCMHasContinuationLessThanDoubleRoundedUpTo15Digits = 0x1, kDCMEqualToDoubleRoundedUpTo15Digits = 0x2, kDCMHasContinuationLargerThanDoubleRoundedUpTo15Digits = 0x3 }
 Encodes the kind of NumberDecimal that is stored. More...
 

Public Member Functions

 KeyString (Version version)
 
 KeyString (Version version, const BSONObj &obj, Ordering ord, RecordId recordId)
 
 KeyString (Version version, const BSONObj &obj, Ordering ord, Discriminator discriminator=kInclusive)
 
 KeyString (Version version, RecordId rid)
 
void appendRecordId (RecordId loc)
 
void appendTypeBits (const TypeBits &bits)
 
void resetToEmpty ()
 Resets to an empty state. More...
 
void resetToKey (const BSONObj &obj, Ordering ord, RecordId recordId)
 
void resetToKey (const BSONObj &obj, Ordering ord, Discriminator discriminator=kInclusive)
 
void resetFromBuffer (const void *buffer, size_t size)
 
const char * getBuffer () const
 
size_t getSize () const
 
bool isEmpty () const
 
const TypeBitsgetTypeBits () const
 
int compare (const KeyString &other) const
 
std::string toString () const
 

Static Public Member Functions

static StringData versionToString (Version version)
 
static size_t getKeySize (const char *buffer, size_t len, Ordering ord, const TypeBits &typeBits)
 
static BSONObj toBson (StringData data, Ordering ord, const TypeBits &types)
 
static BSONObj toBson (const char *buffer, size_t len, Ordering ord, const TypeBits &types) noexcept
 Decodes the given KeyString buffer into it's BSONObj representation. More...
 
static BSONObj toBsonSafe (const char *buffer, size_t len, Ordering ord, const TypeBits &types)
 
static RecordId decodeRecordIdAtEnd (const void *buf, size_t size)
 Decodes a RecordId from the end of a buffer. More...
 
static RecordId decodeRecordId (BufReader *reader)
 Decodes a RecordId, consuming all bytes needed from reader. More...
 

Public Attributes

const Version version
 Version to use for conversion to/from KeyString. More...
 

Static Public Attributes

static const Version kLatestVersion = Version::V1
 Provides the latest version of KeyString available. More...
 

Private Member Functions

void _appendAllElementsForIndexing (const BSONObj &obj, Ordering ord, Discriminator discriminator)
 
void _appendBool (bool val, bool invert)
 
void _appendDate (Date_t val, bool invert)
 
void _appendTimestamp (Timestamp val, bool invert)
 
void _appendOID (OID val, bool invert)
 
void _appendString (StringData val, bool invert)
 
void _appendSymbol (StringData val, bool invert)
 
void _appendCode (StringData val, bool invert)
 
void _appendCodeWString (const BSONCodeWScope &val, bool invert)
 
void _appendBinData (const BSONBinData &val, bool invert)
 
void _appendRegex (const BSONRegEx &val, bool invert)
 
void _appendDBRef (const BSONDBRef &val, bool invert)
 
void _appendArray (const BSONArray &val, bool invert)
 
void _appendObject (const BSONObj &val, bool invert)
 
void _appendNumberDouble (const double num, bool invert)
 
void _appendNumberLong (const long long num, bool invert)
 
void _appendNumberInt (const int num, bool invert)
 
void _appendNumberDecimal (const Decimal128 num, bool invert)
 
void _appendBsonValue (const BSONElement &elem, bool invert, const StringData *name)
 
void _appendStringLike (StringData str, bool invert)
 – lowest level More...
 
void _appendBson (const BSONObj &obj, bool invert)
 
void _appendSmallDouble (double value, DecimalContinuationMarker dcm, bool invert)
 
void _appendLargeDouble (double value, DecimalContinuationMarker dcm, bool invert)
 
void _appendInteger (const long long num, bool invert)
 
void _appendPreshiftedIntegerPortion (uint64_t value, bool isNegative, bool invert)
 
void _appendDoubleWithoutTypeBits (const double num, DecimalContinuationMarker dcm, bool invert)
 
void _appendHugeDecimalWithoutTypeBits (const Decimal128 dec, bool invert)
 
void _appendTinyDecimalWithoutTypeBits (const Decimal128 dec, const double bin, bool invert)
 
template<typename T >
void _append (const T &thing, bool invert)
 
void _appendBytes (const void *source, size_t bytes, bool invert)
 

Private Attributes

TypeBits _typeBits
 
StackBufBuilder _buffer
 

Member Enumeration Documentation

◆ DecimalContinuationMarker

Encodes the kind of NumberDecimal that is stored.

Enumerator
kDCMEqualToDouble 
kDCMHasContinuationLessThanDoubleRoundedUpTo15Digits 
kDCMEqualToDoubleRoundedUpTo15Digits 
kDCMHasContinuationLargerThanDoubleRoundedUpTo15Digits 

◆ Discriminator

Enumerator
kInclusive 
kExclusiveBefore 
kExclusiveAfter 

◆ Version

enum mongo::KeyString::Version : uint8_t
strong

Selects version of KeyString to use.

V0 and V1 differ in their encoding of numeric values.

Enumerator
V0 
V1 

Constructor & Destructor Documentation

◆ KeyString() [1/4]

mongo::KeyString::KeyString ( Version  version)
inlineexplicit

◆ KeyString() [2/4]

mongo::KeyString::KeyString ( Version  version,
const BSONObj &  obj,
Ordering  ord,
RecordId  recordId 
)
inline

◆ KeyString() [3/4]

mongo::KeyString::KeyString ( Version  version,
const BSONObj &  obj,
Ordering  ord,
Discriminator  discriminator = kInclusive 
)
inline

◆ KeyString() [4/4]

mongo::KeyString::KeyString ( Version  version,
RecordId  rid 
)
inline

Member Function Documentation

◆ _append()

template<typename T >
void mongo::KeyString::_append ( const T &  thing,
bool  invert 
)
private

◆ _appendAllElementsForIndexing()

void mongo::KeyString::_appendAllElementsForIndexing ( const BSONObj &  obj,
Ordering  ord,
Discriminator  discriminator 
)
private

◆ _appendArray()

void mongo::KeyString::_appendArray ( const BSONArray &  val,
bool  invert 
)
private

◆ _appendBinData()

void mongo::KeyString::_appendBinData ( const BSONBinData &  val,
bool  invert 
)
private

◆ _appendBool()

void mongo::KeyString::_appendBool ( bool  val,
bool  invert 
)
private

◆ _appendBson()

void mongo::KeyString::_appendBson ( const BSONObj &  obj,
bool  invert 
)
private

◆ _appendBsonValue()

void mongo::KeyString::_appendBsonValue ( const BSONElement &  elem,
bool  invert,
const StringData *  name 
)
private
Parameters
name- optional, can be NULL if NULL, not included in encoding if not NULL, put in after type, before value

◆ _appendBytes()

void mongo::KeyString::_appendBytes ( const void source,
size_t  bytes,
bool  invert 
)
private

◆ _appendCode()

void mongo::KeyString::_appendCode ( StringData  val,
bool  invert 
)
private

◆ _appendCodeWString()

void mongo::KeyString::_appendCodeWString ( const BSONCodeWScope &  val,
bool  invert 
)
private

◆ _appendDate()

void mongo::KeyString::_appendDate ( Date_t  val,
bool  invert 
)
private

◆ _appendDBRef()

void mongo::KeyString::_appendDBRef ( const BSONDBRef &  val,
bool  invert 
)
private

◆ _appendDoubleWithoutTypeBits()

void mongo::KeyString::_appendDoubleWithoutTypeBits ( const double  num,
DecimalContinuationMarker  dcm,
bool  invert 
)
private

◆ _appendHugeDecimalWithoutTypeBits()

void mongo::KeyString::_appendHugeDecimalWithoutTypeBits ( const Decimal128  dec,
bool  invert 
)
private

◆ _appendInteger()

void mongo::KeyString::_appendInteger ( const long long  num,
bool  invert 
)
private

◆ _appendLargeDouble()

void mongo::KeyString::_appendLargeDouble ( double  value,
DecimalContinuationMarker  dcm,
bool  invert 
)
private

◆ _appendNumberDecimal()

void mongo::KeyString::_appendNumberDecimal ( const Decimal128  num,
bool  invert 
)
private

◆ _appendNumberDouble()

void mongo::KeyString::_appendNumberDouble ( const double  num,
bool  invert 
)
private

◆ _appendNumberInt()

void mongo::KeyString::_appendNumberInt ( const int  num,
bool  invert 
)
private

◆ _appendNumberLong()

void mongo::KeyString::_appendNumberLong ( const long long  num,
bool  invert 
)
private

◆ _appendObject()

void mongo::KeyString::_appendObject ( const BSONObj &  val,
bool  invert 
)
private

◆ _appendOID()

void mongo::KeyString::_appendOID ( OID  val,
bool  invert 
)
private

◆ _appendPreshiftedIntegerPortion()

void mongo::KeyString::_appendPreshiftedIntegerPortion ( uint64_t  value,
bool  isNegative,
bool  invert 
)
private

◆ _appendRegex()

void mongo::KeyString::_appendRegex ( const BSONRegEx &  val,
bool  invert 
)
private

◆ _appendSmallDouble()

void mongo::KeyString::_appendSmallDouble ( double  value,
DecimalContinuationMarker  dcm,
bool  invert 
)
private

◆ _appendString()

void mongo::KeyString::_appendString ( StringData  val,
bool  invert 
)
private

◆ _appendStringLike()

void mongo::KeyString::_appendStringLike ( StringData  str,
bool  invert 
)
private

– lowest level

◆ _appendSymbol()

void mongo::KeyString::_appendSymbol ( StringData  val,
bool  invert 
)
private

◆ _appendTimestamp()

void mongo::KeyString::_appendTimestamp ( Timestamp  val,
bool  invert 
)
private

◆ _appendTinyDecimalWithoutTypeBits()

void mongo::KeyString::_appendTinyDecimalWithoutTypeBits ( const Decimal128  dec,
const double  bin,
bool  invert 
)
private

◆ appendRecordId()

void mongo::KeyString::appendRecordId ( RecordId  loc)

◆ appendTypeBits()

void mongo::KeyString::appendTypeBits ( const TypeBits bits)

◆ compare()

int mongo::KeyString::compare ( const KeyString other) const

◆ decodeRecordId()

RecordId mongo::KeyString::decodeRecordId ( BufReader *  reader)
static

Decodes a RecordId, consuming all bytes needed from reader.

◆ decodeRecordIdAtEnd()

RecordId mongo::KeyString::decodeRecordIdAtEnd ( const void buf,
size_t  size 
)
static

Decodes a RecordId from the end of a buffer.

◆ getBuffer()

const char* mongo::KeyString::getBuffer ( ) const
inline

◆ getKeySize()

size_t mongo::KeyString::getKeySize ( const char *  buffer,
size_t  len,
Ordering  ord,
const TypeBits typeBits 
)
static

◆ getSize()

size_t mongo::KeyString::getSize ( ) const
inline

◆ getTypeBits()

const TypeBits& mongo::KeyString::getTypeBits ( ) const
inline

◆ isEmpty()

bool mongo::KeyString::isEmpty ( ) const
inline

◆ resetFromBuffer()

void mongo::KeyString::resetFromBuffer ( const void buffer,
size_t  size 
)
inline

◆ resetToEmpty()

void mongo::KeyString::resetToEmpty ( )
inline

Resets to an empty state.

Equivalent to but faster than *this = KeyString()

◆ resetToKey() [1/2]

void mongo::KeyString::resetToKey ( const BSONObj &  obj,
Ordering  ord,
RecordId  recordId 
)

◆ resetToKey() [2/2]

void mongo::KeyString::resetToKey ( const BSONObj &  obj,
Ordering  ord,
Discriminator  discriminator = kInclusive 
)

◆ toBson() [1/2]

BSONObj mongo::KeyString::toBson ( StringData  data,
Ordering  ord,
const TypeBits types 
)
static

◆ toBson() [2/2]

BSONObj mongo::KeyString::toBson ( const char *  buffer,
size_t  len,
Ordering  ord,
const TypeBits types 
)
staticnoexcept

Decodes the given KeyString buffer into it's BSONObj representation.

This is marked as noexcept since the assumption is that 'buffer' is a valid KeyString buffer and this method is not expected to throw.

If the buffer provided may not be valid, use the 'safe' version instead.

◆ toBsonSafe()

BSONObj mongo::KeyString::toBsonSafe ( const char *  buffer,
size_t  len,
Ordering  ord,
const TypeBits types 
)
static

◆ toString()

std::string mongo::KeyString::toString ( ) const
Returns
a hex encoding of this key

◆ versionToString()

static StringData mongo::KeyString::versionToString ( Version  version)
inlinestatic

Member Data Documentation

◆ _buffer

StackBufBuilder mongo::KeyString::_buffer
private

◆ _typeBits

TypeBits mongo::KeyString::_typeBits
private

◆ kLatestVersion

const Version mongo::KeyString::kLatestVersion = Version::V1
static

Provides the latest version of KeyString available.

◆ version

const Version mongo::KeyString::version

Version to use for conversion to/from KeyString.

V1 has different encodings for numeric values.


The documentation for this class was generated from the following files: