diff options
author | Jon Bratseth <bratseth@gmail.com> | 2021-11-09 17:37:25 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2021-11-09 17:37:25 +0100 |
commit | 531485ce5dc68531bce49e7720b562f906bc4444 (patch) | |
tree | 097ca1f0dd39a76a87fdfd3d36eeec2151d3a128 | |
parent | 198a9431c2d025652a6d95be093d890f622f7e65 (diff) |
Create implicit summaries for each schema separately
7 files changed, 140 insertions, 80 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java b/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java index 512d908ce5b..c7a7ecd1d08 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java @@ -514,21 +514,14 @@ public class Schema implements ImmutableSchema { return Collections.unmodifiableList(allIndices); } - /** - * Adds an explicitly defined summary to this search definition - * - * @param summary The summary to add. - */ + /** Adds an explicitly defined summary to this search definition */ public void addSummary(DocumentSummary summary) { summaries.put(summary.getName(), summary); } /** - * <p>Returns a summary class defined by this search definition, or null if no summary with this name is defined. - * The default summary, named "default" is always present.</p> - * - * @param name the name of the summary to get. - * @return Summary found. + * Returns a summary class defined by this search definition, or null if no summary with this name is defined. + * The default summary, named "default" is always present. */ public DocumentSummary getSummary(String name) { var summary = summaries.get(name); @@ -540,9 +533,6 @@ public class Schema implements ImmutableSchema { /** * Returns the first explicit instance found of a summary field with this name, or null if not present (implicitly * or explicitly) in any summary class. - * - * @param name The name of the summaryfield to get. - * @return SummaryField to return. */ public SummaryField getSummaryField(String name) { for (DocumentSummary summary : summaries.values()) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImplicitSummaries.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImplicitSummaries.java index 6b09234c469..38703007f58 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImplicitSummaries.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImplicitSummaries.java @@ -29,17 +29,16 @@ public class ImplicitSummaries extends Processor { @Override public void process(boolean validate, boolean documentsOnly) { - DocumentSummary defaultSummary = schema.getSummary("default"); + DocumentSummary defaultSummary = schema.getSummariesInThis().get("default"); if (defaultSummary == null) { defaultSummary = new DocumentSummary("default", schema); - defaultSummary.setFromDisk(true); + defaultSummary.setFromDisk(true); // TODO: Not necessarily schema.addSummary(defaultSummary); } for (SDField field : schema.allConcreteFields()) { collectSummaries(field, schema, validate); } - for (DocumentSummary documentSummary : schema.getSummaries().values()) { documentSummary.purgeImplicits(); } @@ -50,7 +49,7 @@ public class ImplicitSummaries extends Processor { } private void collectSummaries(SDField field , Schema schema, boolean validate) { - SummaryField addedSummaryField=null; + SummaryField addedSummaryField = null; // Implicit String fieldName = field.getName(); @@ -114,7 +113,7 @@ public class ImplicitSummaries extends Processor { } private DocumentSummary getOrCreateAttributePrefetchSummary(Schema schema) { - DocumentSummary summary = schema.getSummary("attributeprefetch"); + DocumentSummary summary = schema.getSummariesInThis().get("attributeprefetch"); if (summary == null) { summary = new DocumentSummary("attributeprefetch", schema); schema.addSummary(summary); diff --git a/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentSummary.java b/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentSummary.java index 3dda498b0be..59b4e1a2f9b 100644 --- a/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentSummary.java +++ b/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentSummary.java @@ -88,7 +88,7 @@ public class DocumentSummary extends FieldView { String sourceName = j.next().getName(); if (sourceName.equals(summaryField.getName())) continue; SummaryField sourceField=getSummaryField(sourceName); - if (sourceField==null) continue; + if (sourceField == null) continue; if (!sourceField.isImplicit()) continue; falseImplicits.add(sourceField); } diff --git a/config-model/src/test/derived/schemainheritance/summary.cfg b/config-model/src/test/derived/schemainheritance/summary.cfg index 451894ec2c1..d3286961007 100644 --- a/config-model/src/test/derived/schemainheritance/summary.cfg +++ b/config-model/src/test/derived/schemainheritance/summary.cfg @@ -1,19 +1,19 @@ -defaultsummaryid 1044042981 -classes[].id 1044042981 +defaultsummaryid 1313596701 +classes[].id 1313596701 classes[].name "default" classes[].omitsummaryfeatures false classes[].fields[].name "parent_field" classes[].fields[].type "longstring" +classes[].fields[].name "child_field" +classes[].fields[].type "longstring" classes[].fields[].name "pf1" classes[].fields[].type "longstring" +classes[].fields[].name "cf1" +classes[].fields[].type "longstring" classes[].fields[].name "rankfeatures" classes[].fields[].type "featuredata" classes[].fields[].name "summaryfeatures" classes[].fields[].type "featuredata" -classes[].fields[].name "child_field" -classes[].fields[].type "longstring" -classes[].fields[].name "cf1" -classes[].fields[].type "longstring" classes[].fields[].name "documentid" classes[].fields[].type "longstring" classes[].id 2134223620 @@ -25,17 +25,17 @@ classes[].fields[].name "rankfeatures" classes[].fields[].type "featuredata" classes[].fields[].name "summaryfeatures" classes[].fields[].type "featuredata" -classes[].id 178044032 +classes[].id 524210908 classes[].name "attributeprefetch" classes[].omitsummaryfeatures false classes[].fields[].name "parent_field" classes[].fields[].type "longstring" +classes[].fields[].name "child_field" +classes[].fields[].type "longstring" classes[].fields[].name "rankfeatures" classes[].fields[].type "featuredata" classes[].fields[].name "summaryfeatures" classes[].fields[].type "featuredata" -classes[].fields[].name "child_field" -classes[].fields[].type "longstring" classes[].id 1486475170 classes[].name "child_summary" classes[].omitsummaryfeatures false @@ -46,4 +46,4 @@ classes[].fields[].type "featuredata" classes[].fields[].name "summaryfeatures" classes[].fields[].type "featuredata" classes[].fields[].name "cf1" -classes[].fields[].type "longstring" +classes[].fields[].type "longstring"
\ No newline at end of file diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java index 860b741a1f2..d6740de1f1e 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java @@ -102,81 +102,147 @@ public class SchemaTestCase { " import field parentschema_ref.name as parent_imported {}" + " raw-as-base64-in-summary" + "}"); - String childLines = joinLines( - "schema child inherits parent {" + - " document child inherits parent {" + - " field cf1 type string {" + + String child1Lines = joinLines( + "schema child1 inherits parent {" + + " document child1 inherits parent {" + + " field c1f1 type string {" + " indexing: summary" + " }" + " }" + - " fieldset child_set {" + - " fields: cf1, pf1" + + " fieldset child1_set {" + + " fields: c1f1, pf1" + " }" + " stemming: shortest" + - " index child_index {" + + " index child1_index {" + " stemming: shortest" + " }" + - " field child_field type string {" + + " field child1_field type string {" + " indexing: input pf1 | lowercase | index | attribute | summary" + " }" + - " rank-profile child_profile inherits parent_profile {" + + " rank-profile child1_profile inherits parent_profile {" + " }" + - " constant child_constant {" + + " constant child1_constant {" + " file: constants/my_constant_tensor_file.json" + " type: tensor<float>(x{},y{})" + " }" + - " onnx-model child_model {" + + " onnx-model child1_model {" + " file: models/my_model.onnx" + " }" + - " document-summary child_summary inherits parent_summary {" + - " summary cf1 type string {}" + + " document-summary child1_summary inherits parent_summary {" + + " summary c1f1 type string {}" + " }" + - " import field parentschema_ref.name as child_imported {}" + + " import field parentschema_ref.name as child1_imported {}" + + "}"); + String child2Lines = joinLines( + "schema child2 inherits parent {" + + " document child2 inherits parent {" + + " field c2f1 type string {" + + " indexing: summary" + + " }" + + " }" + + " fieldset child2_set {" + + " fields: c2f1, pf1" + + " }" + + " stemming: shortest" + + " index child2_index {" + + " stemming: shortest" + + " }" + + " field child2_field type string {" + + " indexing: input pf1 | lowercase | index | attribute | summary" + + " }" + + " rank-profile child2_profile inherits parent_profile {" + + " }" + + " constant child2_constant {" + + " file: constants/my_constant_tensor_file.json" + + " type: tensor<float>(x{},y{})" + + " }" + + " onnx-model child2_model {" + + " file: models/my_model.onnx" + + " }" + + " document-summary child2_summary inherits parent_summary {" + + " summary c2f1 type string {}" + + " }" + + " import field parentschema_ref.name as child2_imported {}" + "}"); - System.out.println(parentLines); SchemaBuilder builder = new SchemaBuilder(new DeployLoggerStub()); builder.processorsToSkip().add(OnnxModelTypeResolver.class); // Avoid discovering the Onnx model referenced does not exist builder.processorsToSkip().add(ImportedFieldsResolver.class); // Avoid discovering the document reference leads nowhere builder.importString(parentLines); - builder.importString(childLines); + builder.importString(child1Lines); + builder.importString(child2Lines); builder.build(true); var application = builder.application(); - var child = application.schemas().get("child"); - assertEquals("pf1", child.fieldSets().userFieldSets().get("parent_set").getFieldNames().stream().findFirst().get()); - assertEquals("[cf1, pf1]", child.fieldSets().userFieldSets().get("child_set").getFieldNames().toString()); - assertEquals(Stemming.SHORTEST, child.getStemming()); - assertEquals(Stemming.BEST, child.getIndex("parent_index").getStemming()); - assertEquals(Stemming.SHORTEST, child.getIndex("child_index").getStemming()); - assertNotNull(child.getField("parent_field")); - assertNotNull(child.getField("child_field")); - assertNotNull(child.getExtraField("parent_field")); - assertNotNull(child.getExtraField("child_field")); - assertNotNull(builder.getRankProfileRegistry().get(child, "parent_profile")); - assertNotNull(builder.getRankProfileRegistry().get(child, "child_profile")); - assertEquals("parent_profile", builder.getRankProfileRegistry().get(child, "child_profile").getInheritedName()); - assertNotNull(child.rankingConstants().get("parent_constant")); - assertNotNull(child.rankingConstants().get("child_constant")); - assertTrue(child.rankingConstants().asMap().containsKey("parent_constant")); - assertTrue(child.rankingConstants().asMap().containsKey("child_constant")); - assertNotNull(child.onnxModels().get("parent_model")); - assertNotNull(child.onnxModels().get("child_model")); - assertTrue(child.onnxModels().asMap().containsKey("parent_model")); - assertTrue(child.onnxModels().asMap().containsKey("child_model")); - assertNotNull(child.getSummary("parent_summary")); - assertNotNull(child.getSummary("child_summary")); - assertEquals("parent_summary", child.getSummary("child_summary").inherited().get().getName()); - assertTrue(child.getSummaries().containsKey("parent_summary")); - assertTrue(child.getSummaries().containsKey("child_summary")); - assertNotNull(child.getSummaryField("pf1")); - assertNotNull(child.getSummaryField("cf1")); - assertNotNull(child.getExplicitSummaryField("pf1")); - assertNotNull(child.getExplicitSummaryField("cf1")); - assertNotNull(child.getUniqueNamedSummaryFields().get("pf1")); - assertNotNull(child.getUniqueNamedSummaryFields().get("cf1")); - assertNotNull(child.temporaryImportedFields().get().fields().get("parent_imported")); - assertNotNull(child.temporaryImportedFields().get().fields().get("child_imported")); + var child1 = application.schemas().get("child1"); + assertEquals("pf1", child1.fieldSets().userFieldSets().get("parent_set").getFieldNames().stream().findFirst().get()); + assertEquals("[c1f1, pf1]", child1.fieldSets().userFieldSets().get("child1_set").getFieldNames().toString()); + assertEquals(Stemming.SHORTEST, child1.getStemming()); + assertEquals(Stemming.BEST, child1.getIndex("parent_index").getStemming()); + assertEquals(Stemming.SHORTEST, child1.getIndex("child1_index").getStemming()); + assertNotNull(child1.getField("parent_field")); + assertNotNull(child1.getField("child1_field")); + assertNotNull(child1.getExtraField("parent_field")); + assertNotNull(child1.getExtraField("child1_field")); + assertNotNull(builder.getRankProfileRegistry().get(child1, "parent_profile")); + assertNotNull(builder.getRankProfileRegistry().get(child1, "child1_profile")); + assertEquals("parent_profile", builder.getRankProfileRegistry().get(child1, "child1_profile").getInheritedName()); + assertNotNull(child1.rankingConstants().get("parent_constant")); + assertNotNull(child1.rankingConstants().get("child1_constant")); + assertTrue(child1.rankingConstants().asMap().containsKey("parent_constant")); + assertTrue(child1.rankingConstants().asMap().containsKey("child1_constant")); + assertNotNull(child1.onnxModels().get("parent_model")); + assertNotNull(child1.onnxModels().get("child1_model")); + assertTrue(child1.onnxModels().asMap().containsKey("parent_model")); + assertTrue(child1.onnxModels().asMap().containsKey("child1_model")); + assertNotNull(child1.getSummary("parent_summary")); + assertNotNull(child1.getSummary("child1_summary")); + assertEquals("parent_summary", child1.getSummary("child1_summary").inherited().get().getName()); + assertTrue(child1.getSummaries().containsKey("parent_summary")); + assertTrue(child1.getSummaries().containsKey("child1_summary")); + assertNotNull(child1.getSummaryField("pf1")); + assertNotNull(child1.getSummaryField("c1f1")); + assertNotNull(child1.getExplicitSummaryField("pf1")); + assertNotNull(child1.getExplicitSummaryField("c1f1")); + assertNotNull(child1.getUniqueNamedSummaryFields().get("pf1")); + assertNotNull(child1.getUniqueNamedSummaryFields().get("c1f1")); + assertNotNull(child1.temporaryImportedFields().get().fields().get("parent_imported")); + assertNotNull(child1.temporaryImportedFields().get().fields().get("child1_imported")); + + var child2 = application.schemas().get("child2"); + assertEquals("pf1", child2.fieldSets().userFieldSets().get("parent_set").getFieldNames().stream().findFirst().get()); + assertEquals("[c2f1, pf1]", child2.fieldSets().userFieldSets().get("child2_set").getFieldNames().toString()); + assertEquals(Stemming.SHORTEST, child2.getStemming()); + assertEquals(Stemming.BEST, child2.getIndex("parent_index").getStemming()); + assertEquals(Stemming.SHORTEST, child2.getIndex("child2_index").getStemming()); + assertNotNull(child2.getField("parent_field")); + assertNotNull(child2.getField("child2_field")); + assertNotNull(child2.getExtraField("parent_field")); + assertNotNull(child2.getExtraField("child2_field")); + assertNotNull(builder.getRankProfileRegistry().get(child2, "parent_profile")); + assertNotNull(builder.getRankProfileRegistry().get(child2, "child2_profile")); + assertEquals("parent_profile", builder.getRankProfileRegistry().get(child2, "child2_profile").getInheritedName()); + assertNotNull(child2.rankingConstants().get("parent_constant")); + assertNotNull(child2.rankingConstants().get("child2_constant")); + assertTrue(child2.rankingConstants().asMap().containsKey("parent_constant")); + assertTrue(child2.rankingConstants().asMap().containsKey("child2_constant")); + assertNotNull(child2.onnxModels().get("parent_model")); + assertNotNull(child2.onnxModels().get("child2_model")); + assertTrue(child2.onnxModels().asMap().containsKey("parent_model")); + assertTrue(child2.onnxModels().asMap().containsKey("child2_model")); + assertNotNull(child2.getSummary("parent_summary")); + assertNotNull(child2.getSummary("child2_summary")); + assertEquals("parent_summary", child2.getSummary("child2_summary").inherited().get().getName()); + assertTrue(child2.getSummaries().containsKey("parent_summary")); + assertTrue(child2.getSummaries().containsKey("child2_summary")); + assertNotNull(child2.getSummaryField("pf1")); + assertNotNull(child2.getSummaryField("c2f1")); + assertNotNull(child2.getExplicitSummaryField("pf1")); + assertNotNull(child2.getExplicitSummaryField("c2f1")); + assertNotNull(child2.getUniqueNamedSummaryFields().get("pf1")); + assertNotNull(child2.getUniqueNamedSummaryFields().get("c2f1")); + assertNotNull(child2.temporaryImportedFields().get().fields().get("parent_imported")); + assertNotNull(child2.temporaryImportedFields().get().fields().get("child2_imported")); } @Test diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/operationProcessor/OperationProcessor.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/operationProcessor/OperationProcessor.java index 6633fca6ca0..5d0e063efdf 100644 --- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/operationProcessor/OperationProcessor.java +++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/operationProcessor/OperationProcessor.java @@ -145,7 +145,7 @@ public class OperationProcessor { if (retryThisOperation) { int waitTime = (int) (minTimeBetweenRetriesMs * (1 + random.nextDouble() / 3)); - log.finest("Retrying due to " + detail.toString() + " attempt " + retries + " in " + waitTime + " ms."); + log.finest("Retrying due to " + detail + " attempt " + retries + " in " + waitTime + " ms."); timeoutExecutor.schedule(() -> postToCluster(clusters.get(clusterId), documentSendInfo.getDocument()), waitTime, TimeUnit.MILLISECONDS); diff --git a/vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.java index fd33cf97220..ef571043d0f 100644 --- a/vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.java @@ -42,6 +42,11 @@ public class TensorTestCase { } @Test + public void testTmp() { + System.out.println(Tensor.from("tensor(x[3]):[1, 2, 3]").join(Tensor.from("tensor(y[3]):[4, 5, 6]"), (x,y) -> x*y).map(v -> v*3)); + } + + @Test public void testValueTypes() { assertEquals(Tensor.from("tensor<double>(x[1]):{{x:0}:5}").getClass(), IndexedDoubleTensor.class); assertEquals(Tensor.Builder.of(TensorType.fromSpec("tensor<double>(x[1])")).cell(5.0, 0).build().getClass(), |