summaryrefslogtreecommitdiffstats
path: root/docprocs
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2023-01-19 20:50:56 +0100
committerJon Bratseth <bratseth@gmail.com>2023-01-19 20:50:56 +0100
commitfa17d66d3b4466cfa47cea78e841721782462976 (patch)
tree66ef3bfc13cf869b129f2c674747a8ec8346d010 /docprocs
parentb4de61b832dbb50ad8d7a1100e384869538bcd83 (diff)
Cleanup - no functional chnges
Diffstat (limited to 'docprocs')
-rw-r--r--docprocs/src/main/java/com/yahoo/docprocs/indexing/IndexingProcessor.java50
-rw-r--r--docprocs/src/main/java/com/yahoo/docprocs/indexing/ScriptManager.java7
-rw-r--r--docprocs/src/test/java/com/yahoo/docprocs/indexing/IndexingProcessorTestCase.java3
-rw-r--r--docprocs/src/test/java/com/yahoo/docprocs/indexing/ScriptManagerTestCase.java6
4 files changed, 33 insertions, 33 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 a55159cdaa0..657c8a161f7 100644
--- a/docprocs/src/main/java/com/yahoo/docprocs/indexing/IndexingProcessor.java
+++ b/docprocs/src/main/java/com/yahoo/docprocs/indexing/IndexingProcessor.java
@@ -95,56 +95,56 @@ public class IndexingProcessor extends DocumentProcessor {
return docTypeMgr;
}
- private void processDocument(DocumentPut prev, List<DocumentOperation> out) {
- DocumentType hadType = prev.getDocument().getDataType();
+ private void processDocument(DocumentPut input, List<DocumentOperation> out) {
+ DocumentType hadType = input.getDocument().getDataType();
DocumentScript script = scriptMgr.getScript(hadType);
if (script == null) {
- log.log(Level.FINE, "No indexing script for document '%s'.", prev.getId());
- out.add(prev);
+ log.log(Level.FINE, "No indexing script for document '%s'.", input.getId());
+ out.add(input);
return;
}
- log.log(Level.FINE, "Processing document '%s'.", prev.getId());
+ log.log(Level.FINE, "Processing document '%s'.", input.getId());
DocumentType wantType = docTypeMgr.getDocumentType(hadType.getName());
- Document prevDoc = prev.getDocument();
+ Document inputDocument = input.getDocument();
if (hadType != wantType) {
// this happens when you have a concrete document; we need to
// convert back to a "normal" Document for indexing of complex structures
// to work properly.
GrowableByteBuffer buffer = new GrowableByteBuffer(64 * 1024, 2.0f);
DocumentSerializer serializer = DocumentSerializerFactory.createHead(buffer);
- serializer.write(prevDoc);
+ serializer.write(inputDocument);
buffer.flip();
- prevDoc = docTypeMgr.createDocument(buffer);
+ inputDocument = docTypeMgr.createDocument(buffer);
}
- Document next = script.execute(adapterFactory, prevDoc);
- if (next == null) {
- log.log(Level.FINE, "Document '%s' produced no output.", prev.getId());
+ Document output = script.execute(adapterFactory, inputDocument);
+ if (output == null) {
+ log.log(Level.FINE, "Document '%s' produced no output.", input.getId());
return;
}
- out.add(new DocumentPut(prev, next));
+ out.add(new DocumentPut(input, output));
}
- private void processUpdate(DocumentUpdate prev, List<DocumentOperation> out) {
- DocumentScript script = scriptMgr.getScript(prev.getType());
+ private void processUpdate(DocumentUpdate input, List<DocumentOperation> out) {
+ DocumentScript script = scriptMgr.getScript(input.getType());
if (script == null) {
- log.log(Level.FINE, "No indexing script for update '%s'.", prev.getId());
- out.add(prev);
+ log.log(Level.FINE, "No indexing script for update '%s'.", input.getId());
+ out.add(input);
return;
}
- log.log(Level.FINE, "Processing update '%s'.", prev.getId());
- DocumentUpdate next = script.execute(adapterFactory, prev);
- if (next == null) {
- log.log(Level.FINE, "Update '%s' produced no output.", prev.getId());
+ log.log(Level.FINE, "Processing update '%s'.", input.getId());
+ DocumentUpdate output = script.execute(adapterFactory, input);
+ if (output == null) {
+ log.log(Level.FINE, "Update '%s' produced no output.", input.getId());
return;
}
- next.setCondition(prev.getCondition());
- out.add(next);
+ output.setCondition(input.getCondition());
+ out.add(output);
}
- private void processRemove(DocumentRemove prev, List<DocumentOperation> out) {
- log.log(Level.FINE, "Not processing remove '%s'.", prev.getId());
- out.add(prev);
+ private void processRemove(DocumentRemove input, List<DocumentOperation> out) {
+ log.log(Level.FINE, "Not processing remove '%s'.", input.getId());
+ out.add(input);
}
private Map<String, Embedder> toMap(ComponentRegistry<Embedder> embedders) {
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 de3a429e357..acc5a2066c9 100644
--- a/docprocs/src/main/java/com/yahoo/docprocs/indexing/ScriptManager.java
+++ b/docprocs/src/main/java/com/yahoo/docprocs/indexing/ScriptManager.java
@@ -72,6 +72,10 @@ public class ScriptManager {
return null;
}
+ /**
+ * Returns an unmodifiable map from document type name to a map of the scripts which must be run given an update
+ * to each possible field in that type.
+ */
private static Map<String, Map<String, DocumentScript>> createScriptsMap(DocumentTypeManager docTypeMgr,
IlscriptsConfig config,
Linguistics linguistics,
@@ -106,11 +110,8 @@ public class ScriptManager {
List<StatementExpression> appendedList = new ArrayList<>(((ScriptExpression)prev.getExpression()).asList());
appendedList.add(statement);
script = new ScriptExpression(appendedList);
- log.log(Level.FINE, "Appending script for field '" + fieldName + "' = " + statement);
- log.log(Level.FINE, "Full script for field '" + fieldName + "' = " + appendedList);
} else {
script = new ScriptExpression(statement);
- log.log(Level.FINE, "Setting script for field '" + fieldName + "' = " + statement);
}
DocumentScript documentScript = new DocumentScript(ilscript.doctype(), inputFieldNameExtractor.getInputFieldNames(), script);
fieldScripts.put(fieldName, documentScript);
diff --git a/docprocs/src/test/java/com/yahoo/docprocs/indexing/IndexingProcessorTestCase.java b/docprocs/src/test/java/com/yahoo/docprocs/indexing/IndexingProcessorTestCase.java
index c6ba63b7924..1f7cd008fb0 100644
--- a/docprocs/src/test/java/com/yahoo/docprocs/indexing/IndexingProcessorTestCase.java
+++ b/docprocs/src/test/java/com/yahoo/docprocs/indexing/IndexingProcessorTestCase.java
@@ -32,7 +32,8 @@ import static org.junit.Assert.assertTrue;
public class IndexingProcessorTestCase {
private static final String CONFIG_ID = "dir:src/test/cfg";
- private IndexingProcessor indexer = newProcessor(CONFIG_ID);
+
+ private final IndexingProcessor indexer = newProcessor(CONFIG_ID);
@Test
public void requireThatIndexerProcessesDocuments() {
diff --git a/docprocs/src/test/java/com/yahoo/docprocs/indexing/ScriptManagerTestCase.java b/docprocs/src/test/java/com/yahoo/docprocs/indexing/ScriptManagerTestCase.java
index 4a7e643fb0a..578c3517922 100644
--- a/docprocs/src/test/java/com/yahoo/docprocs/indexing/ScriptManagerTestCase.java
+++ b/docprocs/src/test/java/com/yahoo/docprocs/indexing/ScriptManagerTestCase.java
@@ -5,11 +5,9 @@ import com.yahoo.document.DocumentType;
import com.yahoo.document.DocumentTypeManager;
import com.yahoo.language.process.Embedder;
import com.yahoo.vespa.configdefinition.IlscriptsConfig;
-import com.yahoo.vespa.indexinglanguage.parser.ParseException;
import org.junit.Test;
import java.util.Iterator;
-import java.util.Map;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -20,7 +18,7 @@ import static org.junit.Assert.assertNull;
public class ScriptManagerTestCase {
@Test
- public void requireThatScriptsAreAppliedToSubType() throws ParseException {
+ public void requireThatScriptsAreAppliedToSubType() {
var typeMgr = DocumentTypeManager.fromFile("src/test/cfg/documentmanager_inherit.cfg");
DocumentType docType = typeMgr.getDocumentType("newssummary");
assertNotNull(docType);
@@ -35,7 +33,7 @@ public class ScriptManagerTestCase {
}
@Test
- public void requireThatScriptsAreAppliedToSuperType() throws ParseException {
+ public void requireThatScriptsAreAppliedToSuperType() {
var typeMgr = DocumentTypeManager.fromFile("src/test/cfg/documentmanager_inherit.cfg");
DocumentType docType = typeMgr.getDocumentType("newsarticle");
assertNotNull(docType);