From 821eaba272d01f7bc45b37379485b5605d775ae3 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Fri, 20 Apr 2018 13:21:06 +0000 Subject: Add virtual isImported() method to IAttributeVector. --- .../src/vespa/searchcommon/attribute/iattributevector.h | 8 +++++++- searchlib/src/vespa/searchlib/attribute/attributevector.cpp | 6 ++++++ searchlib/src/vespa/searchlib/attribute/attributevector.h | 1 + .../attribute/imported_attribute_vector_read_guard.cpp | 5 +++++ .../attribute/imported_attribute_vector_read_guard.h | 1 + searchlib/src/vespa/searchlib/features/dotproductfeature.cpp | 12 ++++-------- .../features/internal_max_reduce_prod_join_feature.cpp | 6 +----- 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h b/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h index 22e2e46c1e4..79795d94170 100644 --- a/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h +++ b/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h @@ -366,13 +366,19 @@ public: */ virtual bool getIsFastSearch() const = 0; - /* + /** * Returns the committed docid limit for the attribute. * * @return committed docid limit for the attribute. */ virtual uint32_t getCommittedDocIdLimitSlow() const = 0; + /* + * Returns whether the current attribute vector is an imported attribute + * vector. + */ + virtual bool isImported() const = 0; + /** * Will serialize the values for the documentid in ascending order. The serialized form can be used by memcmp and * sortorder will be preserved. diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp index e6cfe303bed..998cd78623d 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp @@ -345,6 +345,12 @@ AttributeVector::getCommittedDocIdLimitSlow() const return getCommittedDocIdLimit(); } +bool +AttributeVector::isImported() const +{ + return false; +} + bool AttributeVector::headerTypeOK(const vespalib::GenericHeader &header) const { diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h index f00a8779c92..2392504bdaf 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.h +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h @@ -434,6 +434,7 @@ public: virtual bool getIsFilter() const override; virtual bool getIsFastSearch() const override; virtual uint32_t getCommittedDocIdLimitSlow() const override; + virtual bool isImported() const override; /** * Updates the base file name of this attribute vector and saves diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp index 98e93fb41df..a27c73e112e 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp +++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.cpp @@ -146,6 +146,11 @@ uint32_t ImportedAttributeVectorReadGuard::getCommittedDocIdLimitSlow() const { return _reference_attribute.getCommittedDocIdLimit(); } +bool ImportedAttributeVectorReadGuard::isImported() const +{ + return true; +} + long ImportedAttributeVectorReadGuard::onSerializeForAscendingSort(DocId doc, void *serTo, long available, diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h index 6c02c20c48a..6c8dca11d31 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h +++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h @@ -76,6 +76,7 @@ public: virtual bool getIsFilter() const override; virtual bool getIsFastSearch() const override; virtual uint32_t getCommittedDocIdLimitSlow() const override; + virtual bool isImported() const override; protected: virtual long onSerializeForAscendingSort(DocId doc, void * serTo, long available, diff --git a/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp b/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp index be909d7a7e6..3688e00d47d 100644 --- a/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp @@ -355,10 +355,6 @@ template class ArrayParam; namespace { -bool isImportedAttribute(const IAttributeVector& attribute) noexcept { - return dynamic_cast(&attribute) != nullptr; -} - using dotproduct::ArrayParam; template @@ -373,7 +369,7 @@ bool supportsGetRawValues(const A & attr) noexcept { } } -// Precondition: isImportedAttribute(*attribute) == false +// Precondition: attribute->isImported() == false template FeatureExecutor & createForDirectArrayImpl(const IAttributeVector * attribute, @@ -471,7 +467,7 @@ FeatureExecutor & createFromObject(const IAttributeVector * attribute, const fef::Anything & object, vespalib::Stash &stash) { if (attribute->getCollectionType() == attribute::CollectionType::ARRAY) { - if (!isImportedAttribute(*attribute)) { + if (!attribute->isImported()) { switch (attribute->getBasicType()) { case BasicType::INT32: return createForDirectArray>(attribute, dynamic_cast &>(object), stash); @@ -507,7 +503,7 @@ createFromObject(const IAttributeVector * attribute, const fef::Anything & objec FeatureExecutor * createTypedArrayExecutor(const IAttributeVector * attribute, const Property & prop, vespalib::Stash & stash) { - if (!isImportedAttribute(*attribute)) { + if (!attribute->isImported()) { switch (attribute->getBasicType()) { case BasicType::INT32: return &createForDirectArray>(attribute, prop, stash); @@ -586,7 +582,7 @@ createFromString(const IAttributeVector * attribute, const Property & prop, vesp } fef::Anything::UP attemptParseArrayQueryVector(const IAttributeVector & attribute, const Property & prop) { - if (!isImportedAttribute(attribute)) { + if (!attribute.isImported()) { switch (attribute.getBasicType()) { case BasicType::INT32: return std::make_unique>(prop); diff --git a/searchlib/src/vespa/searchlib/features/internal_max_reduce_prod_join_feature.cpp b/searchlib/src/vespa/searchlib/features/internal_max_reduce_prod_join_feature.cpp index b9a9d96ff66..90451c01294 100644 --- a/searchlib/src/vespa/searchlib/features/internal_max_reduce_prod_join_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/internal_max_reduce_prod_join_feature.cpp @@ -143,10 +143,6 @@ InternalMaxReduceProdJoinBlueprint::setup(const IIndexEnvironment &env, const Pa return true; } -bool isImportedAttribute(const IAttributeVector &attribute) noexcept { - return dynamic_cast(&attribute) != nullptr; -} - template bool supportsGetRawValues(const A &attr) noexcept { try { @@ -163,7 +159,7 @@ template FeatureExecutor & selectTypedExecutor(const IAttributeVector *attribute, const IntegerVector &vector, vespalib::Stash &stash) { - if (!isImportedAttribute(*attribute)) { + if (!attribute->isImported()) { using A = IntegerAttributeTemplate; using VT = multivalue::Value; using ExactA = MultiValueNumericAttribute; -- cgit v1.2.3