// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "attributefactory.h" #include "defines.h" #include "flagattribute.h" #include "floatbase.h" #include "multinumericpostattribute.h" #include "multistringpostattribute.h" #include #include LOG_SETUP(".createarrayfastsearch"); namespace search { using attribute::BasicType; #define INTARRAY(T) MultiValueNumericPostingAttribute< ENUM_ATTRIBUTE(IntegerAttributeTemplate), MULTIVALUE_ENUM_ARG > #define FLOATARRAY(T) MultiValueNumericPostingAttribute< ENUM_ATTRIBUTE(FloatingPointAttributeTemplate), MULTIVALUE_ENUM_ARG > #define CREATEINTARRAY(T, fname, info) static_cast(new INTARRAY(T)(fname, info)) #define CREATEFLOATARRAY(T, fname, info) static_cast(new FLOATARRAY(T)(fname, info)) AttributeVector::SP AttributeFactory::createArrayFastSearch(stringref name, const Config & info) { assert(info.collectionType().type() == attribute::CollectionType::ARRAY); assert(info.fastSearch()); AttributeVector::SP ret; switch(info.basicType().type()) { case BasicType::BOOL: case BasicType::UINT2: case BasicType::UINT4: break; case BasicType::INT8: ret = std::make_shared(name, info); break; case BasicType::INT16: ret.reset(CREATEINTARRAY(int16_t, name, info)); break; case BasicType::INT32: ret.reset(CREATEINTARRAY(int32_t, name, info)); break; case BasicType::INT64: ret.reset(CREATEINTARRAY(int64_t, name, info)); break; case BasicType::FLOAT: ret.reset(CREATEFLOATARRAY(float, name, info)); break; case BasicType::DOUBLE: ret.reset(CREATEFLOATARRAY(double, name, info)); break; case BasicType::STRING: ret = std::make_shared(name, info); break; default: break; } return ret; } }