Storage Engine API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
btree_test_help.h
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include <string>
32 
33 #include "mongo/db/json.h"
37 
38 namespace mongo {
39 
44 std::string bigNumString(long long n, int len);
45 
49 BSONObj simpleKey(char c, int n = 1);
50 
54 class TestHeadManager : public HeadManager {
55 public:
56  virtual const RecordId getHead(OperationContext* opCtx) const {
57  return _head;
58  }
59 
60  virtual void setHead(OperationContext* opCtx, const RecordId newHead) {
61  _head = newHead;
62  }
63 
64 private:
65  RecordId _head;
66 };
67 
68 
73 template <class OnDiskFormat>
75  BtreeLogicTestHelper(const BSONObj& order);
76 
77  // Everything needed for a fully-functional Btree logic
83 };
84 
85 
89 template <class OnDiskFormat>
91 public:
95 
96  typedef typename OnDiskFormat::FixedWidthKeyType FixedWidthKeyType;
97 
104  : _opCtx(opCtx), _helper(helper) {}
105 
120  void makeTree(const std::string& spec);
121 
125  void checkStructure(const std::string& spec) const;
126 
130  void push(const DiskLoc bucketLoc, const BSONObj& key, const DiskLoc child);
131 
135  int fillBucketToExactSize(const DiskLoc bucketLoc, int targetSize, char startKey);
136 
137 private:
138  DiskLoc makeTree(const BSONObj& spec);
139 
140  void checkStructure(const BSONObj& spec, const DiskLoc node) const;
141 
142  bool isPresent(const BSONObj& key, int direction) const;
143 
144  static std::string expectedKey(const char* spec);
145 
146  OperationContext* _opCtx;
148 };
149 
150 } // namespace mongo
HeapRecordStoreBtree recordStore
Definition: btree_test_help.h:79
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
DiskLoc dummyDiskLoc
Definition: btree_test_help.h:82
BSONObj key
Definition: btree_interface.cpp:334
represents a disk location/offset on disk in a database.
Definition: diskloc.h:53
BtreeLogic< OnDiskFormat >::KeyDataOwnedType KeyDataOwnedType
Definition: btree_test_help.h:93
OperationContext * _opCtx
Definition: btree_test_help.h:146
BtreeLogic< OnDiskFormat >::KeyHeaderType KeyHeaderType
Definition: btree_test_help.h:94
BtreeLogic< OnDiskFormat >::BucketType BucketType
Definition: btree_test_help.h:92
BSONObj simpleKey(char c, int n)
Generates key on a field &#39;a&#39;, with the specified number of repetitions of the character.
Definition: btree_test_help.cpp:52
This structure encapsulates a Btree and all the infrastructure needed by it (head manager...
Definition: btree_test_help.h:74
string bigNumString(long long n, int len)
Generates a string of the specified length containing repeated concatenation of the hexadecimal repre...
Definition: btree_test_help.cpp:42
RecordId _head
Definition: btree_test_help.h:65
A RecordStore that stores all data on the heap.
Definition: heap_record_store_btree.h:45
OnDiskFormat::FixedWidthKeyType FixedWidthKeyType
Definition: btree_test_help.h:96
Simple head manager, which performs no validity checking or persistence.
Definition: btree_test_help.h:54
std::unique_ptr< KVHarnessHelper > helper
Definition: kv_engine_test_timestamps.cpp:204
TestHeadManager headManager
Definition: btree_test_help.h:78
virtual void setHead(OperationContext *opCtx, const RecordId newHead)
Definition: btree_test_help.h:60
BtreeLogic< OnDiskFormat > btree
Definition: btree_test_help.h:81
virtual const RecordId getHead(OperationContext *opCtx) const
Definition: btree_test_help.h:56
Tool to construct custom tree shapes for tests.
Definition: btree_logic.h:52
std::unique_ptr< KVHarnessHelper > _helper
Definition: kv_catalog_feature_tracker_test.cpp:101
SavedCursorRegistry cursorRegistry
Definition: btree_test_help.h:80
ArtificialTreeBuilder(OperationContext *opCtx, BtreeLogicTestHelper< OnDiskFormat > *helper)
The tree builder wraps around the passed-in helper and will invoke methods on it. ...
Definition: btree_test_help.h:103
An abstraction for setting and getting data about the &#39;head&#39; of an index.
Definition: head_manager.h:41
OperationContext * _opCtx
Definition: ephemeral_for_test_btree_impl.cpp:447
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
Class that stores active cursors that have been saved (as part of yielding) to allow them to be inval...
Definition: record_store_v1_base.h:104
BtreeLogicTestHelper< OnDiskFormat > * _helper
Definition: btree_test_help.h:147