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
64
65
66
67
68
69
70
71
72
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "integerbase.h"
#include <vespa/vespalib/util/exceptions.h>
namespace search {
using largeint_t = attribute::IAttributeVector::largeint_t;
template<typename T>
uint32_t
IntegerAttributeTemplate<T>::getRawValues(DocId, const multivalue::Value<T> * &) const {
throw std::runtime_error(getNativeClassName() + "::getRawValues() not implemented.");
}
template<typename T>
uint32_t
IntegerAttributeTemplate<T>::getRawValues(DocId, const multivalue::WeightedValue<T> * &) const {
throw std::runtime_error(getNativeClassName() + "::getRawValues() not implemented.");
}
template<typename T>
bool
IntegerAttributeTemplate<T>::findEnum(const char *value, EnumHandle &e) const {
vespalib::asciistream iss(value);
int64_t ivalue = 0;
try {
iss >> ivalue;
} catch (const vespalib::IllegalArgumentException &) {
}
return findEnum(ivalue, e);
}
template<typename T>
largeint_t
IntegerAttributeTemplate<T>::getIntFromEnum(EnumHandle e) const {
T v(getFromEnum(e));
if (attribute::isUndefined<T>(v)) {
return attribute::getUndefined<largeint_t>();
}
return v;
}
template<typename T>
long
IntegerAttributeTemplate<T>::onSerializeForAscendingSort(DocId doc, void * serTo, long available, const common::BlobConverter * bc) const {
(void) bc;
if (available >= long(sizeof(T))) {
T origValue(get(doc));
vespalib::serializeForSort< vespalib::convertForSort<T, true> >(origValue, serTo);
} else {
return -1;
}
return sizeof(T);
}
template<typename T>
long
IntegerAttributeTemplate<T>::onSerializeForDescendingSort(DocId doc, void * serTo, long available, const common::BlobConverter * bc) const {
(void) bc;
if (available >= long(sizeof(T))) {
T origValue(get(doc));
vespalib::serializeForSort< vespalib::convertForSort<T, false> >(origValue, serTo);
} else {
return -1;
}
return sizeof(T);
}
}
|