BSONObj KVCatalog::_findEntry(OperationContext* opCtx, StringData ns, RecordId* out) const { std::unique_ptr<Lock::ResourceLock> rLk; if (!_isRsThreadSafe && opCtx->lockState()) { rLk.reset(new Lock::ResourceLock(opCtx->lockState(), resourceIdCatalogMetadata, MODE_S)); } RecordId dl; { stdx::lock_guard<stdx::mutex> lk(_identsLock); NSToIdentMap::const_iterator it = _idents.find(ns.toString()); invariant(it != _idents.end()); dl = it->second.storedLoc; } LOG(1) << "looking up metadata for: " << ns << " @ " << dl; RecordData data; if (!_rs->findRecord(opCtx, dl, &data)) { // since the in memory meta data isn't managed with mvcc // its possible for different transactions to see slightly // different things, which is ok via the locking above. return BSONObj(); } if (out) *out = dl; return data.releaseToBson().getOwned(); }
bool Collection::findDoc(OperationContext* txn, const RecordId& loc, BSONObj* out) const { RecordData rd; if ( !_recordStore->findRecord( txn, loc, &rd ) ) return false; *out = rd.releaseToBson(); return true; }
Status Collection::aboutToDeleteCapped(OperationContext* txn, const RecordId& loc, RecordData data) { /* check if any cursors point to us. if so, advance them. */ _cursorManager.invalidateDocument(txn, loc, INVALIDATION_DELETION); BSONObj doc = data.releaseToBson(); _indexCatalog.unindexRecord(txn, doc, loc, false); return Status::OK(); }
bool Collection::findDoc(OperationContext* txn, const RecordId& loc, Snapshotted<BSONObj>* out) const { dassert(txn->lockState()->isCollectionLockedForMode(ns().toString(), MODE_IS)); RecordData rd; if (!_recordStore->findRecord(txn, loc, &rd)) return false; *out = Snapshotted<BSONObj>(txn->recoveryUnit()->getSnapshotId(), rd.releaseToBson()); return true; }
CollectionOptions MMAPV1DatabaseCatalogEntry::getCollectionOptions(OperationContext* txn, RecordId rid) const { CollectionOptions options; if (rid.isNull()) { return options; } RecordStoreV1Base* rs = _getNamespaceRecordStore(); invariant(rs); RecordData data; invariant(rs->findRecord(txn, rid, &data)); if (data.releaseToBson()["options"].isABSONObj()) { Status status = options.parse(data.releaseToBson()["options"].Obj()); fassert(18523, status); } return options; }
BSONObj KVCatalog::_findEntry(OperationContext* opCtx, StringData ns, RecordId* out) const { RecordId dl; { stdx::lock_guard<stdx::mutex> lk(_identsLock); NSToIdentMap::const_iterator it = _idents.find(ns.toString()); invariant(it != _idents.end(), str::stream() << "Did not find collection. Ns: " << ns); dl = it->second.storedLoc; } LOG(3) << "looking up metadata for: " << ns << " @ " << dl; RecordData data; if (!_rs->findRecord(opCtx, dl, &data)) { // since the in memory meta data isn't managed with mvcc // its possible for different transactions to see slightly // different things, which is ok via the locking above. return BSONObj(); } if (out) *out = dl; return data.releaseToBson().getOwned(); }