diff options
author | Hari Khalsa <hkhalsa@10gen.com> | 2014-06-26 13:29:05 -0400 |
---|---|---|
committer | Hari Khalsa <hkhalsa@10gen.com> | 2014-06-27 11:40:47 -0400 |
commit | d21efec1d8a3554792ca72a666fc61cd09f85ec9 (patch) | |
tree | 682506ca521b1bea74c3ff87402dbaaf9ed1b4e3 /src/mongo | |
parent | 8ec5d664cbc47578d01ffb07aa31f32544b1a345 (diff) | |
download | mongo-d21efec1d8a3554792ca72a666fc61cd09f85ec9.tar.gz |
SERVER-13635 keep mmapv1-specific record.h within mmapv1 impl
Diffstat (limited to 'src/mongo')
20 files changed, 43 insertions, 47 deletions
diff --git a/src/mongo/db/exec/oplogstart.cpp b/src/mongo/db/exec/oplogstart.cpp index f63f95b27b9..c569bfb8a34 100644 --- a/src/mongo/db/exec/oplogstart.cpp +++ b/src/mongo/db/exec/oplogstart.cpp @@ -31,7 +31,6 @@ #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" #include "mongo/db/client.h" -#include "mongo/db/storage/record.h" namespace mongo { diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp index c40bce96687..5ec74934cbe 100644 --- a/src/mongo/db/mongod_options.cpp +++ b/src/mongo/db/mongod_options.cpp @@ -40,7 +40,6 @@ #include "mongo/db/repl/repl_settings.h" #include "mongo/db/server_options.h" #include "mongo/db/server_options_helpers.h" -#include "mongo/db/storage/record.h" #include "mongo/util/mongoutils/str.h" #include "mongo/util/net/ssl_options.h" #include "mongo/util/options_parser/startup_options.h" diff --git a/src/mongo/db/storage/heap1/heap1_test.cpp b/src/mongo/db/storage/heap1/heap1_test.cpp index b41b3122898..a403979d850 100644 --- a/src/mongo/db/storage/heap1/heap1_test.cpp +++ b/src/mongo/db/storage/heap1/heap1_test.cpp @@ -33,7 +33,6 @@ #include "mongo/db/operation_context.h" #include "mongo/db/storage/heap1/heap1_database_catalog_entry.h" #include "mongo/db/storage/heap1/heap1_recovery_unit.h" -#include "mongo/db/storage/record.h" #include "mongo/db/structure/record_store.h" #include "mongo/unittest/unittest.h" @@ -132,7 +131,7 @@ namespace { StatusWith<DiskLoc> loc = rs->insertRecord( &op, "abc", 4, -1 ); ASSERT_OK( loc.getStatus() ); ASSERT_EQUALS( 1, rs->numRecords() ); - ASSERT_EQUALS( std::string( "abc" ), rs->recordFor( loc.getValue() )->data() ); + ASSERT_EQUALS( std::string( "abc" ), rs->dataFor( loc.getValue() )->data() ); } } diff --git a/src/mongo/db/storage/mmap_v1/dur.h b/src/mongo/db/storage/mmap_v1/dur.h index cca8988efbe..065d39ecd2d 100644 --- a/src/mongo/db/storage/mmap_v1/dur.h +++ b/src/mongo/db/storage/mmap_v1/dur.h @@ -32,7 +32,6 @@ #include "mongo/db/diskloc.h" #include "mongo/db/storage/mmap_v1/durable_mapped_file.h" -#include "mongo/db/storage/record.h" namespace mongo { @@ -174,16 +173,6 @@ namespace mongo { static DurableInterface& getDur() { return *_impl; } private: - /** Intentionally unimplemented method. - It's very easy to manipulate Record::data open ended. Thus a call to writing(Record*) is suspect. - This will override the templated version and yield an unresolved external. - */ - Record* writing(Record* r); - /** Intentionally unimplemented method. BtreeBuckets are allocated in buffers larger than sizeof( BtreeBucket ). */ -// BtreeBucket* writing( BtreeBucket* ); - /** Intentionally unimplemented method. NamespaceDetails may be based on references to 'Extra' objects. */ - NamespaceDetails* writing( NamespaceDetails* ); - static DurableInterface* _impl; // NonDurableImpl at startup() static void enableDurability(); // makes _impl a DurableImpl static void disableDurability(); // makes _impl a NonDurableImpl diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp b/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp index 1e41c8c6033..ae886d8202e 100644 --- a/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp +++ b/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp @@ -37,9 +37,9 @@ #include "mongo/db/d_concurrency.h" #include "mongo/db/storage/mmap_v1/dur.h" #include "mongo/db/storage/mmap_v1/data_file.h" +#include "mongo/db/storage/mmap_v1/record.h" #include "mongo/db/storage/extent.h" #include "mongo/db/storage/extent_manager.h" -#include "mongo/db/storage/record.h" #include "mongo/db/operation_context.h" #include "mongo/util/log.h" diff --git a/src/mongo/db/storage/record.h b/src/mongo/db/storage/mmap_v1/record.h index 395a65cfdca..395a65cfdca 100644 --- a/src/mongo/db/storage/record.h +++ b/src/mongo/db/storage/mmap_v1/record.h diff --git a/src/mongo/db/structure/btree/btree_logic.cpp b/src/mongo/db/structure/btree/btree_logic.cpp index 6c532e23c84..0cd10393043 100644 --- a/src/mongo/db/structure/btree/btree_logic.cpp +++ b/src/mongo/db/structure/btree/btree_logic.cpp @@ -28,7 +28,6 @@ #include "mongo/db/diskloc.h" #include "mongo/db/jsobj.h" -#include "mongo/db/storage/record.h" #include "mongo/db/operation_context.h" #include "mongo/db/structure/btree/btree_logic.h" #include "mongo/db/structure/btree/key.h" diff --git a/src/mongo/db/structure/btree/btree_logic.h b/src/mongo/db/structure/btree/btree_logic.h index 94b82ed99bd..157040e4891 100644 --- a/src/mongo/db/structure/btree/btree_logic.h +++ b/src/mongo/db/structure/btree/btree_logic.h @@ -31,7 +31,6 @@ #include "mongo/db/catalog/index_catalog_entry.h" #include "mongo/db/diskloc.h" #include "mongo/db/jsobj.h" -#include "mongo/db/storage/record.h" #include "mongo/db/operation_context.h" #include "mongo/db/structure/btree/btree_ondisk.h" #include "mongo/db/structure/btree/key.h" diff --git a/src/mongo/db/structure/btree/btree_ondisk.h b/src/mongo/db/structure/btree/btree_ondisk.h index 1045443c822..fd343db111f 100644 --- a/src/mongo/db/structure/btree/btree_ondisk.h +++ b/src/mongo/db/structure/btree/btree_ondisk.h @@ -31,7 +31,6 @@ #include "mongo/db/diskloc.h" #include "mongo/db/storage/mmap_v1/dur.h" #include "mongo/db/jsobj.h" -#include "mongo/db/storage/record.h" #include "mongo/db/structure/btree/key.h" namespace mongo { diff --git a/src/mongo/db/structure/collection_compact.cpp b/src/mongo/db/structure/collection_compact.cpp index 4146c3a457b..c4d91c17168 100644 --- a/src/mongo/db/structure/collection_compact.cpp +++ b/src/mongo/db/structure/collection_compact.cpp @@ -39,9 +39,6 @@ #include "mongo/db/catalog/database.h" #include "mongo/db/catalog/index_key_validate.h" #include "mongo/db/index/index_access_method.h" -#include "mongo/db/storage/extent.h" -#include "mongo/db/storage/extent_manager.h" -#include "mongo/db/storage/record.h" #include "mongo/db/operation_context.h" #include "mongo/util/touch_pages.h" diff --git a/src/mongo/db/structure/record_store.h b/src/mongo/db/structure/record_store.h index c248709ca8b..e8f212f7f3f 100644 --- a/src/mongo/db/structure/record_store.h +++ b/src/mongo/db/structure/record_store.h @@ -42,12 +42,10 @@ namespace mongo { class Collection; struct CompactOptions; struct CompactStats; - class DeletedRecord; class DocWriter; class ExtentManager; class MAdvise; class NamespaceDetails; - class Record; class OperationContext; class RecordStoreCompactAdaptor; diff --git a/src/mongo/db/structure/record_store_heap.cpp b/src/mongo/db/structure/record_store_heap.cpp index bc3fd0298a6..2bbb7e2ec62 100644 --- a/src/mongo/db/structure/record_store_heap.cpp +++ b/src/mongo/db/structure/record_store_heap.cpp @@ -31,8 +31,6 @@ #include "mongo/db/structure/record_store_heap.h" -#include "mongo/db/storage/record.h" - namespace mongo { // @@ -68,14 +66,14 @@ namespace mongo { return recordFor(loc)->toRecordData(); } - Record* HeapRecordStore::recordFor(const DiskLoc& loc) const { + HeapRecordStore::HeapRecord* HeapRecordStore::recordFor(const DiskLoc& loc) const { Records::const_iterator it = _records.find(loc); invariant(it != _records.end()); - return reinterpret_cast<Record*>(it->second.get()); + return reinterpret_cast<HeapRecord*>(it->second.get()); } void HeapRecordStore::deleteRecord(OperationContext* txn, const DiskLoc& loc) { - Record* rec = recordFor(loc); + HeapRecord* rec = recordFor(loc); _dataSize -= rec->netLength(); invariant(_records.erase(loc) == 1); } @@ -118,9 +116,9 @@ namespace mongo { } // TODO padding? - const int lengthWithHeaders = len + Record::HeaderSize; + const int lengthWithHeaders = len + HeapRecord::HeaderSize; boost::shared_array<char> buf(new char[lengthWithHeaders]); - Record* rec = reinterpret_cast<Record*>(buf.get()); + HeapRecord* rec = reinterpret_cast<HeapRecord*>(buf.get()); rec->lengthWithHeaders() = lengthWithHeaders; memcpy(rec->data(), data, len); @@ -145,9 +143,9 @@ namespace mongo { } // TODO padding? - const int lengthWithHeaders = len + Record::HeaderSize; + const int lengthWithHeaders = len + HeapRecord::HeaderSize; boost::shared_array<char> buf(new char[lengthWithHeaders]); - Record* rec = reinterpret_cast<Record*>(buf.get()); + HeapRecord* rec = reinterpret_cast<HeapRecord*>(buf.get()); rec->lengthWithHeaders() = lengthWithHeaders; doc->writeDocument(rec->data()); @@ -166,7 +164,7 @@ namespace mongo { int len, int quotaMax, UpdateMoveNotifier* notifier ) { - Record* oldRecord = recordFor( oldLocation ); + HeapRecord* oldRecord = recordFor( oldLocation ); int oldLen = oldRecord->netLength(); // If the length of the new data is <= the length of the old data then just @@ -186,9 +184,9 @@ namespace mongo { // If the length of the new data exceeds the size of the old Record, we need to allocate // a new Record, and delete the old one - const int lengthWithHeaders = len + Record::HeaderSize; + const int lengthWithHeaders = len + HeapRecord::HeaderSize; boost::shared_array<char> buf(new char[lengthWithHeaders]); - Record* rec = reinterpret_cast<Record*>(buf.get()); + HeapRecord* rec = reinterpret_cast<HeapRecord*>(buf.get()); rec->lengthWithHeaders() = lengthWithHeaders; memcpy(rec->data(), data, len); @@ -204,7 +202,7 @@ namespace mongo { const DiskLoc& loc, const char* damangeSource, const mutablebson::DamageVector& damages ) { - Record* rec = recordFor( loc ); + HeapRecord* rec = recordFor( loc ); char* root = rec->data(); // All updates were in place. Apply them via durability and writing pointer. @@ -257,7 +255,7 @@ namespace mongo { Records::iterator it = inclusive ? _records.lower_bound(end) : _records.upper_bound(end); while(it != _records.end()) { - _dataSize -= reinterpret_cast<Record*>(it->second.get())->netLength(); + _dataSize -= reinterpret_cast<HeapRecord*>(it->second.get())->netLength(); _records.erase(it++); } } @@ -282,7 +280,7 @@ namespace mongo { results->valid = true; if (scanData && full) { for (Records::const_iterator it = _records.begin(); it != _records.end(); ++it) { - Record* rec = reinterpret_cast<Record*>(it->second.get()); + HeapRecord* rec = reinterpret_cast<HeapRecord*>(it->second.get()); size_t dataSize; const Status status = adaptor->validate(rec->toRecordData(), &dataSize); if (!status.isOK()) { @@ -323,7 +321,7 @@ namespace mongo { int64_t HeapRecordStore::storageSize(BSONObjBuilder* extraInfo, int infoLevel) const { // Note: not making use of extraInfo or infoLevel since we don't have extents - const int64_t recordOverhead = numRecords() * Record::HeaderSize; + const int64_t recordOverhead = numRecords() * HeapRecord::HeaderSize; return _dataSize + recordOverhead; } diff --git a/src/mongo/db/structure/record_store_heap.h b/src/mongo/db/structure/record_store_heap.h index 16a0a9ecb56..bf3f6329545 100644 --- a/src/mongo/db/structure/record_store_heap.h +++ b/src/mongo/db/structure/record_store_heap.h @@ -119,7 +119,26 @@ namespace mongo { virtual long long numRecords() const { return _records.size(); } protected: - virtual Record* recordFor( const DiskLoc& loc ) const; + class HeapRecord { + public: + enum HeaderSizeValue { HeaderSize = 16 }; + + int lengthWithHeaders() const { return _lengthWithHeaders; } + int& lengthWithHeaders() { return _lengthWithHeaders; } + + const char* data() const { return _data; } + char* data() { return _data; } + + int netLength() const { return _lengthWithHeaders - HeaderSize; } + + RecordData toRecordData() const { return RecordData(_data, netLength()); } + + private: + int _lengthWithHeaders; + char _data[4]; + }; + + virtual HeapRecord* recordFor( const DiskLoc& loc ) const; public: // diff --git a/src/mongo/db/structure/record_store_v1_base.cpp b/src/mongo/db/structure/record_store_v1_base.cpp index 37f80b9a844..ec6c53931a7 100644 --- a/src/mongo/db/structure/record_store_v1_base.cpp +++ b/src/mongo/db/structure/record_store_v1_base.cpp @@ -34,7 +34,7 @@ #include "mongo/db/operation_context.h" #include "mongo/db/storage/extent.h" #include "mongo/db/storage/extent_manager.h" -#include "mongo/db/storage/record.h" +#include "mongo/db/storage/mmap_v1/record.h" #include "mongo/db/structure/record_store_v1_repair_iterator.h" #include "mongo/util/progress_meter.h" #include "mongo/util/timer.h" diff --git a/src/mongo/db/structure/record_store_v1_base.h b/src/mongo/db/structure/record_store_v1_base.h index 081d9256f6a..de65605317f 100644 --- a/src/mongo/db/structure/record_store_v1_base.h +++ b/src/mongo/db/structure/record_store_v1_base.h @@ -35,6 +35,7 @@ namespace mongo { + class DeletedRecord; class DocWriter; class ExtentManager; class Record; diff --git a/src/mongo/db/structure/record_store_v1_capped.cpp b/src/mongo/db/structure/record_store_v1_capped.cpp index 45a11fdee29..681e1d684da 100644 --- a/src/mongo/db/structure/record_store_v1_capped.cpp +++ b/src/mongo/db/structure/record_store_v1_capped.cpp @@ -33,7 +33,7 @@ #include "mongo/db/storage/extent.h" #include "mongo/db/storage/extent_manager.h" #include "mongo/db/operation_context_impl.h" -#include "mongo/db/storage/record.h" +#include "mongo/db/storage/mmap_v1/record.h" #include "mongo/db/structure/record_store_v1_capped_iterator.h" #include "mongo/util/mmap.h" #include "mongo/util/mongoutils/str.h" diff --git a/src/mongo/db/structure/record_store_v1_capped_test.cpp b/src/mongo/db/structure/record_store_v1_capped_test.cpp index d1f4fa709e4..9e61dafa9c7 100644 --- a/src/mongo/db/structure/record_store_v1_capped_test.cpp +++ b/src/mongo/db/structure/record_store_v1_capped_test.cpp @@ -31,7 +31,7 @@ #include "mongo/db/structure/record_store_v1_capped.h" #include "mongo/db/operation_context_noop.h" -#include "mongo/db/storage/record.h" +#include "mongo/db/storage/mmap_v1/record.h" #include "mongo/db/structure/record_store_v1_test_help.h" #include "mongo/unittest/unittest.h" diff --git a/src/mongo/db/structure/record_store_v1_simple.cpp b/src/mongo/db/structure/record_store_v1_simple.cpp index 4a7f84bf2b1..9218a5cd42b 100644 --- a/src/mongo/db/structure/record_store_v1_simple.cpp +++ b/src/mongo/db/structure/record_store_v1_simple.cpp @@ -38,7 +38,7 @@ #include "mongo/db/commands/server_status_metric.h" #include "mongo/db/storage/extent.h" #include "mongo/db/storage/extent_manager.h" -#include "mongo/db/storage/record.h" +#include "mongo/db/storage/mmap_v1/record.h" #include "mongo/db/operation_context.h" #include "mongo/db/structure/record_store_v1_simple_iterator.h" #include "mongo/util/log.h" diff --git a/src/mongo/db/structure/record_store_v1_simple_test.cpp b/src/mongo/db/structure/record_store_v1_simple_test.cpp index 048688d0d8d..3f7abdc069e 100644 --- a/src/mongo/db/structure/record_store_v1_simple_test.cpp +++ b/src/mongo/db/structure/record_store_v1_simple_test.cpp @@ -31,7 +31,7 @@ #include "mongo/db/structure/record_store_v1_simple.h" #include "mongo/db/operation_context_noop.h" -#include "mongo/db/storage/record.h" +#include "mongo/db/storage/mmap_v1/record.h" #include "mongo/db/structure/record_store_v1_test_help.h" #include "mongo/unittest/unittest.h" diff --git a/src/mongo/db/structure/record_store_v1_test_help.cpp b/src/mongo/db/structure/record_store_v1_test_help.cpp index 251c930fdcd..d166a405387 100644 --- a/src/mongo/db/structure/record_store_v1_test_help.cpp +++ b/src/mongo/db/structure/record_store_v1_test_help.cpp @@ -36,7 +36,7 @@ #include <vector> #include "mongo/db/storage/extent.h" -#include "mongo/db/storage/record.h" +#include "mongo/db/storage/mmap_v1/record.h" #include "mongo/unittest/unittest.h" namespace mongo { |