/** * data and len must be the arguments from RecordStore::insert() on an oplog collection. */ StatusWith<RecordId> extractKey(const char* data, int len) { DEV invariant(validateBSON(data, len).isOK()); const BSONObj obj(data); const BSONElement elem = obj["ts"]; if (elem.eoo()) return StatusWith<RecordId>(ErrorCodes::BadValue, "no ts field"); if (elem.type() != bsonTimestamp) return StatusWith<RecordId>(ErrorCodes::BadValue, "ts must be a Timestamp"); return keyForOptime(elem.timestamp()); }
/** * data and len must be the arguments from RecordStore::insert() on an oplog collection. */ StatusWith<RecordId> extractKey(const char* data, int len) { // Use the latest BSON validation version. Oplog entries are allowed to contain decimal data // even if decimal is disabled. DEV invariant(validateBSON(data, len, BSONVersion::kLatest).isOK()); const BSONObj obj(data); const BSONElement elem = obj["ts"]; if (elem.eoo()) return StatusWith<RecordId>(ErrorCodes::BadValue, "no ts field"); if (elem.type() != bsonTimestamp) return StatusWith<RecordId>(ErrorCodes::BadValue, "ts must be a Timestamp"); return keyForOptime(elem.timestamp()); }