本文整理汇总了C++中bsoncollectioncatalogentry::MetaData::findIndexOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ MetaData::findIndexOffset方法的具体用法?C++ MetaData::findIndexOffset怎么用?C++ MetaData::findIndexOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bsoncollectioncatalogentry::MetaData
的用法示例。
在下文中一共展示了MetaData::findIndexOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: opCtx
TEST_F(KVCatalogTest, RestartForPrefixes) {
storageGlobalParams.groupCollections = true;
ON_BLOCK_EXIT([&] { storageGlobalParams.groupCollections = false; });
KVPrefix abCollPrefix = KVPrefix::getNextPrefix(NamespaceString("a.b"));
KVPrefix fooIndexPrefix = KVPrefix::getNextPrefix(NamespaceString("a.b"));
unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create());
KVEngine* engine = helper->getEngine();
{
unique_ptr<RecordStore> rs;
unique_ptr<KVCatalog> catalog;
{
MyOperationContext opCtx(engine);
WriteUnitOfWork uow(&opCtx);
ASSERT_OK(engine->createRecordStore(&opCtx, "catalog", "catalog", CollectionOptions()));
rs = engine->getRecordStore(&opCtx, "catalog", "catalog", CollectionOptions());
catalog.reset(new KVCatalog(rs.get(), false, false, nullptr));
uow.commit();
}
{
MyOperationContext opCtx(engine);
WriteUnitOfWork uow(&opCtx);
ASSERT_OK(newCollection(
&opCtx, NamespaceString("a.b"), CollectionOptions(), abCollPrefix, catalog.get()));
ASSERT_NOT_EQUALS("a.b", catalog->getCollectionIdent("a.b"));
ASSERT_TRUE(catalog->isUserDataIdent(catalog->getCollectionIdent("a.b")));
uow.commit();
}
{
MyOperationContext opCtx(engine);
WriteUnitOfWork uow(&opCtx);
BSONCollectionCatalogEntry::MetaData md;
md.ns = "a.b";
BSONCollectionCatalogEntry::IndexMetaData imd;
imd.spec = BSON("name"
<< "foo");
imd.ready = false;
imd.head = RecordId();
imd.multikey = false;
imd.prefix = fooIndexPrefix;
imd.isBackgroundSecondaryBuild = false;
md.indexes.push_back(imd);
md.prefix = abCollPrefix;
catalog->putMetaData(&opCtx, "a.b", md);
uow.commit();
}
}
engine = helper->restartEngine();
{
MyOperationContext opCtx(engine);
WriteUnitOfWork uow(&opCtx);
unique_ptr<RecordStore> rs =
engine->getRecordStore(&opCtx, "catalog", "catalog", CollectionOptions());
unique_ptr<KVCatalog> catalog =
stdx::make_unique<KVCatalog>(rs.get(), false, false, nullptr);
catalog->init(&opCtx);
const BSONCollectionCatalogEntry::MetaData md = catalog->getMetaData(&opCtx, "a.b");
ASSERT_EQ("a.b", md.ns);
ASSERT_EQ(abCollPrefix, md.prefix);
ASSERT_EQ(fooIndexPrefix, md.indexes[md.findIndexOffset("foo")].prefix);
}
}