blob: 34bb6e1db2e7a153c0c89c8635fa3bd4568e8ed5 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.processing;
import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.document.Field;
import com.yahoo.schema.RankProfileRegistry;
import com.yahoo.schema.Schema;
import com.yahoo.schema.document.Attribute;
import com.yahoo.tensor.TensorType;
import com.yahoo.vespa.model.container.search.QueryProfiles;
import java.util.Optional;
/**
* Validates the 'paged' attribute setting and throws if specified on unsupported types.
*
* @author geirst
*/
public class PagedAttributeValidator extends Processor {
public PagedAttributeValidator(Schema schema,
DeployLogger deployLogger,
RankProfileRegistry rankProfileRegistry,
QueryProfiles queryProfiles) {
super(schema, deployLogger, rankProfileRegistry, queryProfiles);
}
@Override
public void process(boolean validate, boolean documentsOnly) {
if (!validate) {
return;
}
for (var field : schema.allConcreteFields()) {
for (var attribute : field.getAttributes().values()) {
if (attribute.isPaged()) {
validatePagedSetting(field, attribute);
}
}
}
}
private void validatePagedSetting(Field field, Attribute attribute) {
if (!isSupportedType(attribute)) {
fail(schema, field, "The 'paged' attribute setting is not supported for non-dense tensor, predicate and reference types");
}
}
private boolean isSupportedType(Attribute attribute) {
var type = attribute.getType();
return (type != Attribute.Type.PREDICATE) &&
(type != Attribute.Type.REFERENCE) &&
(isSupportedTensorType(attribute.tensorType()));
}
private boolean isSupportedTensorType(Optional<TensorType> tensorType) {
if (tensorType.isPresent()) {
return isDenseTensorType(tensorType.get());
}
return true;
}
private boolean isDenseTensorType(TensorType type) {
return type.dimensions().stream().allMatch(d -> d.isIndexed());
}
}
|