| 195 | } |
| 196 | |
| 197 | ExtMsgQuery::ExtMsgQuery(ExtMsgHeader* header, const uint8_t* body) : header(header) { |
| 198 | const uint8_t* ptr = body; |
| 199 | const uint8_t* eom = (uint8_t*)header + header->messageLength; |
| 200 | |
| 201 | flags = *(int32_t*)ptr; |
| 202 | ptr += sizeof(int32_t); |
| 203 | |
| 204 | const char* collName = (const char*)ptr; |
| 205 | ptr += strlen(collName) + 1; |
| 206 | |
| 207 | numberToSkip = *(int32_t*)ptr; |
| 208 | ptr += sizeof(int32_t); |
| 209 | numberToReturn = *(int32_t*)ptr; |
| 210 | ptr += sizeof(int32_t); |
| 211 | |
| 212 | query = bson::BSONObj((const char*)ptr); |
| 213 | ptr += query.objsize(); |
| 214 | |
| 215 | if (ptr != eom) { |
| 216 | returnFieldSelector = bson::BSONObj((const char*)ptr); |
| 217 | ptr += returnFieldSelector.objsize(); |
| 218 | } |
| 219 | |
| 220 | ns = getDBCollectionPair(collName, std::make_pair(DocLayerConstants::QUERY_FIELD, query.toString())); |
| 221 | if (ns.second == "$cmd") { |
| 222 | isCmd = true; |
| 223 | // Mark it empty for now, command would be responsible for setting collection name later. |
| 224 | ns.second = ""; |
| 225 | } else { |
| 226 | isCmd = false; |
| 227 | } |
| 228 | |
| 229 | /* We should have consumed all the bytes specified by header */ |
| 230 | ASSERT(ptr == eom); |
| 231 | } |
| 232 | |
| 233 | std::string ExtMsgQuery::toString() { |
| 234 | return format("QUERY: %s, collection=%s, flags=%d, numberToSkip=%d, numberToReturn=%d (%s)", |
nothing calls this directly
no test coverage detected