blob: 8d17ac9e8ba764be700dcaa4d133d1915b7a4ca9 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "i_direct_posting_store.h"
#include <charconv>
namespace search {
namespace {
class StringAsKey final : public IDirectPostingStore::LookupKey {
public:
StringAsKey(vespalib::stringref key)
: _key(key)
{ }
vespalib::stringref asString() const override { return _key; }
private:
vespalib::string _key;
};
}
bool
IDirectPostingStore::LookupKey::asInteger(int64_t &value) const {
vespalib::stringref str = asString();
const char *end = str.data() + str.size();
auto res = std::from_chars(str.data(), end, value);
return res.ptr == end;
}
IDirectPostingStore::LookupResult
IDirectPostingStore::lookup(vespalib::stringref term, vespalib::datastore::EntryRef dictionary_snapshot) const {
return lookup(StringAsKey(term), dictionary_snapshot);
}
}
|