diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-04-03 16:16:42 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2017-04-03 16:16:42 +0200 |
commit | c5b45393eef04591f5012264a69141c29053f7f7 (patch) | |
tree | 5173aa0d6c84095e30102d9272631afe56b056b5 /searchlib | |
parent | 2de59d58030f4d9e3d63636058ec3987258266e6 (diff) |
Add field id to the onPrimitive interface.
Diffstat (limited to 'searchlib')
4 files changed, 41 insertions, 52 deletions
diff --git a/searchlib/src/vespa/searchlib/expression/documentaccessornode.h b/searchlib/src/vespa/searchlib/expression/documentaccessornode.h index 7fc577d6a53..864223ad250 100644 --- a/searchlib/src/vespa/searchlib/expression/documentaccessornode.h +++ b/searchlib/src/vespa/searchlib/expression/documentaccessornode.h @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/searchlib/expression/expressionnode.h> +#include "expressionnode.h" #include <vespa/document/fieldvalue/document.h> #include <vespa/vespalib/objects/objectoperation.h> #include <vespa/vespalib/objects/objectpredicate.h> @@ -18,8 +18,8 @@ public: public: Configure(const document::DocumentType & documentType) : _docType(documentType) { } private: - virtual void execute(vespalib::Identifiable &obj) { static_cast<DocumentAccessorNode &>(obj).setDocType(_docType); } - virtual bool check(const vespalib::Identifiable &obj) const { return obj.inherits(DocumentAccessorNode::classId); } + void execute(vespalib::Identifiable &obj) override { static_cast<DocumentAccessorNode &>(obj).setDocType(_docType); } + bool check(const vespalib::Identifiable &obj) const override { return obj.inherits(DocumentAccessorNode::classId); } const document::DocumentType & _docType; }; diff --git a/searchlib/src/vespa/searchlib/expression/documentfieldnode.cpp b/searchlib/src/vespa/searchlib/expression/documentfieldnode.cpp index 5c85e110692..e4b0a1462f7 100644 --- a/searchlib/src/vespa/searchlib/expression/documentfieldnode.cpp +++ b/searchlib/src/vespa/searchlib/expression/documentfieldnode.cpp @@ -1,14 +1,11 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/searchlib/expression/documentfieldnode.h> -#include <vespa/searchlib/expression/getdocidnamespacespecificfunctionnode.h> -#include <vespa/searchlib/expression/getymumchecksumfunctionnode.h> +#include "documentfieldnode.h" +#include "getdocidnamespacespecificfunctionnode.h" +#include "getymumchecksumfunctionnode.h" #include <vespa/document/fieldvalue/fieldvalues.h> -#include <stdexcept> -#include <vespa/vespalib/objects/visit.h> +#include <vespa/vespalib/encoding/base64.h> #include <vespa/log/log.h> - LOG_SETUP(".searchlib.documentfieldnode"); namespace search { @@ -45,7 +42,8 @@ DocumentFieldNode & DocumentFieldNode::operator = (const DocumentFieldNode & rhs return *this; } -std::unique_ptr<ResultNode> deduceResultNode(const vespalib::stringref & fieldName, const FieldValue & fv, bool preserveAccurateTypes, bool nestedMultiValue) +std::unique_ptr<ResultNode> +deduceResultNode(const vespalib::stringref & fieldName, const FieldValue & fv, bool preserveAccurateTypes, bool nestedMultiValue) { std::unique_ptr<ResultNode> value; const Identifiable::RuntimeClass & cInfo = fv.getClass(); @@ -147,9 +145,9 @@ class FieldValue2ResultNode : public ResultNode public: DECLARE_EXPRESSIONNODE(FieldValue2ResultNode); FieldValue2ResultNode(const FieldValue * fv=NULL) : _fv(fv) { } - virtual int64_t onGetInteger(size_t index) const { (void) index; return _fv ? _fv->getAsLong() : 0; } - virtual double onGetFloat(size_t index) const { (void) index; return _fv ? _fv->getAsDouble() : 0; } - virtual ConstBufferRef onGetString(size_t index, BufferRef buf) const { + int64_t onGetInteger(size_t index) const override { (void) index; return _fv ? _fv->getAsLong() : 0; } + double onGetFloat(size_t index) const override { (void) index; return _fv ? _fv->getAsDouble() : 0; } + ConstBufferRef onGetString(size_t index, BufferRef buf) const override { (void) index; if (_fv) { std::pair<const char*, size_t> raw = _fv->getAsRaw(); @@ -157,12 +155,9 @@ public: } return buf; } - virtual void min(const ResultNode & b) { (void) b; } - virtual void max(const ResultNode & b) { (void) b; } - virtual void add(const ResultNode & b) { (void) b; } private: - virtual void set(const ResultNode&); - virtual size_t hash() const { return 0; } + virtual void set(const ResultNode&) override; + virtual size_t hash() const override { return 0; } const FieldValue * _fv; }; @@ -196,7 +191,7 @@ bool DocumentFieldNode::onExecute() const DefaultValue DocumentFieldNode::SingleHandler::_defaultValue; void -DocumentFieldNode::SingleHandler::onPrimitive(const Content & c) +DocumentFieldNode::SingleHandler::onPrimitive(uint32_t, const Content & c) { LOG(spam, "SingleHandler::onPrimitive: field value '%s'", c.getValue().toString().c_str()); FieldValue2ResultNode converter(&c.getValue()); @@ -204,7 +199,7 @@ DocumentFieldNode::SingleHandler::onPrimitive(const Content & c) } void -DocumentFieldNode::MultiHandler::onPrimitive(const Content & c) +DocumentFieldNode::MultiHandler::onPrimitive(uint32_t, const Content & c) { LOG(spam, "MultiHandler::onPrimitive: field value '%s'", c.getValue().toString().c_str()); FieldValue2ResultNode converter(&c.getValue()); diff --git a/searchlib/src/vespa/searchlib/expression/documentfieldnode.h b/searchlib/src/vespa/searchlib/expression/documentfieldnode.h index d40a9fd8836..e5b670be1ea 100644 --- a/searchlib/src/vespa/searchlib/expression/documentfieldnode.h +++ b/searchlib/src/vespa/searchlib/expression/documentfieldnode.h @@ -1,32 +1,27 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/searchlib/expression/documentaccessornode.h> -#include <vespa/searchlib/expression/resultnode.h> -#include <vespa/searchlib/expression/resultvector.h> -#include <vespa/document/document.h> -#include <vespa/vespalib/encoding/base64.h> +#include "documentaccessornode.h" +#include "resultnode.h" +#include "resultvector.h" namespace search { namespace expression { -class DefaultValue : public ResultNode +class DefaultValue final : public ResultNode { public: DECLARE_EXPRESSIONNODE(DefaultValue); - virtual int64_t onGetInteger(size_t index) const { (void) index; return 0; } - virtual double onGetFloat(size_t index) const { (void) index; return 0; } - virtual ConstBufferRef onGetString(size_t index, BufferRef buf) const { + int64_t onGetInteger(size_t index) const override { (void) index; return 0; } + double onGetFloat(size_t index) const override { (void) index; return 0; } + ConstBufferRef onGetString(size_t index, BufferRef buf) const override { (void) index; (void) buf; return ConstBufferRef(&null, 0); } - virtual void min(const ResultNode & b) { (void) b; } - virtual void max(const ResultNode & b) { (void) b; } - virtual void add(const ResultNode & b) { (void) b; } private: - virtual void set(const ResultNode&); - virtual size_t hash() const { return 0; } + void set(const ResultNode&) override; + size_t hash() const override { return 0; } static char null; }; @@ -34,13 +29,13 @@ class DocumentFieldNode : public DocumentAccessorNode { public: DECLARE_NBO_SERIALIZE; - virtual void visitMembers(vespalib::ObjectVisitor &visitor) const; + void visitMembers(vespalib::ObjectVisitor &visitor) const override; DECLARE_EXPRESSIONNODE(DocumentFieldNode); DocumentFieldNode() : _fieldPath(), _value(), _fieldName(), _doc(NULL) { } DocumentFieldNode(const vespalib::stringref &name) : _fieldPath(), _value(), _fieldName(name), _doc(NULL) { } DocumentFieldNode(const DocumentFieldNode & rhs); DocumentFieldNode & operator = (const DocumentFieldNode & rhs); - virtual const vespalib::string & getFieldName() const { return _fieldName; } + const vespalib::string & getFieldName() const override { return _fieldName; } private: class Handler : public document::FieldValue::IteratorHandler { public: @@ -48,32 +43,32 @@ private: protected: typedef document::FieldValue::IteratorHandler::Content Content; private: - virtual void onCollectionStart(const Content & c); - virtual void onStructStart(const Content & c); + void onCollectionStart(const Content & c) override; + void onStructStart(const Content & c) override; }; class SingleHandler : public Handler { public: SingleHandler(ResultNode & result) : _result(result) {} private: - virtual void reset() { _result.set(_defaultValue); } + void reset() override { _result.set(_defaultValue); } ResultNode & _result; static DefaultValue _defaultValue; - virtual void onPrimitive(const Content & c); + void onPrimitive(uint32_t fid, const Content & c) override; }; class MultiHandler : public Handler { public: MultiHandler(ResultNodeVector & result) : _result(result) {} private: - virtual void reset() { _result.clear(); } + void reset() override { _result.clear(); } ResultNodeVector & _result; - virtual void onPrimitive(const Content & c); + void onPrimitive(uint32_t fid, const Content & c) override; }; - virtual const ResultNode & getResult() const { return *_value; } - virtual void onPrepare(bool preserveAccurateTypes); - virtual bool onExecute() const; - virtual void onDoc(const document::Document & doc); - virtual void onDocType(const document::DocumentType & docType); + const ResultNode & getResult() const override { return *_value; } + void onPrepare(bool preserveAccurateTypes) override; + bool onExecute() const override; + void onDoc(const document::Document & doc) override; + void onDocType(const document::DocumentType & docType) override; document::FieldPath _fieldPath; mutable ResultNode::CP _value; mutable std::unique_ptr<Handler> _handler; @@ -84,4 +79,3 @@ private: } } - diff --git a/searchlib/src/vespa/searchlib/expression/resultnode.h b/searchlib/src/vespa/searchlib/expression/resultnode.h index b30ff68c51c..edd76bdcbfa 100644 --- a/searchlib/src/vespa/searchlib/expression/resultnode.h +++ b/searchlib/src/vespa/searchlib/expression/resultnode.h @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/searchlib/expression/expressionnode.h> -#include <vespa/searchlib/expression/serializer.h> +#include "expressionnode.h" +#include "serializer.h" #include <vespa/vespalib/util/exception.h> #include <vespa/vespalib/util/buffer.h> @@ -58,7 +58,7 @@ private: public: DECLARE_ABSTRACT_RESULTNODE(ResultNode); - virtual ~ResultNode() { } + ~ResultNode() { } typedef std::unique_ptr<ResultNode> UP; typedef vespalib::IdentifiablePtr<ResultNode> CP; virtual void set(const ResultNode & rhs) = 0; |