aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp
blob: 94d20e474af13eddacc7522acf6d10994292056f (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
// 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 "singleboolattribute.h"
#include "singlenumericpostattribute.h"
#include "singlestringpostattribute.h"
#include <vespa/searchcommon/attribute/config.h>
#include <vespa/searchlib/tensor/direct_tensor_attribute.h>

#define INTPOSTING(T)   SingleValueNumericPostingAttribute< ENUM_ATTRIBUTE(IntegerAttributeTemplate<T>) >
#define FLOATPOSTING(T) SingleValueNumericPostingAttribute< ENUM_ATTRIBUTE(FloatingPointAttributeTemplate<T>) >

namespace search {

using attribute::BasicType;

AttributeVector::SP
AttributeFactory::createSingleFastSearch(stringref name, const Config & info)
{
    assert(info.collectionType().type() == attribute::CollectionType::SINGLE);
    assert(info.fastSearch());
    switch(info.basicType().type()) {
    case BasicType::BOOL:
        return std::make_shared<SingleBoolAttribute>(name, info.getGrowStrategy(), info.paged());
    case BasicType::UINT2:
    case BasicType::UINT4:
        break;
    case BasicType::INT8:
        return std::make_shared<INTPOSTING(int8_t)>(name, info);
    case BasicType::INT16:
        return std::make_shared<INTPOSTING(int16_t)>(name, info);
    case BasicType::INT32:
        return std::make_shared<INTPOSTING(int32_t)>(name, info);
    case BasicType::INT64:
        return std::make_shared<INTPOSTING(int64_t)>(name, info);
    case BasicType::FLOAT:
        return std::make_shared<FLOATPOSTING(float)>(name, info);
    case BasicType::DOUBLE:
        return std::make_shared<FLOATPOSTING(double)>(name, info);
    case BasicType::STRING:
        return std::make_shared<SingleValueStringPostingAttribute>(name, info);
    case BasicType::TENSOR:
        if (!info.tensorType().is_dense()) {
            return std::make_shared<tensor::DirectTensorAttribute>(name, info);
        }
        break;
    default:
        break;
    }
    return AttributeVector::SP();
}

}