summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorLester Solbakken <lesters@yahoo-inc.com>2017-08-18 10:29:03 +0000
committerLester Solbakken <lesters@yahoo-inc.com>2017-08-18 10:29:03 +0000
commit02fd65e96f9457002a4465263f5bf420b668b39e (patch)
tree68e63cab12443f95c757bab4b1d17b7e66dfcfd6 /searchlib
parenta018bd987c0db9fdf23ea2f46de5d965f42e3ed7 (diff)
Add check for supported attribute types in blueprint setup
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/features/internal_max_reduce_prod_join_feature/internal_max_reduce_prod_join_feature_test.cpp12
-rw-r--r--searchlib/src/vespa/searchlib/features/internal_max_reduce_prod_join_feature.cpp18
-rw-r--r--searchlib/src/vespa/searchlib/fef/test/indexenvironmentbuilder.cpp11
-rw-r--r--searchlib/src/vespa/searchlib/fef/test/indexenvironmentbuilder.h13
4 files changed, 46 insertions, 8 deletions
diff --git a/searchlib/src/tests/features/internal_max_reduce_prod_join_feature/internal_max_reduce_prod_join_feature_test.cpp b/searchlib/src/tests/features/internal_max_reduce_prod_join_feature/internal_max_reduce_prod_join_feature_test.cpp
index 86eaaf2e083..06d1994d369 100644
--- a/searchlib/src/tests/features/internal_max_reduce_prod_join_feature/internal_max_reduce_prod_join_feature_test.cpp
+++ b/searchlib/src/tests/features/internal_max_reduce_prod_join_feature/internal_max_reduce_prod_join_feature_test.cpp
@@ -14,6 +14,7 @@ using namespace search::features;
using search::AttributeFactory;
using search::IntegerAttribute;
using CollectionType = FieldInfo::CollectionType;
+using DataType = FieldInfo::DataType;
typedef search::attribute::Config AVC;
typedef search::attribute::BasicType AVBT;
@@ -25,12 +26,13 @@ struct SetupFixture
{
InternalMaxReduceProdJoinBlueprint blueprint;
IndexEnvironment indexEnv;
- SetupFixture(const vespalib::string &attr)
+ SetupFixture(const vespalib::string &attrName)
: blueprint(),
indexEnv()
{
- FieldInfo attr_info(FieldType::ATTRIBUTE, CollectionType::ARRAY, attr, 0);
- indexEnv.getFields().push_back(attr_info);
+ FieldInfo attrInfo(FieldType::ATTRIBUTE, CollectionType::ARRAY, attrName, 0);
+ attrInfo.set_data_type(DataType::INT64);
+ indexEnv.getFields().push_back(attrInfo);
}
};
@@ -70,8 +72,8 @@ struct ExecFixture
vespalib::string attrIntArray = "intarray";
vespalib::string attrLongArray = "longarray";
- test.getIndexEnv().getBuilder().addField(FieldType::ATTRIBUTE, CollectionType::ARRAY, attrLongArray);
- test.getIndexEnv().getBuilder().addField(FieldType::ATTRIBUTE, CollectionType::ARRAY, attrIntArray);
+ test.getIndexEnv().getBuilder().addField(FieldType::ATTRIBUTE, CollectionType::ARRAY, DataType::INT64, attrLongArray);
+ test.getIndexEnv().getBuilder().addField(FieldType::ATTRIBUTE, CollectionType::ARRAY, DataType::INT32, attrIntArray);
std::vector<AttributePtr> attrs;
attrs.push_back(AttributeFactory::createAttribute(attrLongArray, AVC(AVBT::INT64, AVCT::ARRAY)));
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 07086c6e7ac..adb7750ac66 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
@@ -11,6 +11,7 @@
#include <vespa/searchlib/features/dotproductfeature.h>
#include <vespa/searchlib/fef/properties.h>
#include <vespa/searchlib/fef/featureexecutor.h>
+#include <vespa/searchcommon/common/datatype.h>
LOG_SETUP(".features.internalmaxreduceprodjoin");
@@ -27,9 +28,6 @@ namespace features {
*/
template <typename BaseType>
class RawExecutor : public FeatureExecutor {
-public:
- using A = IntegerAttributeTemplate<BaseType>;
- using AT = multivalue::Value<BaseType>;
protected:
const IAttributeVector * _attribute;
IntegerVector _queryVector;
@@ -67,6 +65,9 @@ template <typename BaseType>
void
RawExecutor<BaseType>::execute(uint32_t docId)
{
+ using A = IntegerAttributeTemplate<BaseType>;
+ using AT = multivalue::Value<BaseType>;
+
const AT *values(nullptr);
const A *iattr = dynamic_cast<const A *>(_attribute);
size_t count = iattr->getRawValues(docId, values);
@@ -136,6 +137,17 @@ InternalMaxReduceProdJoinBlueprint::getDescriptions() const
bool
InternalMaxReduceProdJoinBlueprint::setup(const IIndexEnvironment &env, const ParameterList &params)
{
+ const FieldInfo* attributeInfo = params[0].asField();
+ if (attributeInfo == nullptr) {
+ return false;
+ }
+ if (attributeInfo->collection() != FieldInfo::CollectionType::ARRAY) {
+ return false;
+ }
+ if (attributeInfo->get_data_type() != FieldInfo::DataType::INT32 && attributeInfo->get_data_type() != FieldInfo::DataType::INT64) {
+ return false;
+ }
+
_attribute = params[0].getValue();
_query = params[1].getValue();
describeOutput("scalar", "Internal executor for optimized execution of reduce(join(A,Q,f(x,y)(x*y)),max)");
diff --git a/searchlib/src/vespa/searchlib/fef/test/indexenvironmentbuilder.cpp b/searchlib/src/vespa/searchlib/fef/test/indexenvironmentbuilder.cpp
index da27cb143cc..be78e8c45f8 100644
--- a/searchlib/src/vespa/searchlib/fef/test/indexenvironmentbuilder.cpp
+++ b/searchlib/src/vespa/searchlib/fef/test/indexenvironmentbuilder.cpp
@@ -1,5 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/searchcommon/common/datatype.h>
#include "indexenvironmentbuilder.h"
namespace search {
@@ -17,8 +18,18 @@ IndexEnvironmentBuilder::addField(const FieldType &type,
const FieldInfo::CollectionType &coll,
const vespalib::string &name)
{
+ return addField(type, coll, FieldInfo::DataType::DOUBLE, name);
+}
+
+IndexEnvironmentBuilder &
+IndexEnvironmentBuilder::addField(const FieldType &type,
+ const FieldInfo::CollectionType &coll,
+ const FieldInfo::DataType &dataType,
+ const vespalib::string &name)
+{
uint32_t idx = _env.getFields().size();
FieldInfo field(type, coll, name, idx);
+ field.set_data_type(dataType);
_env.getFields().push_back(field);
return *this;
}
diff --git a/searchlib/src/vespa/searchlib/fef/test/indexenvironmentbuilder.h b/searchlib/src/vespa/searchlib/fef/test/indexenvironmentbuilder.h
index fc7af0dc6aa..5cc685af92b 100644
--- a/searchlib/src/vespa/searchlib/fef/test/indexenvironmentbuilder.h
+++ b/searchlib/src/vespa/searchlib/fef/test/indexenvironmentbuilder.h
@@ -30,6 +30,19 @@ public:
const FieldInfo::CollectionType &coll,
const vespalib::string &name);
+ /**
+ * Add a field to the index environment with specified data type.
+ *
+ * @param type The type of field to add.
+ * @param coll collection type
+ * @param coll collection base data type
+ * @param name The name of the field.
+ */
+ IndexEnvironmentBuilder &addField(const FieldType &type,
+ const FieldInfo::CollectionType &coll,
+ const FieldInfo::DataType &dataType,
+ const vespalib::string &name);
+
/** Returns a reference to the index environment of this. */
IndexEnvironment &getIndexEnv() { return _env; }