Storage Engine API
mongo::ArtificialTreeBuilder< OnDiskFormat > Class Template Reference

Tool to construct custom tree shapes for tests. More...

#include <btree_logic.h>

Detailed Description

template<class OnDiskFormat>
class mongo::ArtificialTreeBuilder< OnDiskFormat >

Tool to construct custom tree shapes for tests.

Public Types

typedef BtreeLogic< OnDiskFormat >::BucketType BucketType
 
typedef BtreeLogic< OnDiskFormat >::KeyDataOwnedType KeyDataOwnedType
 
typedef BtreeLogic< OnDiskFormat >::KeyHeaderType KeyHeaderType
 
typedef OnDiskFormat::FixedWidthKeyType FixedWidthKeyType
 

Public Member Functions

 ArtificialTreeBuilder (OperationContext *opCtx, BtreeLogicTestHelper< OnDiskFormat > *helper)
 The tree builder wraps around the passed-in helper and will invoke methods on it. More...
 
void makeTree (const std::string &spec)
 Causes the specified tree shape to be built on the associated helper and the tree's root installed as the head. More...
 
void checkStructure (const std::string &spec) const
 Validates that the structure of the Btree in the helper matches the specification. More...
 
void push (const DiskLoc bucketLoc, const BSONObj &key, const DiskLoc child)
 Adds the following key to the bucket and fixes up the child pointers. More...
 
int fillBucketToExactSize (const DiskLoc bucketLoc, int targetSize, char startKey)
 

Private Member Functions

DiskLoc makeTree (const BSONObj &spec)
 
void checkStructure (const BSONObj &spec, const DiskLoc node) const
 
bool isPresent (const BSONObj &key, int direction) const
 

Static Private Member Functions

static std::string expectedKey (const char *spec)
 

Private Attributes

OperationContext * _opCtx
 
BtreeLogicTestHelper< OnDiskFormat > * _helper
 

Member Typedef Documentation

◆ BucketType

template<class OnDiskFormat >
typedef BtreeLogic<OnDiskFormat>::BucketType mongo::ArtificialTreeBuilder< OnDiskFormat >::BucketType

◆ FixedWidthKeyType

template<class OnDiskFormat >
typedef OnDiskFormat::FixedWidthKeyType mongo::ArtificialTreeBuilder< OnDiskFormat >::FixedWidthKeyType

◆ KeyDataOwnedType

template<class OnDiskFormat >
typedef BtreeLogic<OnDiskFormat>::KeyDataOwnedType mongo::ArtificialTreeBuilder< OnDiskFormat >::KeyDataOwnedType

◆ KeyHeaderType

template<class OnDiskFormat >
typedef BtreeLogic<OnDiskFormat>::KeyHeaderType mongo::ArtificialTreeBuilder< OnDiskFormat >::KeyHeaderType

Constructor & Destructor Documentation

◆ ArtificialTreeBuilder()

template<class OnDiskFormat >
mongo::ArtificialTreeBuilder< OnDiskFormat >::ArtificialTreeBuilder ( OperationContext *  opCtx,
BtreeLogicTestHelper< OnDiskFormat > *  helper 
)
inline

The tree builder wraps around the passed-in helper and will invoke methods on it.

It does not do any cleanup, so constructing multiple trees over the same helper will cause leaked records.

Member Function Documentation

◆ checkStructure() [1/2]

template<class OnDiskFormat >
void mongo::ArtificialTreeBuilder< OnDiskFormat >::checkStructure ( const std::string &  spec) const

Validates that the structure of the Btree in the helper matches the specification.

◆ checkStructure() [2/2]

template<class OnDiskFormat >
void mongo::ArtificialTreeBuilder< OnDiskFormat >::checkStructure ( const BSONObj &  spec,
const DiskLoc  node 
) const
private

◆ expectedKey()

template<class OnDiskFormat >
string mongo::ArtificialTreeBuilder< OnDiskFormat >::expectedKey ( const char *  spec)
staticprivate

◆ fillBucketToExactSize()

template<class OnDiskFormat >
int mongo::ArtificialTreeBuilder< OnDiskFormat >::fillBucketToExactSize ( const DiskLoc  bucketLoc,
int  targetSize,
char  startKey 
)
Returns
The number of keys inserted.

◆ isPresent()

template<class OnDiskFormat >
bool mongo::ArtificialTreeBuilder< OnDiskFormat >::isPresent ( const BSONObj &  key,
int  direction 
) const
private

◆ makeTree() [1/2]

template<class OnDiskFormat >
void mongo::ArtificialTreeBuilder< OnDiskFormat >::makeTree ( const std::string &  spec)

Causes the specified tree shape to be built on the associated helper and the tree's root installed as the head.

Uses a custom JSON-based language with the following syntax:

Btree := BTreeBucket BtreeBucket := { Child_1_Key: <BtreeBucket | null>, Child_2_Key: <BtreeBucket | null>, ..., _: <BtreeBucket | null> }

The _ key name specifies the content of the nextChild pointer. The value null means use a fixed disk loc.

◆ makeTree() [2/2]

template<class OnDiskFormat >
DiskLoc mongo::ArtificialTreeBuilder< OnDiskFormat >::makeTree ( const BSONObj &  spec)
private

◆ push()

template<class OnDiskFormat >
void mongo::ArtificialTreeBuilder< OnDiskFormat >::push ( const DiskLoc  bucketLoc,
const BSONObj &  key,
const DiskLoc  child 
)

Adds the following key to the bucket and fixes up the child pointers.

Member Data Documentation

◆ _helper

template<class OnDiskFormat >
BtreeLogicTestHelper<OnDiskFormat>* mongo::ArtificialTreeBuilder< OnDiskFormat >::_helper
private

◆ _opCtx

template<class OnDiskFormat >
OperationContext* mongo::ArtificialTreeBuilder< OnDiskFormat >::_opCtx
private

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