Skip to content

Commit

Permalink
Merge pull request #32846 from vespa-engine/bratseth/always-validate
Browse files Browse the repository at this point in the history
Bratseth/always validate
  • Loading branch information
bratseth authored Nov 13, 2024
2 parents e1fcaad + 10165a2 commit 3b06700
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand All @@ -59,8 +59,8 @@ public IndexingProcessor(DocumentTypeManager documentTypeManager,
IlscriptsConfig ilscriptsConfig,
Linguistics linguistics,
ComponentRegistry<Embedder> 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());
}

Expand Down Expand Up @@ -88,17 +88,17 @@ public Progress process(Processing proc) {
}

DocumentTypeManager getDocumentTypeManager() {
return docTypeMgr;
return documentTypeManager;
}

private void processDocument(DocumentPut input, List<DocumentOperation> 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
Expand All @@ -108,7 +108,7 @@ private void processDocument(DocumentPut input, List<DocumentOperation> 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;
Expand All @@ -117,7 +117,7 @@ private void processDocument(DocumentPut input, List<DocumentOperation> out) {
}

private void processUpdate(DocumentUpdate input, List<DocumentOperation> out) {
DocumentScript script = scriptMgr.getScript(input.getType());
DocumentScript script = scriptManager.getScript(input.getType());
if (script == null) {
out.add(input);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Map<String, DocumentScript>> 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<String, Embedder> embedders) {
this.docTypeMgr = docTypeMgr;
documentFieldScripts = createScriptsMap(docTypeMgr, config, linguistics, embedders);
this.documentTypeManager = documentTypeManager;
documentFieldScripts = createScriptsMap(documentTypeManager, config, linguistics, embedders);
}

private Map<String, DocumentScript> getScripts(DocumentType inputType) {
Map<String, DocumentScript> scripts = documentFieldScripts.get(inputType.getName());
if (scripts != null) return scripts;
for (Map.Entry<String, Map<String, DocumentScript>> entry : documentFieldScripts.entrySet()) {
if (inputType.inherits(docTypeMgr.getDocumentType(entry.getKey())))
if (inputType.inherits(documentTypeManager.getDocumentType(entry.getKey())))
return entry.getValue();
}
for (Map.Entry<String, Map<String, DocumentScript>> entry : documentFieldScripts.entrySet()) {
if (docTypeMgr.getDocumentType(entry.getKey()).inherits(inputType))
if (documentTypeManager.getDocumentType(entry.getKey()).inherits(inputType))
return entry.getValue();
}
return null;
Expand Down Expand Up @@ -104,7 +104,7 @@ private static Map<String, Map<String, DocumentScript>> 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);
}
}
Expand Down

0 comments on commit 3b06700

Please sign in to comment.