blob: 5054de54c6c3eb6d6e1d635ccccda2e5aba0ad20 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "document_type_inspector.h"
#include <vespa/document/base/exceptions.h>
#include <vespa/document/base/fieldpath.h>
using document::FieldPath;
using document::FieldPathEntry;
namespace proton {
DocumentTypeInspector::DocumentTypeInspector(const document::DocumentType &oldDocType,
const document::DocumentType &newDocType)
: _oldDocType(oldDocType),
_newDocType(newDocType)
{
}
bool
DocumentTypeInspector::hasUnchangedField(const vespalib::string &name) const
{
FieldPath oldPath;
FieldPath newPath;
try {
_oldDocType.buildFieldPath(oldPath, name);
_newDocType.buildFieldPath(newPath, name);
} catch (document::FieldNotFoundException &e) {
return false;
} catch (vespalib::IllegalArgumentException &e) {
return false;
}
if (oldPath.size() != newPath.size()) {
return false;
}
for (uint32_t i = 0; i < oldPath.size(); ++i) {
const auto &oldEntry = oldPath[i];
const auto &newEntry = newPath[i];
if (oldEntry.getType() != newEntry.getType() ||
oldEntry.getDataType() != newEntry.getDataType()) {
return false;
}
}
return true;
}
} // namespace proton
|