summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/searchdefinition/document
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-10-31 17:08:38 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2019-10-31 17:08:38 +0100
commit9cad135570e17d26ad58fa077d80842670f16dd0 (patch)
tree20d0a94160721815590885ed623170259f716079 /config-model/src/main/java/com/yahoo/searchdefinition/document
parent7e3c245771498acb025d78cfaa01ea171608bf99 (diff)
Use immutable interfaces where possible.
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition/document')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableImportedSDField.java40
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableSDField.java17
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java18
3 files changed, 52 insertions, 23 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableImportedSDField.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableImportedSDField.java
index be5f135f819..9c183d99435 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableImportedSDField.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableImportedSDField.java
@@ -24,7 +24,7 @@ public class ImmutableImportedSDField implements ImmutableSDField {
private final ImportedField importedField;
- public ImmutableImportedSDField(ImportedField importedField) {
+ ImmutableImportedSDField(ImportedField importedField) {
this.importedField = importedField;
}
@@ -63,14 +63,16 @@ public class ImmutableImportedSDField implements ImmutableSDField {
}
@Override
- public ImmutableSDField getBackingField() { return importedField.targetField(); }
-
- @Override
public boolean isIndexStructureField() {
return importedField.targetField().isIndexStructureField();
}
@Override
+ public boolean hasIndex() {
+ return importedField.targetField().hasIndex();
+ }
+
+ @Override
public boolean usesStructOrMap() {
return importedField.targetField().usesStructOrMap();
}
@@ -81,6 +83,11 @@ public class ImmutableImportedSDField implements ImmutableSDField {
}
@Override
+ public SummaryField getSummaryField(String name) {
+ return importedField.targetField().getSummaryField(name);
+ }
+
+ @Override
public Index getIndex(String name) {
if ( ! importedField.fieldName().equals(name)) {
throw new IllegalArgumentException("Getting an index (" + name + ") with different name than the imported field ("
@@ -158,6 +165,31 @@ public class ImmutableImportedSDField implements ImmutableSDField {
return importedField.fieldName(); // Name of the imported field, not the target field
}
+ @Override
+ public int getWeight() {
+ return importedField.targetField().getWeight();
+ }
+
+ @Override
+ public int getLiteralBoost() {
+ return importedField.targetField().getLiteralBoost();
+ }
+
+ @Override
+ public RankType getRankType() {
+ return importedField.targetField().getRankType();
+ }
+
+ @Override
+ public Map<String, Index> getIndices() {
+ return importedField.targetField().getIndices();
+ }
+
+ @Override
+ public boolean existsIndex(String name) {
+ return importedField.targetField().existsIndex(name);
+ }
+
/**
* Returns a field representation of the imported field.
* Changes to the returned instance are not propagated back to the underlying imported field!
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableSDField.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableSDField.java
index 15e75ad8314..7f92e676118 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableSDField.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableSDField.java
@@ -33,16 +33,6 @@ public interface ImmutableSDField {
boolean isImportedField();
- /**
- * Returns the field backing this - the field itself if this is a regular field,
- * and the target field if this is imported.
- */
- ImmutableSDField getBackingField();
-
- default boolean isConcreteField() {
- return !isImportedField();
- }
-
boolean isIndexStructureField();
boolean usesStructOrMap();
@@ -83,4 +73,11 @@ public interface ImmutableSDField {
Field asField();
boolean hasFullIndexingDocprocRights();
+ int getWeight();
+ int getLiteralBoost();
+ RankType getRankType();
+ Map<String, Index> getIndices();
+ boolean existsIndex(String name);
+ SummaryField getSummaryField(String name);
+ boolean hasIndex();
}
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java
index 93b3ff29e13..e9e168edea3 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java
@@ -220,9 +220,6 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer,
}
@Override
- public ImmutableSDField getBackingField() { return this; }
-
- @Override
public boolean doesAttributing() {
return containsExpression(AttributeExpression.class);
}
@@ -521,12 +518,9 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer,
return Collections.singletonList(getName()).iterator();
}
- /** Returns 1 if this is indexed, 0 if it is not indexed */ // TODO: Replace by a boolean method, or something, see hasIndex
- public int getIndexToCount() {
- if (getIndexingScript() == null) return 0;
- if (!doesIndexing()) return 0;
-
- return 1;
+ @Override
+ public boolean hasIndex() {
+ return (getIndexingScript() != null) && doesIndexing();
}
/** Sets the literal boost of this field */
@@ -537,12 +531,14 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer,
* when a query term matched as query term exactly (unnormalized and unstemmed).
* Default is non-positive.
*/
+ @Override
public int getLiteralBoost() { return literalBoost; }
/** Sets the weight of this field */
public void setWeight(int weight) { this.weight=weight; }
/** Returns the weight of this field, or 0 if nothing is set */
+ @Override
public int getWeight() { return weight; }
/**
@@ -600,6 +596,7 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer,
* Returns an index if this field has one (implicitly or
* explicitly) targeting the given name.
*/
+ @Override
public boolean existsIndex(String name) {
if (indices.get(name) != null) return true;
if (name.equals(getName())) {
@@ -614,6 +611,7 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer,
* Defined indices on this field
* @return defined indices on this
*/
+ @Override
public Map<String, Index> getIndices() {
return indices;
}
@@ -638,6 +636,7 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer,
public Ranking getRanking() { return ranking; }
/** Returns the default rank type of indices of this field, or null if nothing is set */
+ @Override
public RankType getRankType() { return this.rankType; }
/**
@@ -712,6 +711,7 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer,
* Returns a summary field defined (implicitly or explicitly) by this field.
* Returns null if there is no such summary field defined.
*/
+ @Override
public SummaryField getSummaryField(String name) {
return summaryFields.get(name);
}