aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/attribute/createsetfastsearch.cpp
blob: fc7bb9ed4e27553ffeb2cbf6c4bb15f608092b3d (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
62
63
// 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 "floatbase.h"
#include "integerbase.h"
#include "multinumericpostattribute.h"
#include "multistringpostattribute.h"
#include <vespa/searchcommon/attribute/config.h>

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

namespace search {

using attribute::BasicType;

#define INTSET(T)   MultiValueNumericPostingAttribute< ENUM_ATTRIBUTE(IntegerAttributeTemplate<T>), WEIGHTED_MULTIVALUE_ENUM_ARG >
#define FLOATSET(T) MultiValueNumericPostingAttribute< ENUM_ATTRIBUTE(FloatingPointAttributeTemplate<T>), WEIGHTED_MULTIVALUE_ENUM_ARG >

#define CREATEINTSET(T, fname, info) static_cast<AttributeVector *>(new INTSET(T)(fname, info))
#define CREATEFLOATSET(T, fname, info) static_cast<AttributeVector *>(new FLOATSET(T)(fname, info))


AttributeVector::SP
AttributeFactory::createSetFastSearch(stringref name, const Config & info)
{
    assert(info.collectionType().type() == attribute::CollectionType::WSET);
    assert(info.fastSearch());
    AttributeVector::SP ret;
    switch(info.basicType().type()) {
    case BasicType::BOOL:
    case BasicType::UINT2:
    case BasicType::UINT4:
        break;
    case BasicType::INT8:
        ret.reset(CREATEINTSET(int8_t, name, info));
        break;
    case BasicType::INT16:
        ret.reset(CREATEINTSET(int16_t, name, info));
        break;
    case BasicType::INT32:
        ret.reset(CREATEINTSET(int32_t, name, info));
        break;
    case BasicType::INT64:
        ret.reset(CREATEINTSET(int64_t, name, info));
        break;
    case BasicType::FLOAT:
        ret.reset(CREATEFLOATSET(float, name, info));
        break;
    case BasicType::DOUBLE:
        ret.reset(CREATEFLOATSET(double, name, info));
        break;
    case BasicType::STRING:
        ret.reset(static_cast<AttributeVector *>(new WeightedSetStringPostingAttribute(name, info)));
        break;
    default:
        break;
    }
    return ret;
}

}