From e836c45f4b9900bdfa72987a96a13087b106b757 Mon Sep 17 00:00:00 2001 From: Arne H Juul Date: Tue, 31 May 2022 16:50:18 +0000 Subject: remove some cruft --- .../main/java/com/yahoo/schema/Application.java | 5 - .../com/yahoo/schema/FieldOperationApplier.java | 32 ---- .../schema/FieldOperationApplierForSearch.java | 23 --- .../schema/FieldOperationApplierForStructs.java | 20 --- .../java/com/yahoo/schema/document/SDField.java | 28 +--- .../schema/fieldoperation/AliasOperation.java | 42 ----- .../schema/fieldoperation/AttributeOperation.java | 172 --------------------- .../schema/fieldoperation/BoldingOperation.java | 25 --- .../schema/fieldoperation/DictionaryOperation.java | 41 ----- .../fieldoperation/FieldOperationContainer.java | 19 --- .../yahoo/schema/fieldoperation/IdOperation.java | 35 ----- .../schema/fieldoperation/IndexOperation.java | 134 ---------------- .../schema/fieldoperation/MatchOperation.java | 65 -------- .../fieldoperation/NormalizingOperation.java | 34 ---- .../fieldoperation/QueryCommandOperation.java | 25 --- .../yahoo/schema/fieldoperation/RankOperation.java | 36 ----- .../schema/fieldoperation/RankTypeOperation.java | 43 ------ .../schema/fieldoperation/SortingOperation.java | 93 ----------- .../schema/fieldoperation/StemmingOperation.java | 26 ---- .../fieldoperation/StructFieldOperation.java | 56 ------- .../SummaryInFieldLongOperation.java | 70 --------- .../fieldoperation/SummaryInFieldOperation.java | 46 ------ .../SummaryInFieldShortOperation.java | 32 ---- .../schema/fieldoperation/SummaryToOperation.java | 41 ----- .../schema/fieldoperation/WeightOperation.java | 25 --- .../fieldoperation/WeightedSetOperation.java | 70 --------- 26 files changed, 1 insertion(+), 1237 deletions(-) delete mode 100644 config-model/src/main/java/com/yahoo/schema/FieldOperationApplier.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/FieldOperationApplierForSearch.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/FieldOperationApplierForStructs.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/AliasOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/AttributeOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/BoldingOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/DictionaryOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/FieldOperationContainer.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/IdOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/IndexOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/MatchOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/NormalizingOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/QueryCommandOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/RankOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/RankTypeOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/SortingOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/StemmingOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/StructFieldOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryInFieldLongOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryInFieldOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryInFieldShortOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryToOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/WeightOperation.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/fieldoperation/WeightedSetOperation.java diff --git a/config-model/src/main/java/com/yahoo/schema/Application.java b/config-model/src/main/java/com/yahoo/schema/Application.java index aa47818ff99..b147388747e 100644 --- a/config-model/src/main/java/com/yahoo/schema/Application.java +++ b/config-model/src/main/java/com/yahoo/schema/Application.java @@ -66,10 +66,6 @@ public class Application { var orderer = new SDDocumentTypeOrderer(sdocs, logger); orderer.process(); - for (SDDocumentType sdoc : orderer.getOrdered()) { - new FieldOperationApplierForStructs().process(sdoc); - new FieldOperationApplier().process(sdoc); - } var resolver = new DocumentReferenceResolver(schemas); sdocs.forEach(resolver::resolveReferences); @@ -82,7 +78,6 @@ public class Application { List schemasSomewhatOrdered = new ArrayList<>(schemas); for (Schema schema : new SearchOrderer().order(schemasSomewhatOrdered)) { - new FieldOperationApplierForSearch().process(schema); // TODO: Why is this not in the regular list? new Processing(properties).process(schema, logger, rankProfileRegistry, diff --git a/config-model/src/main/java/com/yahoo/schema/FieldOperationApplier.java b/config-model/src/main/java/com/yahoo/schema/FieldOperationApplier.java deleted file mode 100644 index b2f40b045ea..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/FieldOperationApplier.java +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema; - -import com.yahoo.document.Field; -import com.yahoo.schema.document.SDDocumentType; -import com.yahoo.schema.document.SDField; - -/** - * @author Einar M R Rosenvinge - */ -public class FieldOperationApplier { - - public void process(SDDocumentType sdoc) { - if (!sdoc.isStruct()) { - apply(sdoc); - } - } - - protected void apply(SDDocumentType type) { - for (Field field : type.fieldSet()) { - apply(field); - } - } - - protected void apply(Field field) { - if (field instanceof SDField) { - SDField sdField = (SDField) field; - sdField.applyOperations(); - } - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/FieldOperationApplierForSearch.java b/config-model/src/main/java/com/yahoo/schema/FieldOperationApplierForSearch.java deleted file mode 100644 index b107dbaea59..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/FieldOperationApplierForSearch.java +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema; - -import com.yahoo.document.Field; -import com.yahoo.schema.document.SDDocumentType; - -/** - * @author Einar M R Rosenvinge - */ -public class FieldOperationApplierForSearch extends FieldOperationApplier { - - @Override - public void process(SDDocumentType sdoc) { - //Do nothing - } - - public void process(Schema schema) { - for (Field field : schema.extraFieldList()) { - apply(field); - } - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/FieldOperationApplierForStructs.java b/config-model/src/main/java/com/yahoo/schema/FieldOperationApplierForStructs.java deleted file mode 100644 index 1ec1de6a9c6..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/FieldOperationApplierForStructs.java +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema; - -import com.yahoo.schema.document.SDDocumentType; - -/** - * @author Einar M R Rosenvinge - */ -public class FieldOperationApplierForStructs extends FieldOperationApplier { - - @Override - public void process(SDDocumentType sdoc) { - for (SDDocumentType type : sdoc.getAllTypes()) { - if (type.isStruct()) { - apply(type); - } - } - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/document/SDField.java b/config-model/src/main/java/com/yahoo/schema/document/SDField.java index 668b6388620..fbb2b2dc21f 100644 --- a/config-model/src/main/java/com/yahoo/schema/document/SDField.java +++ b/config-model/src/main/java/com/yahoo/schema/document/SDField.java @@ -16,8 +16,6 @@ import com.yahoo.language.process.Embedder; import com.yahoo.language.simple.SimpleLinguistics; import com.yahoo.schema.Index; import com.yahoo.schema.Schema; -import com.yahoo.schema.fieldoperation.FieldOperation; -import com.yahoo.schema.fieldoperation.FieldOperationContainer; import com.yahoo.tensor.TensorType; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.indexinglanguage.ExpressionSearcher; @@ -50,7 +48,7 @@ import java.util.TreeMap; * * @author bratseth */ -public class SDField extends Field implements TypedKey, FieldOperationContainer, ImmutableSDField { +public class SDField extends Field implements TypedKey, ImmutableSDField { /** Use this field for modifying index-structure, even if it doesn't have any indexing code */ private boolean indexStructureField = false; @@ -118,9 +116,6 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer, /** The aliases declared for this field. May pertain to indexes or attributes */ private final Map aliasToName = new HashMap<>(); - /** Pending operations that must be applied after parsing, due to use of not-yet-defined structs. */ - private final List pendingOperations = new LinkedList<>(); - private boolean isExtraField = false; private boolean wasConfiguredToDoAttributing = false; @@ -351,27 +346,6 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer, private Matching matchingForStructFields = null; - public void addOperation(FieldOperation op) { - pendingOperations.add(op); - } - - @Override - public void applyOperations(SDField field) { - if (pendingOperations.isEmpty()) return; - - Collections.sort(pendingOperations); - ListIterator ops = pendingOperations.listIterator(); - while (ops.hasNext()) { - FieldOperation op = ops.next(); - ops.remove(); - op.apply(field); - } - } - - public void applyOperations() { - applyOperations(this); - } - public void setId(int fieldId, DocumentType owner) { super.setId(fieldId, owner); idOverride = true; diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/AliasOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/AliasOperation.java deleted file mode 100644 index b5648dde4fc..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/AliasOperation.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.SDField; - -/** - * @author Einar M R Rosenvinge - */ -public class AliasOperation implements FieldOperation { - - private String aliasedName; - private String alias; - - public AliasOperation(String aliasedName, String alias) { - this.aliasedName = aliasedName; - this.alias = alias; - } - - public String getAliasedName() { - return aliasedName; - } - - public void setAliasedName(String aliasedName) { - this.aliasedName = aliasedName; - } - - public String getAlias() { - return alias; - } - - public void setAlias(String alias) { - this.alias = alias; - } - - public void apply(SDField field) { - if (aliasedName == null) { - aliasedName = field.getName(); - } - field.getAliasToName().put(alias, aliasedName); - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/AttributeOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/AttributeOperation.java deleted file mode 100644 index 3983137129d..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/AttributeOperation.java +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.Attribute; -import com.yahoo.schema.document.SDField; -import com.yahoo.tensor.TensorType; - -import java.util.Locale; -import java.util.Optional; - -/** - * @author Einar M R Rosenvinge - */ -public class AttributeOperation implements FieldOperation, FieldOperationContainer { - - private final String name; - private Boolean huge; - private Boolean fastSearch; - private Boolean fastAccess; - private Boolean mutable; - private Boolean paged; - private Boolean enableBitVectors; - private Boolean enableOnlyBitVector; - //TODO: Remember sorting!! - private boolean doAlias = false; - private String alias; - private String aliasedName; - private Optional tensorType = Optional.empty(); - private Optional distanceMetric = Optional.empty(); - - public AttributeOperation(String name) { - this.name = name; - } - - @Override - public void addOperation(FieldOperation op) { - //TODO: Implement this method: - - } - - @Override - public void applyOperations(SDField field) { - //TODO: Implement this method: - } - - @Override - public String getName() { - return name; - } - - public Boolean getHuge() { - return huge; - } - - public void setHuge(Boolean huge) { - this.huge = huge; - } - - public Boolean getFastSearch() { - return fastSearch; - } - - public void setFastSearch(Boolean fastSearch) { - this.fastSearch = fastSearch; - } - - public Boolean getFastAccess() { - return fastAccess; - } - - public void setFastAccess(Boolean fastAccess) { - this.fastAccess = fastAccess; - } - public void setMutable(Boolean mutable) { - this.mutable = mutable; - } - public void setPaged(Boolean paged) { - this.paged = paged; - } - - public Boolean getEnableBitVectors() { - return enableBitVectors; - } - - public void setEnableBitVectors(Boolean enableBitVectors) { - this.enableBitVectors = enableBitVectors; - } - - public Boolean getEnableOnlyBitVector() { - return enableOnlyBitVector; - } - - public void setEnableOnlyBitVector(Boolean enableOnlyBitVector) { - this.enableOnlyBitVector = enableOnlyBitVector; - } - - public void setDoAlias(boolean doAlias) { - this.doAlias = doAlias; - } - - public String getAlias() { - return alias; - } - - public void setAlias(String alias) { - this.alias = alias; - } - - - public void setAliasedName(String aliasedName) { - this.aliasedName = aliasedName; - } - - public void setTensorType(TensorType tensorType) { - this.tensorType = Optional.of(tensorType); - } - - public void setDistanceMetric(String value) { - this.distanceMetric = Optional.of(value); - } - - public void apply(SDField field) { - Attribute attribute = null; - if (attributeIsSuffixOfStructField(field.getName())) { - attribute = field.getAttributes().get(field.getName()); - } - if (attribute == null) { - attribute = field.getAttributes().get(name); - if (attribute == null) { - attribute = new Attribute(name, field.getDataType()); - field.addAttribute(attribute); - } - } - - if (huge != null) { - attribute.setHuge(huge); - } - if (paged != null) { - attribute.setPaged(paged); - } - if (fastSearch != null) { - attribute.setFastSearch(fastSearch); - } - if (fastAccess != null) { - attribute.setFastAccess(fastAccess); - } - if (mutable != null) { - attribute.setMutable(mutable); - } - if (enableBitVectors != null) { - attribute.setEnableBitVectors(enableBitVectors); - } - if (enableOnlyBitVector != null) { - attribute.setEnableOnlyBitVector(enableOnlyBitVector); - } - if (doAlias) { - field.getAliasToName().put(alias, aliasedName); - } - if (tensorType.isPresent()) { - attribute.setTensorType(tensorType.get()); - } - if (distanceMetric.isPresent()) { - String upper = distanceMetric.get().toUpperCase(Locale.ENGLISH); - attribute.setDistanceMetric(Attribute.DistanceMetric.valueOf(upper)); - } - } - - private boolean attributeIsSuffixOfStructField(String fieldName) { - return ((fieldName.indexOf('.') != -1) && fieldName.endsWith(name)); - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/BoldingOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/BoldingOperation.java deleted file mode 100644 index 74e69e047ef..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/BoldingOperation.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.SDField; -import com.yahoo.vespa.documentmodel.SummaryField; - -/** - * @author Einar M R Rosenvinge - */ -public class BoldingOperation implements FieldOperation { - - private final boolean bold; - - public BoldingOperation(boolean bold) { - this.bold = bold; - } - - public void apply(SDField field) { - SummaryField summaryField = field.getSummaryField(field.getName(), true); - summaryField.addSource(field.getName()); - summaryField.addDestination("default"); - summaryField.setTransform(bold ? summaryField.getTransform().bold() : summaryField.getTransform().unbold()); - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/DictionaryOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/DictionaryOperation.java deleted file mode 100644 index a9a2ce7cbb1..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/DictionaryOperation.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.Case; -import com.yahoo.schema.document.Dictionary; -import com.yahoo.schema.document.SDField; - -/** - * Represents operations controlling setup of dictionary used for queries - * - * @author baldersheim - */ -public class DictionaryOperation implements FieldOperation { - public enum Operation { HASH, BTREE, CASED, UNCASED } - private final Operation operation; - - public DictionaryOperation(Operation type) { - this.operation = type; - } - @Override - public void apply(SDField field) { - Dictionary dictionary = field.getOrSetDictionary(); - switch (operation) { - case HASH: - dictionary.updateType(Dictionary.Type.HASH); - break; - case BTREE: - dictionary.updateType(Dictionary.Type.BTREE); - break; - case CASED: - dictionary.updateMatch(Case.CASED); - break; - case UNCASED: - dictionary.updateMatch(Case.UNCASED); - break; - default: - throw new IllegalArgumentException("Unhandled operation " + operation); - } - } -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/FieldOperationContainer.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/FieldOperationContainer.java deleted file mode 100644 index d5e52fadffa..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/FieldOperationContainer.java +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.SDField; - -/** - * @author Einar M R Rosenvinge - */ -public interface FieldOperationContainer { - - /** Adds an operation */ - void addOperation(FieldOperation op); - - /** Apply all operations. Operations must be sorted in their natural order before applying each operation. */ - void applyOperations(SDField field); - - String getName(); - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/IdOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/IdOperation.java deleted file mode 100644 index 5e62742085f..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/IdOperation.java +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.SDDocumentType; -import com.yahoo.schema.document.SDField; - -/** - * @author Einar M R Rosenvinge - */ -public class IdOperation implements FieldOperation { - - private SDDocumentType document; - private int fieldId; - - public SDDocumentType getDocument() { - return document; - } - - public void setDocument(SDDocumentType document) { - this.document = document; - } - - public int getFieldId() { - return fieldId; - } - - public void setFieldId(int fieldId) { - this.fieldId = fieldId; - } - - public void apply(SDField field) { - document.setFieldId(field, fieldId); - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/IndexOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/IndexOperation.java deleted file mode 100644 index ab5ffa25f33..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/IndexOperation.java +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.Index; -import com.yahoo.schema.Index.Type; -import com.yahoo.schema.document.BooleanIndexDefinition; -import com.yahoo.schema.document.HnswIndexParams; -import com.yahoo.schema.document.SDField; -import com.yahoo.schema.document.Stemming; - -import java.util.LinkedList; -import java.util.List; -import java.util.Optional; -import java.util.OptionalDouble; -import java.util.OptionalInt; -import java.util.OptionalLong; - -/** - * @author Einar M R Rosenvinge - */ -public class IndexOperation implements FieldOperation { - - private String indexName; - private Optional prefix = Optional.empty(); - private List aliases = new LinkedList<>(); - private Optional stemming = Optional.empty(); - private Optional type = Optional.empty(); - - private OptionalInt arity = OptionalInt.empty(); // For predicate data type - private OptionalLong lowerBound = OptionalLong.empty(); - private OptionalLong upperBound = OptionalLong.empty(); - private OptionalDouble densePostingListThreshold = OptionalDouble.empty(); - private Optional enableBm25 = Optional.empty(); - - private Optional hnswIndexParams = Optional.empty(); - - public String getIndexName() { - return indexName; - } - - public void setIndexName(String indexName) { - this.indexName = indexName; - } - - public boolean getPrefix() { - return prefix.get(); - } - - public void setPrefix(Boolean prefix) { - this.prefix = Optional.of(prefix); - } - - public void addAlias(String alias) { - aliases.add(alias); - } - - public String getStemming() { - return stemming.get(); - } - - public void setStemming(String stemming) { - this.stemming = Optional.of(stemming); - } - - public void apply(SDField field) { - Index index = field.getIndex(indexName); - - if (index == null) { - index = new Index(indexName); - field.addIndex(index); - } - - applyToIndex(index); - } - - public void applyToIndex(Index index) { - if (prefix.isPresent()) { - index.setPrefix(prefix.get()); - } - for (String alias : aliases) { - index.addAlias(alias); - } - if (stemming.isPresent()) { - index.setStemming(Stemming.get(stemming.get())); - } - if (type.isPresent()) { - index.setType(type.get()); - } - if (arity.isPresent() || lowerBound.isPresent() || - upperBound.isPresent() || densePostingListThreshold.isPresent()) { - index.setBooleanIndexDefiniton( - new BooleanIndexDefinition(arity, lowerBound, upperBound, densePostingListThreshold)); - } - if (enableBm25.isPresent()) { - index.setInterleavedFeatures(enableBm25.get()); - } - if (hnswIndexParams.isPresent()) { - index.setHnswIndexParams(hnswIndexParams.get().build()); - } - } - - public Type getType() { - return type.get(); - } - - public void setType(Type type) { - this.type = Optional.of(type); - } - - public void setArity(int arity) { - this.arity = OptionalInt.of(arity); - } - - public void setLowerBound(long value) { - this.lowerBound = OptionalLong.of(value); - } - - public void setUpperBound(long value) { - this.upperBound = OptionalLong.of(value); - } - - public void setDensePostingListThreshold(double densePostingListThreshold) { - this.densePostingListThreshold = OptionalDouble.of(densePostingListThreshold); - } - - public void setEnableBm25(boolean value) { - enableBm25 = Optional.of(value); - } - - public void setHnswIndexParams(HnswIndexParams.Builder params) { - this.hnswIndexParams = Optional.of(params); - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/MatchOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/MatchOperation.java deleted file mode 100644 index a568b5b0f66..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/MatchOperation.java +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.Case; -import com.yahoo.schema.document.MatchAlgorithm; -import com.yahoo.schema.document.MatchType; -import com.yahoo.schema.document.SDField; - -/** - * @author Einar M R Rosenvinge - */ -public class MatchOperation implements FieldOperation { - - private MatchType matchingType; - private Case casing; - private Integer gramSize; - private Integer maxLength; - private MatchAlgorithm matchingAlgorithm; - private String exactMatchTerminator; - - public void setMatchingType(MatchType matchingType) { - this.matchingType = matchingType; - } - - public void setGramSize(Integer gramSize) { - this.gramSize = gramSize; - } - public void setMaxLength(Integer maxLength) { - this.maxLength = maxLength; - } - - public void setMatchingAlgorithm(MatchAlgorithm matchingAlgorithm) { - this.matchingAlgorithm = matchingAlgorithm; - } - - public void setExactMatchTerminator(String exactMatchTerminator) { - this.exactMatchTerminator = exactMatchTerminator; - } - - public void setCase(Case casing) { - this.casing = casing; - } - - public void apply(SDField field) { - if (matchingType != null) { - field.setMatchingType(matchingType); - } - if (casing != null) { - field.setMatchingCase(casing); - } - if (gramSize != null) { - field.getMatching().setGramSize(gramSize); - } - if (maxLength != null) { - field.getMatching().maxLength(maxLength); - } - if (matchingAlgorithm != null) { - field.setMatchingAlgorithm(matchingAlgorithm); - } - if (exactMatchTerminator != null) { - field.getMatching().setExactMatchTerminator(exactMatchTerminator); - } - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/NormalizingOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/NormalizingOperation.java deleted file mode 100644 index 561c5b87899..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/NormalizingOperation.java +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.NormalizeLevel; -import com.yahoo.schema.document.SDField; - -/** - * @author Einar M R Rosenvinge - */ -public class NormalizingOperation implements FieldOperation { - - private final NormalizeLevel.Level level; - - public NormalizingOperation(String setting) { - if ("none".equals(setting)) { - this.level = NormalizeLevel.Level.NONE; - } else if ("codepoint".equals(setting)) { - this.level = NormalizeLevel.Level.CODEPOINT; - } else if ("lowercase".equals(setting)) { - this.level = NormalizeLevel.Level.LOWERCASE; - } else if ("accent".equals(setting)) { - this.level = NormalizeLevel.Level.ACCENT; - } else if ("all".equals(setting)) { - this.level = NormalizeLevel.Level.ACCENT; - } else { - throw new IllegalArgumentException("invalid normalizing setting: " + setting); - } - } - - public void apply(SDField field) { - field.setNormalizing(new NormalizeLevel(level, true)); - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/QueryCommandOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/QueryCommandOperation.java deleted file mode 100644 index d0e9feb41e4..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/QueryCommandOperation.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.SDField; - -import java.util.List; - -/** - * @author Einar M R Rosenvinge - */ -public class QueryCommandOperation implements FieldOperation { - - private final List queryCommands = new java.util.ArrayList<>(0); - - public void addQueryCommand(String name) { - queryCommands.add(name); - } - - public void apply(SDField field) { - for (String command : queryCommands) { - field.addQueryCommand(command); - } - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/RankOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/RankOperation.java deleted file mode 100644 index bbc6208ba1b..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/RankOperation.java +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.SDField; - -/** - * @author Einar M R Rosenvinge - */ -public class RankOperation implements FieldOperation { - - private Boolean literal = null; - private Boolean filter = null; - private Boolean normal = null; - - public Boolean getLiteral() { return literal; } - public void setLiteral(Boolean literal) { this.literal = literal; } - - public Boolean getFilter() { return filter; } - public void setFilter(Boolean filter) { this.filter = filter; } - - public Boolean getNormal() { return normal; } - public void setNormal(Boolean n) { this.normal = n; } - - public void apply(SDField field) { - if (literal != null) { - field.getRanking().setLiteral(literal); - } - if (filter != null) { - field.getRanking().setFilter(filter); - } - if (normal != null) { - field.getRanking().setNormal(normal); - } - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/RankTypeOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/RankTypeOperation.java deleted file mode 100644 index 4a43a907549..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/RankTypeOperation.java +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.RankType; -import com.yahoo.schema.document.SDField; -import com.yahoo.schema.Index; - -/** - * @author Einar M R Rosenvinge - */ -public class RankTypeOperation implements FieldOperation { - - private String indexName; - private RankType type; - - public String getIndexName() { - return indexName; - } - public void setIndexName(String indexName) { - this.indexName = indexName; - } - - public RankType getType() { - return type; - } - public void setType(RankType type) { - this.type = type; - } - - public void apply(SDField field) { - if (indexName == null) { - field.setRankType(type); // Set default if the index is not specified. - } else { - Index index = field.getIndex(indexName); - if (index == null) { - index = new Index(indexName); - field.addIndex(index); - } - index.setRankType(type); - } - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/SortingOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/SortingOperation.java deleted file mode 100644 index 2e981a893ce..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/SortingOperation.java +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.Attribute; -import com.yahoo.schema.document.SDField; -import com.yahoo.schema.document.Sorting; - -/** - * @author Einar M R Rosenvinge - */ -public class SortingOperation implements FieldOperation { - - private final String attributeName; - private Boolean ascending; - private Boolean descending; - private Sorting.Function function; - private Sorting.Strength strength; - private String locale; - - public SortingOperation(String attributeName) { - this.attributeName = attributeName; - } - - public String getAttributeName() { - return attributeName; - } - - public Boolean getAscending() { - return ascending; - } - - public void setAscending() { - this.ascending = true; - } - - public Boolean getDescending() { - return descending; - } - - public void setDescending() { - this.descending = true; - } - - public Sorting.Function getFunction() { - return function; - } - - public void setFunction(Sorting.Function function) { - this.function = function; - } - - public Sorting.Strength getStrength() { - return strength; - } - - public void setStrength(Sorting.Strength strength) { - this.strength = strength; - } - - public String getLocale() { - return locale; - } - - public void setLocale(String locale) { - this.locale = locale; - } - - public void apply(SDField field) { - Attribute attribute = field.getAttributes().get(attributeName); - if (attribute == null) { - attribute = new Attribute(attributeName, field.getDataType()); - field.addAttribute(attribute); - } - Sorting sorting = attribute.getSorting(); - - if (ascending != null) { - sorting.setAscending(); - } - if (descending != null) { - sorting.setDescending(); - } - if (function != null) { - sorting.setFunction(function); - } - if (strength != null) { - sorting.setStrength(strength); - } - if (locale != null) { - sorting.setLocale(locale); - } - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/StemmingOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/StemmingOperation.java deleted file mode 100644 index a4bb00b0d07..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/StemmingOperation.java +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.SDField; -import com.yahoo.schema.document.Stemming; - -/** - * @author Einar M R Rosenvinge - */ -public class StemmingOperation implements FieldOperation { - - private String setting; - - public String getSetting() { - return setting; - } - - public void setSetting(String setting) { - this.setting = setting; - } - - public void apply(SDField field) { - field.setStemming(Stemming.get(setting)); - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/StructFieldOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/StructFieldOperation.java deleted file mode 100644 index ac80f5023fc..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/StructFieldOperation.java +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.SDField; - -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; - -/** - * @author Einar M R Rosenvinge - */ -public class StructFieldOperation implements FieldOperation, FieldOperationContainer { - - private final String structFieldName; - private final List pendingOperations = new LinkedList<>(); - - public StructFieldOperation(String structFieldName) { - this.structFieldName = structFieldName; - } - - public void apply(SDField field) { - SDField structField = field.getStructField(structFieldName); - if (structField == null ) { - throw new IllegalArgumentException("Struct field '" + structFieldName + "' has not been defined in struct " + - "for field '" + field.getName() + "'."); - } - - applyOperations(structField); - } - - @Override - public void addOperation(FieldOperation op) { - pendingOperations.add(op); - } - - @Override - public void applyOperations(SDField field) { - if (pendingOperations.isEmpty()) return; - - Collections.sort(pendingOperations); - ListIterator ops = pendingOperations.listIterator(); - while (ops.hasNext()) { - FieldOperation op = ops.next(); - ops.remove(); - op.apply(field); - } - } - - @Override - public String getName() { - return structFieldName; - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryInFieldLongOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryInFieldLongOperation.java deleted file mode 100644 index 4576b7a34fe..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryInFieldLongOperation.java +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.document.DataType; -import com.yahoo.schema.document.SDField; -import com.yahoo.vespa.documentmodel.SummaryField; - -import java.util.Iterator; -import java.util.Set; - -/** - * @author Einar M R Rosenvinge - */ -public class SummaryInFieldLongOperation extends SummaryInFieldOperation { - - private DataType type; - private Boolean bold; - private Set destinations = new java.util.LinkedHashSet<>(); - - public SummaryInFieldLongOperation(String name) { - super(name); - } - - public SummaryInFieldLongOperation() { - super(null); - } - - public void setType(DataType type) { - this.type = type; - } - - public void setBold(Boolean bold) { - this.bold = bold; - } - - public void addDestination(String destination) { - destinations.add(destination); - } - - public Iterator destinationIterator() { - return destinations.iterator(); - } - - public void apply(SDField field) { - if (type == null) { - type = field.getDataType(); - } - SummaryField summary = new SummaryField(name, type); - applyToSummary(summary); - field.addSummaryField(summary); - } - - public void applyToSummary(SummaryField summary) { - if (transform != null) { - summary.setTransform(transform); - } - - if (bold != null) { - summary.setTransform(bold ? summary.getTransform().bold() : summary.getTransform().unbold()); - } - - for (SummaryField.Source source : sources) { - summary.addSource(source); - } - - for (String destination : destinations) { - summary.addDestination(destination); - } - } -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryInFieldOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryInFieldOperation.java deleted file mode 100644 index dd06d920aac..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryInFieldOperation.java +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.vespa.documentmodel.SummaryField; -import com.yahoo.vespa.documentmodel.SummaryTransform; - -import java.util.Set; - -/** - * @author Einar M R Rosenvinge - */ -public abstract class SummaryInFieldOperation implements FieldOperation { - - protected String name; - protected SummaryTransform transform; - protected Set sources = new java.util.LinkedHashSet<>(); - - public SummaryInFieldOperation(String name) { - this.name = name; - } - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setTransform(SummaryTransform transform) { - this.transform = transform; - } - - public SummaryTransform getTransform() { - return transform; - } - - public void addSource(String name) { - sources.add(new SummaryField.Source(name)); - } - - public void addSource(SummaryField.Source source) { - sources.add(source); - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryInFieldShortOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryInFieldShortOperation.java deleted file mode 100644 index ccc22719f25..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryInFieldShortOperation.java +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.SDField; -import com.yahoo.vespa.documentmodel.SummaryField; - -/** - * @author Einar M R Rosenvinge - */ -public class SummaryInFieldShortOperation extends SummaryInFieldOperation { - - public SummaryInFieldShortOperation(String name) { - super(name); - } - - public void apply(SDField field) { - SummaryField ret = field.getSummaryField(name); - if (ret == null) { - ret = new SummaryField(name, field.getDataType()); - ret.addSource(field.getName()); - ret.addDestination("default"); - } - ret.setImplicit(false); - - ret.setTransform(transform); - for (SummaryField.Source source : sources) { - ret.addSource(source); - } - field.addSummaryField(ret); - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryToOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryToOperation.java deleted file mode 100644 index 2d9cf3acf4e..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/SummaryToOperation.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.SDField; -import com.yahoo.vespa.documentmodel.SummaryField; - -import java.util.Set; - -/** - * @author Einar M R Rosenvinge - */ -public class SummaryToOperation implements FieldOperation { - - private Set destinations = new java.util.LinkedHashSet<>(); - private String name; - - public void setName(String name) { - this.name = name; - } - - public void addDestination(String destination) { - destinations.add(destination); - } - - public void apply(SDField field) { - SummaryField summary; - summary = field.getSummaryField(name); - if (summary == null) { - summary = new SummaryField(field); - summary.addSource(field.getName()); - summary.addDestination("default"); - field.addSummaryField(summary); - } - summary.setImplicit(false); - - for (String destination : destinations) { - summary.addDestination(destination); - } - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/WeightOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/WeightOperation.java deleted file mode 100644 index 57c28d9bdb5..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/WeightOperation.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.SDField; - -/** - * @author Einar M R Rosenvinge - */ -public class WeightOperation implements FieldOperation { - - private int weight; - - public int getWeight() { - return weight; - } - - public void setWeight(int weight) { - this.weight = weight; - } - - public void apply(SDField field) { - field.setWeight(weight); - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/WeightedSetOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/WeightedSetOperation.java deleted file mode 100644 index 8fb0cc9fcdb..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/fieldoperation/WeightedSetOperation.java +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema.fieldoperation; - -import com.yahoo.schema.document.Attribute; -import com.yahoo.document.DataType; -import com.yahoo.schema.document.SDField; -import com.yahoo.document.WeightedSetDataType; - -/** - * @author Einar M R Rosenvinge - */ -public class WeightedSetOperation implements FieldOperation { - - private Boolean createIfNonExistent; - private Boolean removeIfZero; - - public Boolean getCreateIfNonExistent() { - return createIfNonExistent; - } - - public void setCreateIfNonExistent(Boolean createIfNonExistent) { - this.createIfNonExistent = createIfNonExistent; - } - - public Boolean getRemoveIfZero() { - return removeIfZero; - } - - public void setRemoveIfZero(Boolean removeIfZero) { - this.removeIfZero = removeIfZero; - } - - public void apply(SDField field) { - WeightedSetDataType ctype = (WeightedSetDataType) field.getDataType(); - - if (createIfNonExistent != null) { - field.setDataType(DataType.getWeightedSet(ctype.getNestedType(), createIfNonExistent, - ctype.removeIfZero())); - } - - ctype = (WeightedSetDataType) field.getDataType(); - if (removeIfZero != null) { - field.setDataType(DataType.getWeightedSet(ctype.getNestedType(), - ctype.createIfNonExistent(), removeIfZero)); - } - - ctype = (WeightedSetDataType) field.getDataType(); - for (Object o : field.getAttributes().values()) { - Attribute attribute = (Attribute) o; - attribute.setRemoveIfZero(ctype.removeIfZero()); - attribute.setCreateIfNonExistent(ctype.createIfNonExistent()); - } - } - - @Override - public int compareTo(FieldOperation other) { - // this operation should be executed first because it modifies the type of weighted sets, and other - // operation depends on the type of the weighted set - return -1; - } - - @Override - public String toString() { - return "WeightedSetOperation{" + - "createIfNonExistent=" + createIfNonExistent + - ", removeIfZero=" + removeIfZero + - '}'; - } - -} -- cgit v1.2.3