Storage Engine API
sorted_data_interface_test_harness.h
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include <initializer_list>
32 #include <memory>
33 
34 #include "mongo/db/jsobj.h"
35 #include "mongo/db/operation_context_noop.h"
36 #include "mongo/db/record_id.h"
37 #include "mongo/db/service_context.h"
38 #include "mongo/db/service_context_noop.h"
41 #include "mongo/stdx/memory.h"
42 #include "mongo/util/unowned_ptr.h"
43 
44 namespace mongo {
45 
46 const BSONObj key0 = BSON("" << 0);
47 const BSONObj key1 = BSON("" << 1);
48 const BSONObj key2 = BSON("" << 2);
49 const BSONObj key3 = BSON("" << 3);
50 const BSONObj key4 = BSON("" << 4);
51 const BSONObj key5 = BSON("" << 5);
52 const BSONObj key6 = BSON("" << 6);
53 
54 const BSONObj compoundKey1a = BSON("" << 1 << ""
55  << "a");
56 const BSONObj compoundKey1b = BSON("" << 1 << ""
57  << "b");
58 const BSONObj compoundKey1c = BSON("" << 1 << ""
59  << "c");
60 const BSONObj compoundKey1d = BSON("" << 1 << ""
61  << "d");
62 const BSONObj compoundKey2a = BSON("" << 2 << ""
63  << "a");
64 const BSONObj compoundKey2b = BSON("" << 2 << ""
65  << "b");
66 const BSONObj compoundKey2c = BSON("" << 2 << ""
67  << "c");
68 const BSONObj compoundKey3a = BSON("" << 3 << ""
69  << "a");
70 const BSONObj compoundKey3b = BSON("" << 3 << ""
71  << "b");
72 const BSONObj compoundKey3c = BSON("" << 3 << ""
73  << "c");
74 
75 const RecordId loc1(0, 42);
76 const RecordId loc2(0, 44);
77 const RecordId loc3(0, 46);
78 const RecordId loc4(0, 48);
79 const RecordId loc5(0, 50);
80 const RecordId loc6(0, 52);
81 const RecordId loc7(0, 54);
82 const RecordId loc8(0, 56);
83 
84 class RecoveryUnit;
85 
87 public:
88  virtual std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique) = 0;
89 
95  std::unique_ptr<SortedDataInterface> newSortedDataInterface(
96  bool unique, std::initializer_list<IndexKeyEntry> toInsert);
97 };
98 
106 void insertToIndex(unowned_ptr<OperationContext> opCtx,
107  unowned_ptr<SortedDataInterface> index,
108  std::initializer_list<IndexKeyEntry> toInsert);
109 
110 inline void insertToIndex(unowned_ptr<HarnessHelper> harness,
111  unowned_ptr<SortedDataInterface> index,
112  std::initializer_list<IndexKeyEntry> toInsert) {
113  auto client = harness->serviceContext()->makeClient("insertToIndex");
114  insertToIndex(harness->newOperationContext(client.get()), index, toInsert);
115 }
116 
123 void removeFromIndex(unowned_ptr<OperationContext> opCtx,
124  unowned_ptr<SortedDataInterface> index,
125  std::initializer_list<IndexKeyEntry> toRemove);
126 
127 inline void removeFromIndex(unowned_ptr<HarnessHelper> harness,
128  unowned_ptr<SortedDataInterface> index,
129  std::initializer_list<IndexKeyEntry> toRemove) {
130  auto client = harness->serviceContext()->makeClient("removeFromIndex");
131  removeFromIndex(harness->newOperationContext(client.get()), index, toRemove);
132 }
133 
134 inline std::unique_ptr<SortedDataInterfaceHarnessHelper> newSortedDataInterfaceHarnessHelper() {
136 }
137 } // namespace mongo
std::unique_ptr< Target > dynamic_ptr_cast(std::unique_ptr< Current > &&p)
Definition: test_harness_helper.h:102
const BSONObj key0
Definition: sorted_data_interface_test_harness.h:46
Definition: sorted_data_interface_test_harness.h:86
const RecordId loc1(0, 42)
const BSONObj key4
Definition: sorted_data_interface_test_harness.h:50
const RecordId loc4(0, 48)
const BSONObj compoundKey3a
Definition: sorted_data_interface_test_harness.h:68
const BSONObj key1
Definition: sorted_data_interface_test_harness.h:47
const BSONObj compoundKey1d
Definition: sorted_data_interface_test_harness.h:60
const BSONObj compoundKey2a
Definition: sorted_data_interface_test_harness.h:62
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
const RecordId loc2(0, 44)
Client * client() const
Definition: test_harness_helper.h:72
const BSONObj key3
Definition: sorted_data_interface_test_harness.h:49
std::unique_ptr< SortedDataInterfaceHarnessHelper > newSortedDataInterfaceHarnessHelper()
Definition: sorted_data_interface_test_harness.h:134
virtual std::unique_ptr< SortedDataInterface > newSortedDataInterface(bool unique)=0
const BSONObj compoundKey2c
Definition: sorted_data_interface_test_harness.h:66
const BSONObj compoundKey1a
Definition: sorted_data_interface_test_harness.h:54
Sets up an OperationContext with a Recovery Unit.
Definition: test_harness_helper.h:55
const BSONObj key5
Definition: sorted_data_interface_test_harness.h:51
const BSONObj compoundKey2b
Definition: sorted_data_interface_test_harness.h:64
A RecoveryUnit is responsible for ensuring that data is persisted.
Definition: recovery_unit.h:51
const RecordId loc7(0, 54)
const RecordId loc8(0, 56)
const RecordId loc6(0, 52)
std::unique_ptr< HarnessHelper > newHarnessHelper()
Definition: test_harness_helper.cpp:49
const BSONObj compoundKey3c
Definition: sorted_data_interface_test_harness.h:72
void insertToIndex(unowned_ptr< OperationContext > opCtx, unowned_ptr< SortedDataInterface > index, std::initializer_list< IndexKeyEntry > toInsert)
Inserts all entries in toInsert into index.
Definition: sorted_data_interface_test_harness.cpp:50
void removeFromIndex(unowned_ptr< OperationContext > opCtx, unowned_ptr< SortedDataInterface > index, std::initializer_list< IndexKeyEntry > toRemove)
Removes all entries in toRemove from index.
Definition: sorted_data_interface_test_harness.cpp:60
const BSONObj key2
Definition: sorted_data_interface_test_harness.h:48
const RecordId loc3(0, 46)
const BSONObj compoundKey1b
Definition: sorted_data_interface_test_harness.h:56
const BSONObj compoundKey1c
Definition: sorted_data_interface_test_harness.h:58
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
const BSONObj key6
Definition: sorted_data_interface_test_harness.h:52
const RecordId loc5(0, 50)
const BSONObj compoundKey3b
Definition: sorted_data_interface_test_harness.h:70