diff options
author | David Storch <david.storch@10gen.com> | 2016-07-15 18:15:12 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2016-07-19 22:35:21 -0400 |
commit | 7e986cc77f121e3af9a5f1217e89913745fc07f9 (patch) | |
tree | e29c4ec325199937b2723a500a462e6c125616ea /src/mongo/db/pipeline/value.cpp | |
parent | 0b32158c9cb44b31078ca923ef5c8fff755c952a (diff) | |
download | mongo-7e986cc77f121e3af9a5f1217e89913745fc07f9.tar.gz |
SERVER-23990 add ValueComparator::Hasher for collation-aware Value hashing
Diffstat (limited to 'src/mongo/db/pipeline/value.cpp')
-rw-r--r-- | src/mongo/db/pipeline/value.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/mongo/db/pipeline/value.cpp b/src/mongo/db/pipeline/value.cpp index d5e6db63d6b..860c4269ba7 100644 --- a/src/mongo/db/pipeline/value.cpp +++ b/src/mongo/db/pipeline/value.cpp @@ -813,7 +813,8 @@ int Value::compare(const Value& rL, verify(false); } -void Value::hash_combine(size_t& seed) const { +void Value::hash_combine(size_t& seed, + const StringData::ComparatorInterface* stringComparator) const { BSONType type = getType(); boost::hash_combine(seed, canonicalizeBSONType(type)); @@ -881,21 +882,30 @@ void Value::hash_combine(size_t& seed) const { break; case Code: - case Symbol: - case String: { + case Symbol: { StringData sd = getStringData(); MurmurHash3_x86_32(sd.rawData(), sd.size(), seed, &seed); break; } + case String: { + StringData sd = getStringData(); + if (stringComparator) { + stringComparator->hash_combine(seed, sd); + } else { + MurmurHash3_x86_32(sd.rawData(), sd.size(), seed, &seed); + } + break; + } + case Object: - getDocument().hash_combine(seed); + getDocument().hash_combine(seed, stringComparator); break; case Array: { const vector<Value>& vec = getArray(); for (size_t i = 0; i < vec.size(); i++) - vec[i].hash_combine(seed); + vec[i].hash_combine(seed, stringComparator); break; } |