summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahooinc.com>2021-12-01 04:17:21 +0000
committerArne H Juul <arnej@yahooinc.com>2021-12-01 06:12:22 +0000
commit7a5b37439b1aa8c73ab7731bbd1e92fa5bb02bc1 (patch)
treecb92a31c18b6568b817751a7b7098f6838570e04 /document
parentac692ee0a41d794a99998dc7aa36a0d858cee455 (diff)
remove support for registering temporary types in DocumentTypeManager
Diffstat (limited to 'document')
-rw-r--r--document/src/main/java/com/yahoo/document/DocumentTypeManager.java96
1 files changed, 6 insertions, 90 deletions
diff --git a/document/src/main/java/com/yahoo/document/DocumentTypeManager.java b/document/src/main/java/com/yahoo/document/DocumentTypeManager.java
index 55320eb8501..80ceac457b9 100644
--- a/document/src/main/java/com/yahoo/document/DocumentTypeManager.java
+++ b/document/src/main/java/com/yahoo/document/DocumentTypeManager.java
@@ -190,6 +190,12 @@ public class DocumentTypeManager {
@SuppressWarnings("deprecation")
void registerSingleType(DataType type) {
if (type instanceof TensorDataType) return; // built-in dynamic: Created on the fly
+ if (type instanceof TemporaryDataType) {
+ throw new IllegalArgumentException("TemporaryDataType no longer supported: " + type);
+ }
+ if (type instanceof TemporaryStructuredDataType) {
+ throw new IllegalArgumentException("TemporaryStructuredDataType no longer supported: " + type);
+ }
if (dataTypes.containsKey(type.getId())) {
DataType existingType = dataTypes.get(type.getId());
if (((type instanceof TemporaryDataType) || (type instanceof TemporaryStructuredDataType))
@@ -310,96 +316,6 @@ public class DocumentTypeManager {
return annotationTypeRegistry;
}
- void replaceTemporaryTypes() {
- for (DataType type : dataTypes.values()) {
- List<DataType> seenStructs = new LinkedList<>();
- replaceTemporaryTypes(type, seenStructs);
- }
- }
-
- @SuppressWarnings("deprecation")
- private void replaceTemporaryTypes(DataType type, List<DataType> seenStructs) {
- if (type instanceof WeightedSetDataType) {
- replaceTemporaryTypesInWeightedSet((WeightedSetDataType) type, seenStructs);
- } else if (type instanceof MapDataType) {
- replaceTemporaryTypesInMap((MapDataType) type, seenStructs);
- } else if (type instanceof CollectionDataType) {
- replaceTemporaryTypesInCollection((CollectionDataType) type, seenStructs);
- } else if (type instanceof StructDataType) {
- replaceTemporaryTypesInStruct((StructDataType) type, seenStructs);
- } else if (type instanceof PrimitiveDataType) {
- //OK because these types are always present
- } else if (type instanceof AnnotationReferenceDataType) {
- //OK because this type is always present
- } else if (type instanceof DocumentType) {
- //OK because this type is always present
- } else if (type instanceof TensorDataType) {
- //OK because this type is always present
- } else if (type instanceof ReferenceDataType) {
- replaceTemporaryTypeInReference((ReferenceDataType) type);
- } else if (type instanceof TemporaryDataType) {
- throw new IllegalStateException("TemporaryDataType registered in DocumentTypeManager, BUG!!");
- } else {
- log.warning("Don't know how to replace temporary data types in " + type);
- }
- }
-
- @SuppressWarnings("deprecation")
- private void replaceTemporaryTypesInStruct(StructDataType structDataType, List<DataType> seenStructs) {
- seenStructs.add(structDataType);
- for (Field field : structDataType.getFieldsThisTypeOnly()) {
- DataType fieldType = field.getDataType();
- if (fieldType instanceof TemporaryDataType) {
- field.setDataType(getDataType(fieldType.getCode(), ((TemporaryDataType)fieldType).getDetailedType()));
- } else {
- if (!seenStructs.contains(fieldType)) {
- replaceTemporaryTypes(fieldType, seenStructs);
- }
- }
- }
- }
-
- @SuppressWarnings("deprecation")
- private void replaceTemporaryTypeInReference(ReferenceDataType referenceDataType) {
- if (referenceDataType.getTargetType() instanceof TemporaryStructuredDataType) {
- referenceDataType.setTargetType((DocumentType) getDataType(referenceDataType.getTargetType().getId()));
- }
- // TODO should we recursively invoke replaceTemporaryTypes for the target type? It should only ever be a doc type
- }
-
- @SuppressWarnings("deprecation")
- private void replaceTemporaryTypesInCollection(CollectionDataType collectionDataType, List<DataType> seenStructs) {
- if (collectionDataType.getNestedType() instanceof TemporaryDataType) {
- collectionDataType.setNestedType(getDataType(collectionDataType.getNestedType().getCode(), ""));
- } else {
- replaceTemporaryTypes(collectionDataType.getNestedType(), seenStructs);
- }
- }
-
- @SuppressWarnings("deprecation")
- private void replaceTemporaryTypesInMap(MapDataType mapDataType, List<DataType> seenStructs) {
- if (mapDataType.getValueType() instanceof TemporaryDataType) {
- mapDataType.setValueType(getDataType(mapDataType.getValueType().getCode(), ""));
- } else {
- replaceTemporaryTypes(mapDataType.getValueType(), seenStructs);
- }
-
- if (mapDataType.getKeyType() instanceof TemporaryDataType) {
- mapDataType.setKeyType(getDataType(mapDataType.getKeyType().getCode(), ""));
- } else {
- replaceTemporaryTypes(mapDataType.getKeyType(), seenStructs);
- }
- }
-
- @SuppressWarnings("deprecation")
- private void replaceTemporaryTypesInWeightedSet(WeightedSetDataType weightedSetDataType, List<DataType> seenStructs) {
- if (weightedSetDataType.getNestedType() instanceof TemporaryDataType) {
- weightedSetDataType.setNestedType(getDataType(weightedSetDataType.getNestedType().getCode(), ""));
- } else {
- replaceTemporaryTypes(weightedSetDataType.getNestedType(), seenStructs);
- }
- }
-
public void shutdown() {
if (subscriber!=null) subscriber.close();
}