aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/attribute/loadednumericvalue.h
blob: 25c00210073083bda29f665c6a4557adae4866f9 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "loadedvalue.h"
#include <vespa/vespalib/util/sort.h>
#include <vespa/searchlib/util/fileutil.h>

namespace search::attribute {

/**
 * Temporary representation of enumerated attribute loaded from non-enumerated
 * save file (i.e. old save format).  For numeric data types.
 */

template <typename T>
struct LoadedNumericValue : public LoadedValue<T>
{
    LoadedNumericValue() : LoadedValue<T>() { }

    class ValueCompare
    {
    public:
        bool operator()(const LoadedNumericValue<T> &x, const LoadedNumericValue<T> &y) const {
            return x < y;
        }
    };

    class ValueRadix
    {
    public:
        uint64_t operator()(const LoadedValue<T> &v) const {
            return vespalib::convertForSort<T, true>::convert(v.getValue());
        }
    };
};


template <typename T>
void
sortLoadedByValue(SequentialReadModifyWriteVector<LoadedNumericValue<T>> & loaded);

template <typename T>
void
sortLoadedByDocId(SequentialReadModifyWriteVector<LoadedNumericValue<T>> & loaded);

}