aboutsummaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahooinc.com>2021-11-29 09:25:54 +0000
committerArne H Juul <arnej@yahooinc.com>2021-11-29 09:25:54 +0000
commit3446278e9bee71cebe9b4b2ebcb90e371b049557 (patch)
tree81a409ec7c65e9cbc45ac31b585d06e728bd8045 /document
parentf1bdb9ea29174848d18c3b732929ed44ae00f356 (diff)
simpler wiring inside Apply class
Diffstat (limited to 'document')
-rw-r--r--document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java53
1 files changed, 24 insertions, 29 deletions
diff --git a/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java b/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java
index bd245cd6a05..0c34b12a2a5 100644
--- a/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java
+++ b/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java
@@ -76,8 +76,8 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub
}
}
private void apply(DocumentmanagerConfig config) {
- setupAnnotationTypesWithoutPayloads(config, manager);
- setupAnnotationRefTypes(config, manager);
+ setupAnnotationTypesWithoutPayloads(config);
+ setupAnnotationRefTypes(config);
log.log(Level.FINE, "Configuring document manager with " + config.datatype().size() + " data types.");
ArrayList<DocumentmanagerConfig.Datatype> failed = new ArrayList<>(config.datatype());
@@ -88,64 +88,61 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub
DocumentmanagerConfig.Datatype thisDataType = tmp.get(i);
int id = thisDataType.id();
try {
- registerTypeIdMapping(manager, thisDataType, id);
+ registerTypeIdMapping(thisDataType, id);
} catch (IllegalArgumentException e) {
failed.add(thisDataType);
}
}
}
- addStructInheritance(config, manager);
- addAnnotationTypePayloads(config, manager);
- addAnnotationTypeInheritance(config, manager);
+ addStructInheritance(config);
+ addAnnotationTypePayloads(config);
+ addAnnotationTypeInheritance(config);
manager.replaceTemporaryTypes();
}
- private void registerTypeIdMapping(DocumentTypeManager manager, DocumentmanagerConfig.Datatype thisDataType, int id) {
+ private void registerTypeIdMapping(DocumentmanagerConfig.Datatype thisDataType, int id) {
for (var o : thisDataType.arraytype()) {
- registerArrayType(manager, id, o);
+ registerArrayType(id, o);
}
for (var o : thisDataType.maptype()) {
- registerMapType(manager, id, o);
+ registerMapType(id, o);
}
for (var o : thisDataType.weightedsettype()) {
- registerWeightedSetType(manager, id, o);
+ registerWeightedSetType(id, o);
}
for (var o : thisDataType.structtype()) {
- registerStructType(manager, id, o);
+ registerStructType(id, o);
}
for (var o : thisDataType.documenttype()) {
- registerDocumentType(manager, o);
+ registerDocumentType(o);
}
for (var o : thisDataType.referencetype()) {
- registerReferenceType(manager, id, o);
+ registerReferenceType(id, o);
}
}
- private void registerArrayType(DocumentTypeManager manager, int id,
- DocumentmanagerConfig.Datatype.Arraytype array) {
+ private void registerArrayType(int id, DocumentmanagerConfig.Datatype.Arraytype array) {
DataType nestedType = manager.getDataType(array.datatype(), "");
ArrayDataType type = new ArrayDataType(nestedType, id);
manager.register(type);
}
- private void registerMapType(DocumentTypeManager manager, int id,
- DocumentmanagerConfig.Datatype.Maptype map) {
+ private void registerMapType(int id, DocumentmanagerConfig.Datatype.Maptype map) {
DataType keyType = manager.getDataType(map.keytype(), "");
DataType valType = manager.getDataType(map.valtype(), "");
MapDataType type = new MapDataType(keyType, valType, id);
manager.register(type);
}
- private void registerWeightedSetType(DocumentTypeManager manager, int id,
- DocumentmanagerConfig.Datatype.Weightedsettype wset) {
+ private void registerWeightedSetType(int id, DocumentmanagerConfig.Datatype.Weightedsettype wset) {
DataType nestedType = manager.getDataType(wset.datatype(), "");
WeightedSetDataType type = new WeightedSetDataType(
nestedType, wset.createifnonexistant(), wset.removeifzero(), id);
manager.register(type);
}
- private void registerDocumentType(DocumentTypeManager manager, DocumentmanagerConfig.Datatype.Documenttype doc) {
+ private void registerDocumentType(DocumentmanagerConfig.Datatype.Documenttype doc) {
StructDataType header = (StructDataType) manager.getDataType(doc.headerstruct(), "");
var importedFields = doc.importedfield().stream()
.map(f -> f.name())
@@ -167,8 +164,7 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub
manager.register(type);
}
- private void registerStructType(DocumentTypeManager manager, int id,
- DocumentmanagerConfig.Datatype.Structtype struct) {
+ private void registerStructType(int id, DocumentmanagerConfig.Datatype.Structtype struct) {
StructDataType type = new StructDataType(id, struct.name());
for (var field : struct.field()) {
@@ -192,8 +188,7 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub
manager.register(type);
}
- private void registerReferenceType(DocumentTypeManager manager, int id,
- DocumentmanagerConfig.Datatype.Referencetype refType) {
+ private void registerReferenceType(int id, DocumentmanagerConfig.Datatype.Referencetype refType) {
ReferenceDataType referenceType;
if (manager.hasDataType(refType.target_type_id())) {
DocumentType targetDocType = (DocumentType)manager.getDataType(refType.target_type_id());
@@ -206,7 +201,7 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub
manager.register(referenceType);
}
- private void setupAnnotationRefTypes(DocumentmanagerConfig config, DocumentTypeManager manager) {
+ private void setupAnnotationRefTypes(DocumentmanagerConfig config) {
for (int i = 0; i < config.datatype().size(); i++) {
DocumentmanagerConfig.Datatype thisDataType = config.datatype(i);
int id = thisDataType.id();
@@ -221,14 +216,14 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub
}
}
- private void setupAnnotationTypesWithoutPayloads(DocumentmanagerConfig config, DocumentTypeManager manager) {
+ private void setupAnnotationTypesWithoutPayloads(DocumentmanagerConfig config) {
for (DocumentmanagerConfig.Annotationtype annType : config.annotationtype()) {
AnnotationType annotationType = new AnnotationType(annType.name(), annType.id());
manager.getAnnotationTypeRegistry().register(annotationType);
}
}
- private void addAnnotationTypePayloads(DocumentmanagerConfig config, DocumentTypeManager manager) {
+ private void addAnnotationTypePayloads(DocumentmanagerConfig config) {
for (DocumentmanagerConfig.Annotationtype annType : config.annotationtype()) {
AnnotationType annotationType = manager.getAnnotationTypeRegistry().getType(annType.id());
DataType payload = manager.getDataType(annType.datatype(), "");
@@ -239,7 +234,7 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub
}
- private void addAnnotationTypeInheritance(DocumentmanagerConfig config, DocumentTypeManager manager) {
+ private void addAnnotationTypeInheritance(DocumentmanagerConfig config) {
for (DocumentmanagerConfig.Annotationtype annType : config.annotationtype()) {
if (annType.inherits().size() > 0) {
AnnotationType inheritedType = manager.getAnnotationTypeRegistry().getType(annType.inherits(0).id());
@@ -249,7 +244,7 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub
}
}
- private void addStructInheritance(DocumentmanagerConfig config, DocumentTypeManager manager) {
+ private void addStructInheritance(DocumentmanagerConfig config) {
for (int i = 0; i < config.datatype().size(); i++) {
DocumentmanagerConfig.Datatype thisDataType = config.datatype(i);
int id = thisDataType.id();