diff options
author | David Storch <david.storch@10gen.com> | 2016-12-07 10:36:41 -0500 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2016-12-08 13:52:54 -0500 |
commit | 516bd8ab5eb1f2f0a377d5b4cb3efc78a259018d (patch) | |
tree | f1417723eca957306fef4c8ff5340e6740e33b5a | |
parent | e4113518e7b0f9dcdfe582d91f4f00dcc0589661 (diff) | |
download | mongo-516bd8ab5eb1f2f0a377d5b4cb3efc78a259018d.tar.gz |
SERVER-27300 delete dead function shouldUseCollationIndexKey()
(cherry picked from commit d5024d5e0ca6cbb883a4ec65c5c76614bbdbbd53)
-rw-r--r-- | src/mongo/db/query/collation/collation_index_key.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/query/collation/collation_index_key.h | 10 | ||||
-rw-r--r-- | src/mongo/db/query/collation/collation_index_key_test.cpp | 28 |
3 files changed, 12 insertions, 33 deletions
diff --git a/src/mongo/db/query/collation/collation_index_key.cpp b/src/mongo/db/query/collation/collation_index_key.cpp index 98410e0dd87..edd8612bcb5 100644 --- a/src/mongo/db/query/collation/collation_index_key.cpp +++ b/src/mongo/db/query/collation/collation_index_key.cpp @@ -137,13 +137,6 @@ void translate(BSONObj obj, const CollatorInterface* collator, BufBuilder* out) } } -// TODO SERVER-24674: We may want to check that objects and arrays actually do contain strings -// before returning true. -bool CollationIndexKey::shouldUseCollationIndexKey(BSONElement elt, - const CollatorInterface* collator) { - return collator && isCollatableType(elt.type()); -} - void CollationIndexKey::collationAwareIndexKeyAppend(BSONElement elt, const CollatorInterface* collator, BSONObjBuilder* out) { diff --git a/src/mongo/db/query/collation/collation_index_key.h b/src/mongo/db/query/collation/collation_index_key.h index a78ecfcdbf3..dc506b68702 100644 --- a/src/mongo/db/query/collation/collation_index_key.h +++ b/src/mongo/db/query/collation/collation_index_key.h @@ -43,21 +43,13 @@ class CollatorInterface; class CollationIndexKey { public: /** - * Returns true if type is affected in comparison or sort order by collation. + * Returns true if type can be affected in comparison or sort order by collation. */ static bool isCollatableType(BSONType type) { - // TODO SERVER-24674 We may want to replace calls to this to shouldUseCollationIndexKey. return type == BSONType::String || type == BSONType::Object || type == BSONType::Array; } /** - * Returns true if the index key for 'elt' may contain a comparison key generated by 'collator'. - * - * This is the case when 'elt' is a String, Array, or Object. - */ - static bool shouldUseCollationIndexKey(BSONElement elt, const CollatorInterface* collator); - - /** * Appends 'elt' to 'out' with an empty field name, converting strings to comparison keys * generated by 'collator' if necessary. */ diff --git a/src/mongo/db/query/collation/collation_index_key_test.cpp b/src/mongo/db/query/collation/collation_index_key_test.cpp index 0b92c5d7cae..9630755c8ec 100644 --- a/src/mongo/db/query/collation/collation_index_key_test.cpp +++ b/src/mongo/db/query/collation/collation_index_key_test.cpp @@ -39,31 +39,25 @@ namespace { using namespace mongo; -TEST(CollationIndexKeyTest, ShouldUseCollationIndexKeyFalseWithNullCollator) { +TEST(CollationIndexKeyTest, IsCollatableTypeShouldBeTrueForString) { BSONObj obj = BSON("foo" << "string"); - ASSERT_FALSE(CollationIndexKey::shouldUseCollationIndexKey(obj.firstElement(), nullptr)); + ASSERT_TRUE(CollationIndexKey::isCollatableType(obj.firstElement().type())); } -TEST(CollationIndexKeyTest, ShouldUseCollationIndexKeyTrueWithObjectElement) { - CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString); - BSONObj obj = BSON("foo" << BSON("bar" - << "string")); - ASSERT_TRUE(CollationIndexKey::shouldUseCollationIndexKey(obj.firstElement(), &collator)); +TEST(CollationIndexKeyTest, IsCollatableTypeShouldBeTrueForObject) { + BSONObj obj = BSON("foo" << BSON("bar" << 99)); + ASSERT_TRUE(CollationIndexKey::isCollatableType(obj.firstElement().type())); } -TEST(CollationIndexKeyTest, ShouldUseCollationIndexKeyTrueWithArrayElement) { - CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString); - BSONObj obj = BSON("foo" << BSON_ARRAY("one" - << "two")); - ASSERT_TRUE(CollationIndexKey::shouldUseCollationIndexKey(obj.firstElement(), &collator)); +TEST(CollationIndexKeyTest, IsCollatableTypeShouldBeTrueForArray) { + BSONObj obj = BSON("foo" << BSON_ARRAY(98 << 99)); + ASSERT_TRUE(CollationIndexKey::isCollatableType(obj.firstElement().type())); } -TEST(CollationIndexKeyTest, ShouldUseCollationIndexKeyTrueWithStringElement) { - CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString); - BSONObj obj = BSON("foo" - << "string"); - ASSERT_TRUE(CollationIndexKey::shouldUseCollationIndexKey(obj.firstElement(), &collator)); +TEST(CollationIndexKeyTest, IsCollatableTypeShouldBeFalseForNumber) { + BSONObj obj = BSON("foo" << 99); + ASSERT_FALSE(CollationIndexKey::isCollatableType(obj.firstElement().type())); } TEST(CollationIndexKeyTest, CollationAwareAppendCorrectlyAppendsElementWithNullCollator) { |