blob: 9e4be09b0a14c6916111c24c54dbe71d0685fb7f (
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
64
65
66
67
68
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "attributedfw.h"
#include "resultconfig.h"
#include <vespa/searchlib/common/geo_location_spec.h>
namespace search::docsummary {
class LocationAttrDFW : public AttrDFW
{
public:
using GeoLoc = search::common::GeoLocation;
explicit LocationAttrDFW(const vespalib::string & attrName)
: AttrDFW(attrName)
{}
struct AllLocations {
std::vector<const GeoLoc *> matching;
std::vector<const GeoLoc *> other;
AllLocations();
~AllLocations();
bool empty() const {
return matching.empty() && other.empty();
}
const std::vector<const GeoLoc *> & best() const {
return matching.empty() ? other : matching;
}
};
AllLocations getAllLocations(GetDocsumsState& state) const;
};
class AbsDistanceDFW : public LocationAttrDFW
{
private:
uint64_t findMinDistance(uint32_t docid, GetDocsumsState& state,
const std::vector<const GeoLoc *> &locations) const;
public:
explicit AbsDistanceDFW(const vespalib::string & attrName);
bool isGenerated() const override { return true; }
void insertField(uint32_t docid, GetDocsumsState& state,
vespalib::slime::Inserter &target) const override;
static std::unique_ptr<DocsumFieldWriter> create(const char *attribute_name, const IAttributeManager *index_man);
};
//--------------------------------------------------------------------------
class PositionsDFW : public AttrDFW
{
private:
bool _useV8geoPositions;
public:
using UP = std::unique_ptr<PositionsDFW>;
PositionsDFW(const vespalib::string & attrName, bool useV8geoPositions);
bool isGenerated() const override { return true; }
void insertField(uint32_t docid, GetDocsumsState& state, vespalib::slime::Inserter &target) const override;
static UP create(const char *attribute_name, const IAttributeManager *index_man, bool useV8geoPositions);
};
}
|