From 724da39e37efda3fe8c1e99198e7a5f0d65413c0 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 12 Nov 2024 23:24:54 +0100 Subject: [PATCH 1/2] Cleanup only --- .../docprocs/indexing/IndexingProcessor.java | 20 +++++++++---------- .../docprocs/indexing/ScriptManager.java | 14 ++++++------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docprocs/src/main/java/com/yahoo/docprocs/indexing/IndexingProcessor.java b/docprocs/src/main/java/com/yahoo/docprocs/indexing/IndexingProcessor.java index c5cf72b351d4..dec87c3ab4ae 100644 --- a/docprocs/src/main/java/com/yahoo/docprocs/indexing/IndexingProcessor.java +++ b/docprocs/src/main/java/com/yahoo/docprocs/indexing/IndexingProcessor.java @@ -43,14 +43,14 @@ public class IndexingProcessor extends DocumentProcessor { public final static String INDEXING_START = "indexingStart"; public final static String INDEXING_END = "indexingEnd"; - private final DocumentTypeManager docTypeMgr; - private final ScriptManager scriptMgr; + private final DocumentTypeManager documentTypeManager; + private final ScriptManager scriptManager; private final AdapterFactory adapterFactory; private class ExpressionSelector extends SimpleAdapterFactory.SelectExpression { @Override public Expression selectExpression(DocumentType documentType, String fieldName) { - return scriptMgr.getScript(documentType, fieldName).getExpression(); + return scriptManager.getScript(documentType, fieldName).getExpression(); } } @@ -59,8 +59,8 @@ public IndexingProcessor(DocumentTypeManager documentTypeManager, IlscriptsConfig ilscriptsConfig, Linguistics linguistics, ComponentRegistry embedders) { - docTypeMgr = documentTypeManager; - scriptMgr = new ScriptManager(docTypeMgr, ilscriptsConfig, linguistics, toMap(embedders)); + this.documentTypeManager = documentTypeManager; + scriptManager = new ScriptManager(this.documentTypeManager, ilscriptsConfig, linguistics, toMap(embedders)); adapterFactory = new SimpleAdapterFactory(new ExpressionSelector()); } @@ -88,17 +88,17 @@ public Progress process(Processing proc) { } DocumentTypeManager getDocumentTypeManager() { - return docTypeMgr; + return documentTypeManager; } private void processDocument(DocumentPut input, List out) { DocumentType hadType = input.getDocument().getDataType(); - DocumentScript script = scriptMgr.getScript(hadType); + DocumentScript script = scriptManager.getScript(hadType); if (script == null) { out.add(input); return; } - DocumentType wantType = docTypeMgr.getDocumentType(hadType.getName()); + DocumentType wantType = documentTypeManager.getDocumentType(hadType.getName()); Document inputDocument = input.getDocument(); if (hadType != wantType) { // this happens when you have a concrete document; we need to @@ -108,7 +108,7 @@ private void processDocument(DocumentPut input, List out) { DocumentSerializer serializer = DocumentSerializerFactory.createHead(buffer); serializer.write(inputDocument); buffer.flip(); - inputDocument = docTypeMgr.createDocument(buffer); + inputDocument = documentTypeManager.createDocument(buffer); } Document output = script.execute(adapterFactory, inputDocument); if (output == null) return; @@ -117,7 +117,7 @@ private void processDocument(DocumentPut input, List out) { } private void processUpdate(DocumentUpdate input, List out) { - DocumentScript script = scriptMgr.getScript(input.getType()); + DocumentScript script = scriptManager.getScript(input.getType()); if (script == null) { out.add(input); return; diff --git a/docprocs/src/main/java/com/yahoo/docprocs/indexing/ScriptManager.java b/docprocs/src/main/java/com/yahoo/docprocs/indexing/ScriptManager.java index 3088083912bc..39ac44119f9f 100644 --- a/docprocs/src/main/java/com/yahoo/docprocs/indexing/ScriptManager.java +++ b/docprocs/src/main/java/com/yahoo/docprocs/indexing/ScriptManager.java @@ -26,23 +26,23 @@ public class ScriptManager { private static final FastLogger log = FastLogger.getLogger(ScriptManager.class.getName()); private static final String FULL = "[all]"; private final Map> documentFieldScripts; - private final DocumentTypeManager docTypeMgr; + private final DocumentTypeManager documentTypeManager; - public ScriptManager(DocumentTypeManager docTypeMgr, IlscriptsConfig config, Linguistics linguistics, + public ScriptManager(DocumentTypeManager documentTypeManager, IlscriptsConfig config, Linguistics linguistics, Map embedders) { - this.docTypeMgr = docTypeMgr; - documentFieldScripts = createScriptsMap(docTypeMgr, config, linguistics, embedders); + this.documentTypeManager = documentTypeManager; + documentFieldScripts = createScriptsMap(documentTypeManager, config, linguistics, embedders); } private Map getScripts(DocumentType inputType) { Map scripts = documentFieldScripts.get(inputType.getName()); if (scripts != null) return scripts; for (Map.Entry> entry : documentFieldScripts.entrySet()) { - if (inputType.inherits(docTypeMgr.getDocumentType(entry.getKey()))) + if (inputType.inherits(documentTypeManager.getDocumentType(entry.getKey()))) return entry.getValue(); } for (Map.Entry> entry : documentFieldScripts.entrySet()) { - if (docTypeMgr.getDocumentType(entry.getKey()).inherits(inputType)) + if (documentTypeManager.getDocumentType(entry.getKey()).inherits(inputType)) return entry.getValue(); } return null; @@ -104,7 +104,7 @@ private static Map> createScriptsMap(Docume DocumentScript documentScript = new DocumentScript(ilscript.doctype(), inputFieldNames, script); fieldScripts.put(fieldName, documentScript); } else { - log.log(Level.FINE, "Non single(" + inputFieldNames.size() +"" + + log.log(Level.FINE, "Non single(" + inputFieldNames.size() + ") inputs = " + inputFieldNames + ". Script = " + statement); } } From 10165a2e787d5be43d8466a215a5bb8af6ccb4f8 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 12 Nov 2024 23:25:01 +0100 Subject: [PATCH 2/2] Always validate indexing expression Validation does the type inference which is needed during execution. Since expressions will always be validated before execution, they should also always be validated by the model to detect validation errors introduced by Vespa at model bootstrap. --- .../java/com/yahoo/schema/processing/IndexingValidation.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/config-model/src/main/java/com/yahoo/schema/processing/IndexingValidation.java b/config-model/src/main/java/com/yahoo/schema/processing/IndexingValidation.java index 1011fb2617f2..63c2c55e850b 100644 --- a/config-model/src/main/java/com/yahoo/schema/processing/IndexingValidation.java +++ b/config-model/src/main/java/com/yahoo/schema/processing/IndexingValidation.java @@ -40,8 +40,6 @@ public class IndexingValidation extends Processor { @Override public void process(boolean validate, boolean documentsOnly) { - if ( ! validate) return; - VerificationContext context = new VerificationContext(new MyAdapter(schema)); for (SDField field : schema.allConcreteFields()) { ScriptExpression script = field.getIndexingScript();