diff options
author | Andrew Morrow <acm@10gen.com> | 2013-08-25 10:55:22 -0400 |
---|---|---|
committer | Andrew Morrow <acm@10gen.com> | 2013-09-25 14:21:49 -0400 |
commit | 4616eae3efe8301ac12574bfc7c6d54338b58bd7 (patch) | |
tree | c89a9f2716fdee0a3c11a28ab601ef94fb2d65fa /src/mongo/db/field_ref.h | |
parent | 6faea24a8e6889c7a46c8e1c305cfa9cd430b0e7 (diff) | |
download | mongo-4616eae3efe8301ac12574bfc7c6d54338b58bd7.tar.gz |
SERVER-10159 Re-serialize and cache dotted form in FieldRef on request
Diffstat (limited to 'src/mongo/db/field_ref.h')
-rw-r--r-- | src/mongo/db/field_ref.h | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/mongo/db/field_ref.h b/src/mongo/db/field_ref.h index 681f9873932..06e60c2c165 100644 --- a/src/mongo/db/field_ref.h +++ b/src/mongo/db/field_ref.h @@ -90,7 +90,7 @@ namespace mongo { * Returns a copy of the full dotted field in its current state (i.e., some parts may * have been replaced since the parse() call). */ - std::string dottedField( size_t offset = 0 ) const; + StringData dottedField( size_t offsetFromStart = 0 ) const; /** * Compares the full dotted path represented by this FieldRef to other @@ -117,12 +117,6 @@ namespace mongo { */ size_t numParts() const { return _size; } - /** - * Returns the number of fields parts that were replaced so far. Replacing the same - * fields several times only counts for 1. - */ - size_t numReplaced() const; - private: // Dotted fields are most often not longer than four parts. We use a mixed structure // here that will not require any extra memory allocation when that is the case. And @@ -139,20 +133,29 @@ namespace mongo { */ size_t appendPart(const StringData& part); + /** + * Re-assemble _dotted from components, including any replacements in _replacements, + * and update the StringData components in _fixed and _variable to refer to the parts + * of the new _dotted. This is used to make the storage for the current value of this + * FieldRef contiguous so it can be returned as a StringData from the dottedField + * method above. + */ + void reserialize() const; + // number of field parts stored size_t _size; // first kResevedAhead field components - StringData _fixed[kReserveAhead]; + mutable StringData _fixed[kReserveAhead]; // remaining field components - std::vector<StringData> _variable; + mutable std::vector<StringData> _variable; // cached dotted name - std::string _dotted; + mutable std::string _dotted; // back memory added with the setPart call pointed to by _fized and _variable - std::vector<std::string> _replacements; + mutable std::vector<std::string> _replacements; }; inline bool operator==(const FieldRef& lhs, const FieldRef& rhs) { |