diff options
author | Greg Studer <greg@10gen.com> | 2014-01-03 15:19:30 -0500 |
---|---|---|
committer | Greg Studer <greg@10gen.com> | 2014-01-07 13:37:09 -0500 |
commit | edcfd827189045b8b64d38cf803d7555cc04132d (patch) | |
tree | 9f8ad63a34530ecebd98c41719a1b55120cd7c83 /src/mongo/s | |
parent | 133d28b56d04e67004aac22a18f068d70624393d (diff) | |
download | mongo-edcfd827189045b8b64d38cf803d7555cc04132d.tar.gz |
SERVER-12139 allow BSONElement parsing for single-pass parse speedup
Diffstat (limited to 'src/mongo/s')
-rw-r--r-- | src/mongo/s/write_ops/batched_insert_request.cpp | 67 |
1 files changed, 42 insertions, 25 deletions
diff --git a/src/mongo/s/write_ops/batched_insert_request.cpp b/src/mongo/s/write_ops/batched_insert_request.cpp index 193dc563552..0b62c63d156 100644 --- a/src/mongo/s/write_ops/batched_insert_request.cpp +++ b/src/mongo/s/write_ops/batched_insert_request.cpp @@ -99,31 +99,48 @@ namespace mongo { std::string dummy; if (!errMsg) errMsg = &dummy; - FieldParser::FieldState fieldState; - fieldState = FieldParser::extract(source, collName, &_collName, errMsg); - if (fieldState == FieldParser::FIELD_INVALID) return false; - _isCollNameSet = fieldState == FieldParser::FIELD_SET; - - fieldState = FieldParser::extract(source, documents, &_documents, errMsg); - if (fieldState == FieldParser::FIELD_INVALID) return false; - _isDocumentsSet = fieldState == FieldParser::FIELD_SET; - - fieldState = FieldParser::extract(source, writeConcern, &_writeConcern, errMsg); - if (fieldState == FieldParser::FIELD_INVALID) return false; - _isWriteConcernSet = fieldState == FieldParser::FIELD_SET; - - fieldState = FieldParser::extract(source, ordered, &_ordered, errMsg); - if (fieldState == FieldParser::FIELD_INVALID) return false; - _isOrderedSet = fieldState == FieldParser::FIELD_SET; - - BSONObj metadataObj; - fieldState = FieldParser::extract(source, metadata, &metadataObj, errMsg); - if (fieldState == FieldParser::FIELD_INVALID) return false; - - if (!metadataObj.isEmpty()) { - _metadata.reset(new BatchedRequestMetadata()); - if (!_metadata->parseBSON(metadataObj, errMsg)) { - return false; + BSONObjIterator sourceIt(source); + + while ( sourceIt.more() ) { + + BSONElement sourceEl = sourceIt.next(); + + if ( collName() == sourceEl.fieldName() ) { + FieldParser::FieldState fieldState = + FieldParser::extract( sourceEl, collName, &_collName, errMsg ); + if (fieldState == FieldParser::FIELD_INVALID) return false; + _isCollNameSet = fieldState == FieldParser::FIELD_SET; + } + else if ( documents() == sourceEl.fieldName() ) { + FieldParser::FieldState fieldState = + FieldParser::extract( sourceEl, documents, &_documents, errMsg ); + if ( fieldState == FieldParser::FIELD_INVALID ) return false; + _isDocumentsSet = fieldState == FieldParser::FIELD_SET; + } + else if ( writeConcern() == sourceEl.fieldName() ) { + FieldParser::FieldState fieldState = + FieldParser::extract(sourceEl, writeConcern, &_writeConcern, errMsg); + if (fieldState == FieldParser::FIELD_INVALID) return false; + _isWriteConcernSet = fieldState == FieldParser::FIELD_SET; + } + else if ( ordered() == sourceEl.fieldName() ) { + FieldParser::FieldState fieldState = + FieldParser::extract(sourceEl, ordered, &_ordered, errMsg); + if (fieldState == FieldParser::FIELD_INVALID) return false; + _isOrderedSet = fieldState == FieldParser::FIELD_SET; + } + else if ( metadata() == sourceEl.fieldName() ) { + BSONObj metadataObj; + FieldParser::FieldState fieldState = + FieldParser::extract(sourceEl, metadata, &metadataObj, errMsg); + if (fieldState == FieldParser::FIELD_INVALID) return false; + + if (!metadataObj.isEmpty()) { + _metadata.reset(new BatchedRequestMetadata()); + if (!_metadata->parseBSON(metadataObj, errMsg)) { + return false; + } + } } } |