diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-16 17:36:04 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-16 18:06:45 +0000 |
commit | cea11eaf40659b879d143f99eee2f6b78e427761 (patch) | |
tree | 88a81f4697a51d889af52daf1b581eeb3ee6385e /vsm/src | |
parent | fd26131762bf938c033178637604df97076ffcdf (diff) |
Avoid requiring identifiable for FieldValue
Diffstat (limited to 'vsm/src')
-rw-r--r-- | vsm/src/vespa/vsm/searcher/fieldsearcher.cpp | 11 | ||||
-rw-r--r-- | vsm/src/vespa/vsm/vsm/docsumfilter.cpp | 2 | ||||
-rw-r--r-- | vsm/src/vespa/vsm/vsm/flattendocsumwriter.cpp | 7 | ||||
-rw-r--r-- | vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp | 23 |
4 files changed, 20 insertions, 23 deletions
diff --git a/vsm/src/vespa/vsm/searcher/fieldsearcher.cpp b/vsm/src/vespa/vsm/searcher/fieldsearcher.cpp index c587f9eadfb..e69999b160e 100644 --- a/vsm/src/vespa/vsm/searcher/fieldsearcher.cpp +++ b/vsm/src/vespa/vsm/searcher/fieldsearcher.cpp @@ -30,7 +30,7 @@ FieldSearcherBase::FieldSearcherBase() : _qtl(), _qtlFastBuffer(), _qtlFastSize(0), - _qtlFast(NULL) + _qtlFast(nullptr) { } @@ -38,7 +38,7 @@ FieldSearcherBase::FieldSearcherBase(const FieldSearcherBase & org) : _qtl(), _qtlFastBuffer(), _qtlFastSize(0), - _qtlFast(NULL) + _qtlFast(nullptr) { prepare(org._qtl); } @@ -260,8 +260,7 @@ bool FieldSearcher::onSearch(const StorageDocument & doc) bool retval(true); size_t fNo(field()); const StorageDocument::SubDocument & sub = doc.getComplexField(fNo); - if (sub.getFieldValue() != NULL) { - LOG(spam, "onSearch %s : %s", sub.getFieldValue()->getClass().name(), sub.getFieldValue()->toString().c_str()); + if (sub.getFieldValue() != nullptr) { IteratorHandler ih(*this); sub.getFieldValue()->iterateNested(sub.getRange(), ih); } @@ -282,10 +281,10 @@ FieldSearcher::IteratorHandler::onCollectionStart(const Content & c) { const document::FieldValue & fv = c.getValue(); LOG(spam, "onCollectionStart: field value '%s'", fv.toString().c_str()); - if (fv.inherits(document::ArrayFieldValue::classId)) { + if (fv.isA(document::FieldValue::Type::ARRAY)) { const document::ArrayFieldValue & afv = static_cast<const document::ArrayFieldValue &>(fv); LOG(spam, "onCollectionStart: Array size = '%zu'", afv.size()); - } else if (fv.inherits(document::WeightedSetFieldValue::classId)) { + } else if (fv.isA(document::FieldValue::Type::WSET)) { const document::WeightedSetFieldValue & wsfv = static_cast<const document::WeightedSetFieldValue &>(fv); LOG(spam, "onCollectionStart: WeightedSet size = '%zu'", wsfv.size()); } diff --git a/vsm/src/vespa/vsm/vsm/docsumfilter.cpp b/vsm/src/vespa/vsm/vsm/docsumfilter.cpp index a74e41dfb3f..bd16c687fc7 100644 --- a/vsm/src/vespa/vsm/vsm/docsumfilter.cpp +++ b/vsm/src/vespa/vsm/vsm/docsumfilter.cpp @@ -71,7 +71,7 @@ public: StringResultHandler(ResType t, ResultPacker & p) : _type(t), _packer(p) {} void onPrimitive(uint32_t, const Content & c) override { const document::FieldValue & fv = c.getValue(); - if (fv.getClass().inherits(document::LiteralFieldValueB::classId)) { + if (fv.isLiteral()) { const document::LiteralFieldValueB & lfv = static_cast<const document::LiteralFieldValueB &>(fv); vespalib::stringref s = lfv.getValueRef(); addToPacker(s.data(), s.size()); diff --git a/vsm/src/vespa/vsm/vsm/flattendocsumwriter.cpp b/vsm/src/vespa/vsm/vsm/flattendocsumwriter.cpp index 821434a4ed6..06b652d85e6 100644 --- a/vsm/src/vespa/vsm/vsm/flattendocsumwriter.cpp +++ b/vsm/src/vespa/vsm/vsm/flattendocsumwriter.cpp @@ -18,13 +18,12 @@ FlattenDocsumWriter::onPrimitive(uint32_t, const Content & c) { considerSeparator(); const document::FieldValue & fv = c.getValue(); - const auto & clazz = fv.getClass(); - if (clazz.inherits(document::LiteralFieldValueB::classId)) { + if (fv.isLiteral()) { const document::LiteralFieldValueB & lfv = static_cast<const document::LiteralFieldValueB &>(fv); vespalib::stringref value = lfv.getValueRef(); _output.put(value.data(), value.size()); - } else if (clazz.inherits(document::NumericFieldValueBase::classId) || - clazz.inherits(document::BoolFieldValue::classId)) + } else if (fv.isNumeric() || + fv.isA(document::FieldValue::Type::BOOL)) { vespalib::string value = fv.getAsString(); _output.put(value.data(), value.size()); diff --git a/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp b/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp index 405f2292f5d..7c7d0cffbcc 100644 --- a/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp +++ b/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp @@ -4,6 +4,7 @@ #include <vespa/searchlib/util/slime_output_raw_buf_adapter.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/size_literals.h> +#include <vespa/vespalib/util/classname.h> #include <vespa/searchsummary/docsummary/resultconfig.h> #include <vespa/document/datatype/positiondatatype.h> @@ -48,13 +49,12 @@ namespace vsm { void SlimeFieldWriter::traverseRecursive(const document::FieldValue & fv, Inserter &inserter) { - const auto & clazz = fv.getClass(); LOG(debug, "traverseRecursive: class(%s), fieldValue(%s), currentPath(%s)", - clazz.name(), fv.toString().c_str(), toString(_currPath).c_str()); + vespalib::getClassName(fv).c_str(), fv.toString().c_str(), toString(_currPath).c_str()); - if (clazz.inherits(document::CollectionFieldValue::classId)) { + if (fv.isCollection()) { const document::CollectionFieldValue & cfv = static_cast<const document::CollectionFieldValue &>(fv); - if (cfv.inherits(document::ArrayFieldValue::classId)) { + if (cfv.isA(document::FieldValue::Type::ARRAY)) { const document::ArrayFieldValue & afv = static_cast<const document::ArrayFieldValue &>(cfv); Cursor &a = inserter.insertArray(); for (size_t i = 0; i < afv.size(); ++i) { @@ -62,7 +62,8 @@ SlimeFieldWriter::traverseRecursive(const document::FieldValue & fv, Inserter &i ArrayInserter ai(a); traverseRecursive(nfv, ai); } - } else if (cfv.inherits(document::WeightedSetFieldValue::classId)) { + } else { + assert(cfv.isA(document::FieldValue::Type::WSET)); const document::WeightedSetFieldValue & wsfv = static_cast<const document::WeightedSetFieldValue &>(cfv); Cursor &a = inserter.insertArray(); Symbol isym = a.resolve("item"); @@ -75,10 +76,8 @@ SlimeFieldWriter::traverseRecursive(const document::FieldValue & fv, Inserter &i int weight = static_cast<const document::IntFieldValue &>(*entry.second).getValue(); o.setLong(wsym, weight); } - } else { - LOG(warning, "traverseRecursive: Cannot handle collection field value of type '%s'", clazz.name()); } - } else if (clazz.inherits(document::MapFieldValue::classId)) { + } else if (fv.isA(document::FieldValue::Type::MAP)) { const document::MapFieldValue & mfv = static_cast<const document::MapFieldValue &>(fv); Cursor &a = inserter.insertArray(); Symbol keysym = a.resolve("key"); @@ -92,7 +91,7 @@ SlimeFieldWriter::traverseRecursive(const document::FieldValue & fv, Inserter &i traverseRecursive(*entry.second, vi); _currPath.pop_back(); } - } else if (clazz.inherits(document::StructuredFieldValue::classId)) { + } else if (fv.isStructured()) { const document::StructuredFieldValue & sfv = static_cast<const document::StructuredFieldValue &>(fv); Cursor &o = inserter.insertObject(); if (sfv.getDataType() == &document::PositionDataType::getInstance() @@ -135,10 +134,10 @@ SlimeFieldWriter::traverseRecursive(const document::FieldValue & fv, Inserter &i } } } else { - if (clazz.inherits(document::LiteralFieldValueB::classId)) { + if (fv.isLiteral()) { const document::LiteralFieldValueB & lfv = static_cast<const document::LiteralFieldValueB &>(fv); inserter.insertString(lfv.getValueRef()); - } else if (clazz.inherits(document::NumericFieldValueBase::classId)) { + } else if (fv.isNumeric()) { switch (fv.getDataType()->getId()) { case document::DataType::T_BYTE: case document::DataType::T_SHORT: @@ -155,7 +154,7 @@ SlimeFieldWriter::traverseRecursive(const document::FieldValue & fv, Inserter &i default: inserter.insertString(fv.getAsString()); } - } else if (clazz.inherits(document::BoolFieldValue::classId)) { + } else if (fv.isA(document::FieldValue::Type::BOOL)) { const auto & bfv = static_cast<const document::BoolFieldValue &>(fv); inserter.insertBool(bfv.getValue()); } else { |