diff options
author | Tor Brede Vekterli <vekterli@yahoo-inc.com> | 2017-02-24 09:39:47 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@yahoo-inc.com> | 2017-02-24 12:41:10 +0000 |
commit | 63e4e8e75c0565a36e930d12085ab68541dfbf5d (patch) | |
tree | 7841237a12a6670dd97b48033f2035197559d1cc /searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h | |
parent | 97d745c24c3bf9de0d415fe859a0810056fbce8d (diff) |
Add imported attribute vector, take two.
Diffstat (limited to 'searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h')
-rw-r--r-- | searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h new file mode 100644 index 00000000000..97f1606f125 --- /dev/null +++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h @@ -0,0 +1,73 @@ +// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include "reference_attribute.h" +#include <vespa/searchcommon/attribute/iattributevector.h> +#include <vespa/vespalib/stllike/string.h> +#include <memory> + +namespace search { +namespace attribute { + +/** + * Attribute vector which does not store values of its own, but rather serves as a + * convenient indirection wrapper towards a target vector, usually in another + * document type altogether. Imported attributes are meant to be used in conjunction + * with a reference attribute, which specifies a dynamic mapping from a local LID to + * a target LID (via an intermediate GID). + * + * Any accessor on the imported attribute for a local LID yields the same result as + * if the same accessor were invoked with the target LID on the target attribute vector. + */ +class ImportedAttributeVector : public IAttributeVector { +public: + ImportedAttributeVector(vespalib::stringref name, + std::shared_ptr<ReferenceAttribute> reference_attribute, + std::shared_ptr<AttributeVector> target_attribute); + ~ImportedAttributeVector(); + + const vespalib::string & getName() const override; + uint32_t getNumDocs() const override; + uint32_t getValueCount(uint32_t doc) const override; + uint32_t getMaxValueCount() const override; + largeint_t getInt(DocId doc) const override; + double getFloat(DocId doc) const override; + const char * getString(DocId doc, char * buffer, size_t sz) const override; + EnumHandle getEnum(DocId doc) const override; + uint32_t get(DocId docId, largeint_t * buffer, uint32_t sz) const override; + uint32_t get(DocId docId, double * buffer, uint32_t sz) const override; + uint32_t get(DocId docId, const char ** buffer, uint32_t sz) const override; + uint32_t get(DocId docId, EnumHandle * buffer, uint32_t sz) const override; + uint32_t get(DocId docId, WeightedInt * buffer, uint32_t sz) const override; + uint32_t get(DocId docId, WeightedFloat * buffer, uint32_t sz) const override; + uint32_t get(DocId docId, WeightedString * buffer, uint32_t sz) const override; + uint32_t get(DocId docId, WeightedConstChar * buffer, uint32_t sz) const override; + uint32_t get(DocId docId, WeightedEnum * buffer, uint32_t sz) const override; + bool findEnum(const char * value, EnumHandle & e) const override; + BasicType::Type getBasicType() const override; + size_t getFixedWidth() const override; + CollectionType::Type getCollectionType() const override; + bool hasEnum() const override; + + const std::shared_ptr<ReferenceAttribute>& getReferenceAttribute() const noexcept { + return _reference_attribute; + } + const std::shared_ptr<AttributeVector>& getTargetAttribute() const noexcept { + return _target_attribute; + } + +private: + long onSerializeForAscendingSort(DocId doc, void * serTo, long available, + const common::BlobConverter * bc) const override; + long onSerializeForDescendingSort(DocId doc, void * serTo, long available, + const common::BlobConverter * bc) const override; + + + vespalib::string _name; + std::shared_ptr<ReferenceAttribute> _reference_attribute; + std::shared_ptr<AttributeVector> _target_attribute; +}; + +} // attribute +} // search
\ No newline at end of file |