diff options
author | Eliot Horowitz <eliot@10gen.com> | 2014-09-09 09:48:49 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2014-09-09 09:48:49 -0400 |
commit | 5395a12bf56f059f36a6216f3e33f557229df996 (patch) | |
tree | 2499a1bf60c8085cfa06ad074d65082ffd8f90dd | |
parent | 0288d14d9db98039202f7ce642f6d2d48f31db0d (diff) | |
download | mongo-5395a12bf56f059f36a6216f3e33f557229df996.tar.gz |
SERVER-13635: BSONCollectionCatalogEntry supports options
-rw-r--r-- | src/mongo/db/storage/bson_collection_catalog_entry.cpp | 27 | ||||
-rw-r--r-- | src/mongo/db/storage/bson_collection_catalog_entry.h | 3 |
2 files changed, 28 insertions, 2 deletions
diff --git a/src/mongo/db/storage/bson_collection_catalog_entry.cpp b/src/mongo/db/storage/bson_collection_catalog_entry.cpp index e9913f7934a..0259efb197b 100644 --- a/src/mongo/db/storage/bson_collection_catalog_entry.cpp +++ b/src/mongo/db/storage/bson_collection_catalog_entry.cpp @@ -37,8 +37,8 @@ namespace mongo { } CollectionOptions BSONCollectionCatalogEntry::getCollectionOptions( OperationContext* txn ) const { - // TODO: support everything - return CollectionOptions(); + MetaData md = _getMetaData( txn ); + return md.options; } int BSONCollectionCatalogEntry::getTotalIndexCount( OperationContext* txn ) const { @@ -104,6 +104,24 @@ namespace mongo { return md.indexes[offset].ready; } + // -------------------------- + + void BSONCollectionCatalogEntry::IndexMetaData::updateTTLSetting( long long newExpireSeconds ) { + BSONObjBuilder b; + for ( BSONObjIterator bi( spec ); bi.more(); ) { + BSONElement e = bi.next(); + if ( e.fieldNameStringData() == "expireAfterSeconds" ) { + continue; + } + b.append( e ); + } + + b.append( "expireAfterSeconds", newExpireSeconds ); + spec = b.obj(); + } + + // -------------------------- + int BSONCollectionCatalogEntry::MetaData::findIndexOffset( const StringData& name ) const { for ( unsigned i = 0; i < indexes.size(); i++ ) if ( indexes[i].spec["name"].String() == name ) @@ -125,6 +143,7 @@ namespace mongo { BSONObj BSONCollectionCatalogEntry::MetaData::toBSON() const { BSONObjBuilder b; b.append( "ns", ns ); + b.append( "options", options.toBSON() ); { BSONArrayBuilder arr( b.subarrayStart( "indexes" ) ); for ( unsigned i = 0; i < indexes.size(); i++ ) { @@ -144,6 +163,10 @@ namespace mongo { void BSONCollectionCatalogEntry::MetaData::parse( const BSONObj& obj ) { ns = obj["ns"].valuestrsafe(); + if ( obj["options"].isABSONObj() ) { + options.parse( obj["options"].Obj() ); + } + BSONElement e = obj["indexes"]; if ( e.isABSONObj() ) { std::vector<BSONElement> entries = e.Array(); diff --git a/src/mongo/db/storage/bson_collection_catalog_entry.h b/src/mongo/db/storage/bson_collection_catalog_entry.h index 85fa1f887d4..9b0645d6849 100644 --- a/src/mongo/db/storage/bson_collection_catalog_entry.h +++ b/src/mongo/db/storage/bson_collection_catalog_entry.h @@ -75,6 +75,8 @@ namespace mongo { IndexMetaData( BSONObj s, bool r, DiskLoc h, bool m ) : spec( s ), ready( r ), head( h ), multikey( m ) {} + void updateTTLSetting( long long newExpireSeconds ); + BSONObj spec; bool ready; DiskLoc head; @@ -94,6 +96,7 @@ namespace mongo { bool eraseIndex( const StringData& name ); std::string ns; + CollectionOptions options; std::vector<IndexMetaData> indexes; }; |