diff options
author | Geir Storli <geirst@verizonmedia.com> | 2019-08-16 13:45:52 +0000 |
---|---|---|
committer | Geir Storli <geirst@verizonmedia.com> | 2019-08-19 07:38:03 +0000 |
commit | d84b3bb9537eac5b0b0e2bb09061ae3d700d7199 (patch) | |
tree | 97fd1611e8adb6ffbee3426a147438482e7e38ba /searchlib/src/tests/attribute/attribute_test.cpp | |
parent | c3ece362865b788a6fb9a86718cb34ec9af609aa (diff) |
Remove "enable enumerated save" flag from attribute vectors as this should be always on.
For production code this has been on for several years already.
Diffstat (limited to 'searchlib/src/tests/attribute/attribute_test.cpp')
-rw-r--r-- | searchlib/src/tests/attribute/attribute_test.cpp | 69 |
1 files changed, 14 insertions, 55 deletions
diff --git a/searchlib/src/tests/attribute/attribute_test.cpp b/searchlib/src/tests/attribute/attribute_test.cpp index c71e51b2040..8259d5ba0f8 100644 --- a/searchlib/src/tests/attribute/attribute_test.cpp +++ b/searchlib/src/tests/attribute/attribute_test.cpp @@ -107,9 +107,8 @@ statSize(const AttributeVector &a) bool preciseEstimatedSize(const AttributeVector &a) { - if (a.getBasicType() == BasicType::STRING && - EXPECT_TRUE(a.hasEnum()) && !a.getEnumeratedSave()) { - return false; // Using average of string lens, can be somewhat off + if (a.getBasicType() == BasicType::STRING) { + return false; // Using average of string lengths, can be somewhat off } return true; } @@ -217,7 +216,7 @@ private: template <typename VectorType, typename BufferType> void - testCompactLidSpace(const Config &config, bool fs, bool es); + testCompactLidSpace(const Config &config, bool fast_search); template <typename VectorType, typename BufferType> void @@ -399,7 +398,7 @@ void AttributeTest::compare(VectorType & a, VectorType & b) EXPECT_EQUAL(static_cast<const AttributeVector &>(a).get(i, av, asz), static_cast<uint32_t>(a.getValueCount(i))); EXPECT_EQUAL(static_cast<const AttributeVector &>(b).get(i, bv, bsz), static_cast<uint32_t>(b.getValueCount(i))); for(size_t j(0), k(std::min(a.getValueCount(i), b.getValueCount(i))); j < k; j++) { - EXPECT_TRUE(av[j] == bv[j]); + EXPECT_EQUAL(av[j], bv[j]); } } delete [] bv; @@ -463,48 +462,13 @@ void AttributeTest::testReload(const AttributePtr & a, const AttributePtr & b, c compare<VectorType, BufferType> (*(static_cast<VectorType *>(a.get())), *(static_cast<VectorType *>(c.get()))); - if (isUnsignedSmallIntAttribute(*a)) + if (isUnsignedSmallIntAttribute(*a)) { return; + } populate(static_cast<VectorType &>(*b.get()), 700); populate(static_cast<VectorType &>(*c.get()), 700); compare<VectorType, BufferType> (*(static_cast<VectorType *>(b.get())), *(static_cast<VectorType *>(c.get()))); - - { - ReadAttributeFile readC(c->getBaseFileName(), c->getConfig()); - WriteAttributeFile writeC(b->getBaseFileName(), b->getConfig(), - DummyFileHeaderContext(), - c->getNumDocs()); - std::unique_ptr<AttributeFile::Record> record(readC.getRecord()); - ASSERT_TRUE(record.get()); - for (size_t i(0), m(c->getNumDocs()); i < m; i++) { - EXPECT_TRUE(readC.read(*record)); - EXPECT_TRUE(writeC.write(*record)); - } - EXPECT_TRUE( ! readC.read(*record)); - } - EXPECT_TRUE( b->load() ); - compare<VectorType, BufferType> - (*(static_cast<VectorType *>(a.get())), - *(static_cast<VectorType *>(b.get()))); - { - ReadAttributeFile readC(c->getBaseFileName(), c->getConfig()); - WriteAttributeFile writeC(b->getBaseFileName(), b->getConfig(), - DummyFileHeaderContext(), - c->getNumDocs()); - readC.enableDirectIO(); - writeC.enableDirectIO(); - std::unique_ptr<AttributeFile::Record> record(readC.getRecord()); - ASSERT_TRUE(record.get()); - for (size_t i(0), m(c->getNumDocs()); i < m; i++) { - EXPECT_TRUE(readC.read(*record)); - EXPECT_TRUE(writeC.write(*record)); - } - EXPECT_TRUE( ! readC.read(*record)); - } - EXPECT_TRUE( b->load() ); - compare<VectorType, BufferType> - (*(static_cast<VectorType *>(a.get())), *(static_cast<VectorType *>(b.get()))); } @@ -1949,28 +1913,24 @@ AttributeTest::testPredicateHeaderTags() template <typename VectorType, typename BufferType> void AttributeTest::testCompactLidSpace(const Config &config, - bool fs, - bool es) + bool fast_search) { uint32_t highDocs = 100; uint32_t trimmedDocs = 30; vespalib::string bts = config.basicType().asString(); vespalib::string cts = config.collectionType().asString(); - vespalib::string fas = fs ? "-fs" : ""; - vespalib::string ess = es ? "-es" : ""; + vespalib::string fas = fast_search ? "-fs" : ""; Config cfg = config; - cfg.setFastSearch(fs); + cfg.setFastSearch(fast_search); - vespalib::string name = clsDir + "/" + bts + "-" + cts + fas + ess; + vespalib::string name = clsDir + "/" + bts + "-" + cts + fas; LOG(info, "testCompactLidSpace(%s)", name.c_str()); AttributePtr attr = AttributeFactory::createAttribute(name, cfg); auto &v = static_cast<VectorType &>(*attr.get()); - attr->enableEnumeratedSave(es); attr->addDocs(highDocs); populate(v, 17); AttributePtr attr2 = AttributeFactory::createAttribute(name, cfg); auto &v2 = static_cast<VectorType &>(*attr2.get()); - attr2->enableEnumeratedSave(es); attr2->addDocs(trimmedDocs); populate(v2, 17); EXPECT_EQUAL(trimmedDocs, attr2->getNumDocs()); @@ -1999,13 +1959,12 @@ template <typename VectorType, typename BufferType> void AttributeTest::testCompactLidSpace(const Config &config) { - testCompactLidSpace<VectorType, BufferType>(config, false, false); - testCompactLidSpace<VectorType, BufferType>(config, false, true); + testCompactLidSpace<VectorType, BufferType>(config, false); bool smallUInt = isUnsignedSmallIntAttribute(config.basicType().type()); - if (smallUInt) + if (smallUInt) { return; - testCompactLidSpace<VectorType, BufferType>(config, true, false); - testCompactLidSpace<VectorType, BufferType>(config, true, true); + } + testCompactLidSpace<VectorType, BufferType>(config, true); } void |