![]() |
Storage Engine API
|
Tool to construct custom tree shapes for tests. More...
#include <btree_logic.h>
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 |
typedef BtreeLogic<OnDiskFormat>::BucketType mongo::ArtificialTreeBuilder< OnDiskFormat >::BucketType |
typedef OnDiskFormat::FixedWidthKeyType mongo::ArtificialTreeBuilder< OnDiskFormat >::FixedWidthKeyType |
typedef BtreeLogic<OnDiskFormat>::KeyDataOwnedType mongo::ArtificialTreeBuilder< OnDiskFormat >::KeyDataOwnedType |
typedef BtreeLogic<OnDiskFormat>::KeyHeaderType mongo::ArtificialTreeBuilder< OnDiskFormat >::KeyHeaderType |
|
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.
void mongo::ArtificialTreeBuilder< OnDiskFormat >::checkStructure | ( | const std::string & | spec | ) | const |
Validates that the structure of the Btree in the helper matches the specification.
|
private |
|
staticprivate |
int mongo::ArtificialTreeBuilder< OnDiskFormat >::fillBucketToExactSize | ( | const DiskLoc | bucketLoc, |
int | targetSize, | ||
char | startKey | ||
) |
|
private |
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.
|
private |
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.
|
private |
|
private |