aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/attribute/createarrayfastsearch.cpp
blob: acdc5c1f21990e8a55695569869a3927b4e912e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright Yahoo. 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 <vespa/searchcommon/attribute/config.h>

#include <vespa/log/log.h>
LOG_SETUP(".createarrayfastsearch");

namespace search {

using attribute::BasicType;

#define INTARRAY(T)   MultiValueNumericPostingAttribute< ENUM_ATTRIBUTE(IntegerAttributeTemplate<T>), MULTIVALUE_ENUM_ARG >
#define FLOATARRAY(T) MultiValueNumericPostingAttribute< ENUM_ATTRIBUTE(FloatingPointAttributeTemplate<T>), MULTIVALUE_ENUM_ARG >
#define CREATEINTARRAY(T, fname, info) static_cast<AttributeVector *>(new INTARRAY(T)(fname, info))
#define CREATEFLOATARRAY(T, fname, info) static_cast<AttributeVector *>(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<FlagAttribute>(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<ArrayStringPostingAttribute>(name, info);
        break;
    default:
        break;
    }
    return ret;
}

}