|
ClusteredIndexSpec is defined by the idl clustered_collections_options.idl:
ClusteredIndexSpec:
|
description: "The specifications for a given clusteredIndex"
|
strict: true
|
fields:
|
v:
|
description: 'Index spec version'
|
type: safeInt
|
default: 2
|
unstable: false
|
key:
|
description: 'Key to index on'
|
type: object_owned
|
unstable: false
|
name:
|
description: 'Descriptive name for the index'
|
type: string
|
optional: true
|
unstable: false
|
unique:
|
type: safeBool
|
unstable: false
|
There are two getter methods that get defined for the indexSpec in build/opt/mongo/db/catalog/clustered_collection_options_gen.h:
const mongo::ClusteredIndexSpec& getIndexSpec() const { return _indexSpec; }
|
mongo::ClusteredIndexSpec& getIndexSpec() { return _indexSpec; }
|
When I try to extract the name, the following code prints garbage:
auto nameOptional = collection->getClusteredInfo()->getIndexSpec().getName();
|
if (nameOptional) {
|
logd("--XYZ-- ------ {}", *nameOptional);
|
}
|
Whereas the following gives me the correct name:
auto indexSpec = collection->getClusteredInfo()->getIndexSpec();
|
auto nameOptional = indexSpec.getName();
|
if (nameOptional) {
|
logd("--XYZ-- ------ {}", *nameOptional);
|
}
|
I don't understand why, and it seems like a bug.
|