|
30 | 30 | #include "mongo/db/auth/action_set.h" |
31 | 31 | #include "mongo/db/auth/action_type.h" |
32 | 32 | #include "mongo/db/auth/privilege.h" |
33 | | -#include "mongo/db/structure/btree/btree.h" |
| 33 | +#include "mongo/db/catalog/index_catalog.h" |
| 34 | +#include "mongo/db/catalog/index_catalog_entry.h" |
34 | 35 | #include "mongo/db/commands.h" |
35 | 36 | #include "mongo/db/db.h" |
36 | | -#include "mongo/db/structure/catalog/index_details.h" |
37 | 37 | #include "mongo/db/jsobj.h" |
| 38 | +#include "mongo/db/index/index_descriptor.h" |
38 | 39 | #include "mongo/db/kill_current_op.h" |
39 | | -#include "mongo/db/structure/catalog/namespace_details.h" |
| 40 | +#include "mongo/db/structure/btree/btree.h" |
40 | 41 | #include "mongo/util/descriptive_stats.h" |
41 | 42 |
|
42 | 43 | namespace mongo { |
@@ -353,41 +354,35 @@ namespace mongo { |
353 | 354 | * |
354 | 355 | * @return true on success, false otherwise |
355 | 356 | */ |
356 | | - bool runInternal(const NamespaceDetails* nsd, IndexStatsParams params, string& errmsg, |
| 357 | + bool runInternal(const Collection* collection, IndexStatsParams params, string& errmsg, |
357 | 358 | BSONObjBuilder& result) { |
358 | 359 |
|
359 | | - const IndexDetails* details = NULL; |
| 360 | + const IndexCatalog* indexCatalog = collection->getIndexCatalog(); |
360 | 361 |
|
361 | | - // casting away const, we are not going to modify NamespaceDetails |
362 | | - // but ii() is not marked const, see SERVER-7619 |
363 | | - for (NamespaceDetails::IndexIterator it = const_cast<NamespaceDetails*>(nsd)->ii(); |
364 | | - it.more();) { |
365 | | - IndexDetails& cur = it.next(); |
366 | | - if (cur.indexName() == params.indexName) details = &cur; |
367 | | - } |
| 362 | + IndexDescriptor* descriptor = indexCatalog->findIndexByName( params.indexName ); |
368 | 363 |
|
369 | | - if (details == NULL) { |
| 364 | + if (descriptor == NULL) { |
370 | 365 | errmsg = "the requested index does not exist"; |
371 | 366 | return false; |
372 | 367 | } |
373 | 368 |
|
374 | | - result << "index" << details->indexName() |
375 | | - << "version" << details->version() |
376 | | - << "isIdIndex" << details->isIdIndex() |
377 | | - << "keyPattern" << details->keyPattern() |
378 | | - << "storageNs" << details->indexNamespace(); |
| 369 | + result << "index" << descriptor->indexName() |
| 370 | + << "version" << descriptor->version() |
| 371 | + << "isIdIndex" << descriptor->isIdIndex() |
| 372 | + << "keyPattern" << descriptor->keyPattern() |
| 373 | + << "storageNs" << descriptor->indexNamespace(); |
379 | 374 |
|
380 | 375 | scoped_ptr<BtreeInspector> inspector(NULL); |
381 | | - switch (details->version()) { |
| 376 | + switch (descriptor->version()) { |
382 | 377 | case 1: inspector.reset(new BtreeInspectorV1(params.expandNodes)); break; |
383 | 378 | case 0: inspector.reset(new BtreeInspectorV0(params.expandNodes)); break; |
384 | 379 | default: |
385 | | - errmsg = str::stream() << "index version " << details->version() << " is " |
| 380 | + errmsg = str::stream() << "index version " << descriptor->version() << " is " |
386 | 381 | << "not supported"; |
387 | 382 | return false; |
388 | 383 | } |
389 | 384 |
|
390 | | - inspector->inspect(details->head); |
| 385 | + inspector->inspect( indexCatalog->getEntry( descriptor )->head() ); |
391 | 386 |
|
392 | 387 | inspector->stats().appendTo(result); |
393 | 388 |
|
@@ -498,12 +493,13 @@ namespace mongo { |
498 | 493 | bool run(const string& dbname, BSONObj& cmdObj, int, string& errmsg, |
499 | 494 | BSONObjBuilder& result, bool fromRepl) { |
500 | 495 |
|
501 | | - string ns = dbname + "." + cmdObj.firstElement().valuestrsafe(); |
502 | | - const NamespaceDetails* nsd = nsdetails(ns); |
| 496 | + NamespaceString nss( dbname, cmdObj.firstElement().valuestrsafe() ); |
503 | 497 | if (!serverGlobalParams.quiet) { |
504 | | - MONGO_TLOG(0) << "CMD: indexStats " << ns << endl; |
| 498 | + MONGO_TLOG(0) << "CMD: indexStats " << nss; |
505 | 499 | } |
506 | | - if (!nsd) { |
| 500 | + |
| 501 | + const Collection* collection = cc().database()->getCollection( nss.ns() ); |
| 502 | + if (!collection) { |
507 | 503 | errmsg = "ns not found"; |
508 | 504 | return false; |
509 | 505 | } |
@@ -535,7 +531,7 @@ namespace mongo { |
535 | 531 | } |
536 | 532 |
|
537 | 533 | BSONObjBuilder resultBuilder; |
538 | | - if (!runInternal(nsd, params, errmsg, resultBuilder)) |
| 534 | + if (!runInternal(collection, params, errmsg, resultBuilder)) |
539 | 535 | return false; |
540 | 536 | result.appendElements(resultBuilder.obj()); |
541 | 537 | return true; |
|
0 commit comments