blob: 0c948ee57e842ae6a3f85d2413dfa2378ffca89d (
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 Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/stllike/hash_map.h>
#include <memory>
namespace document
{
class Document;
class FieldValue;
class FieldPath;
class FieldPathEntry;
}
namespace proton {
/**
* Class used to extract a field value from a document field or from a
* nested field in an array/map of structs.
*/
class DocumentFieldExtractor
{
const document::Document &_doc;
vespalib::hash_map<vespalib::string, std::unique_ptr<document::FieldValue>> _cachedFieldValues;
const document::FieldValue *getCachedFieldValue(const document::FieldPathEntry &fieldPathEntry);
std::unique_ptr<document::FieldValue> getSimpleFieldValue(const document::FieldPath &fieldPath);
std::unique_ptr<document::FieldValue> extractFieldFromStructArray(const document::FieldPath &fieldPath);
std::unique_ptr<document::FieldValue> extractKeyFieldFromMap(const document::FieldPath &fieldPath);
std::unique_ptr<document::FieldValue> extractValueFieldFromPrimitiveMap(const document::FieldPath &fieldPath);
std::unique_ptr<document::FieldValue> extractValueFieldFromStructMap(const document::FieldPath &fieldPath);
public:
DocumentFieldExtractor(const document::Document &doc);
~DocumentFieldExtractor();
std::unique_ptr<document::FieldValue> getFieldValue(const document::FieldPath &fieldPath);
/**
* Check if fieldPath is in a supported form.
*/
static bool isSupported(const document::FieldPath &fieldPath);
};
}
|