diff options
author | gjoranv <gv@verizonmedia.com> | 2022-06-06 21:29:07 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2022-06-08 11:45:31 +0200 |
commit | d68dbcec4feab15beeb0984d3684f39839e8e994 (patch) | |
tree | 3abed7d046f39b88e7ade09f03b89671ed26e1d5 /docproc | |
parent | 81928bd0107babe7dece6bef1840c61cac5120cc (diff) |
Remove docproc.util.Splitter/Joiner document processors.
Diffstat (limited to 'docproc')
9 files changed, 0 insertions, 424 deletions
diff --git a/docproc/abi-spec.json b/docproc/abi-spec.json index bb7177783de..f90d31023d3 100644 --- a/docproc/abi-spec.json +++ b/docproc/abi-spec.json @@ -331,29 +331,5 @@ "public void <init>(java.lang.String)" ], "fields": [] - }, - "com.yahoo.docproc.util.JoinerDocumentProcessor": { - "superClass": "com.yahoo.docproc.DocumentProcessor", - "interfaces": [], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>(com.yahoo.config.docproc.SplitterJoinerDocumentProcessorConfig, com.yahoo.document.config.DocumentmanagerConfig)", - "public com.yahoo.docproc.DocumentProcessor$Progress process(com.yahoo.docproc.Processing)" - ], - "fields": [] - }, - "com.yahoo.docproc.util.SplitterDocumentProcessor": { - "superClass": "com.yahoo.docproc.DocumentProcessor", - "interfaces": [], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>(com.yahoo.config.docproc.SplitterJoinerDocumentProcessorConfig, com.yahoo.document.config.DocumentmanagerConfig)", - "public com.yahoo.docproc.DocumentProcessor$Progress process(com.yahoo.docproc.Processing)" - ], - "fields": [] } }
\ No newline at end of file diff --git a/docproc/src/main/java/com/yahoo/docproc/util/JoinerDocumentProcessor.java b/docproc/src/main/java/com/yahoo/docproc/util/JoinerDocumentProcessor.java deleted file mode 100644 index 4e0a5b3eea6..00000000000 --- a/docproc/src/main/java/com/yahoo/docproc/util/JoinerDocumentProcessor.java +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.docproc.util; - -import com.yahoo.document.DocumentOperation; -import com.yahoo.document.DocumentPut; -import com.yahoo.document.config.DocumentmanagerConfig; -import com.yahoo.config.docproc.SplitterJoinerDocumentProcessorConfig; -import com.yahoo.docproc.DocumentProcessor; -import com.yahoo.docproc.Processing; -import com.yahoo.document.Document; -import com.yahoo.document.DocumentTypeManager; -import com.yahoo.document.DocumentTypeManagerConfigurer; -import com.yahoo.document.datatypes.Array; -import java.util.logging.Level; - -import java.util.logging.Logger; - -/** - * @author Einar M R Rosenvinge - * @deprecated Will be removed on Vespa 8 without replacement - */ -@Deprecated(forRemoval = true, since = "7") -@SuppressWarnings("removal") -public class JoinerDocumentProcessor extends DocumentProcessor { - - private static Logger log = Logger.getLogger(JoinerDocumentProcessor.class.getName()); - private String documentTypeName; - private String arrayFieldName; - private String contextFieldName; - private DocumentTypeManager manager; - - public JoinerDocumentProcessor(SplitterJoinerDocumentProcessorConfig cfg, DocumentmanagerConfig documentmanagerConfig) { - super(); - this.documentTypeName = cfg.documentTypeName(); - this.arrayFieldName = cfg.arrayFieldName(); - this.contextFieldName = cfg.contextFieldName(); - manager = DocumentTypeManagerConfigurer.configureNewManager(documentmanagerConfig); - SplitterDocumentProcessor.validate(manager, documentTypeName, arrayFieldName); - } - - @Override - public Progress process(Processing processing) { - if ( ! SplitterDocumentProcessor.doProcessOuterDocument(processing.getVariable(contextFieldName), documentTypeName)) { - return Progress.DONE; - } - - DocumentPut outerDoc = (DocumentPut)processing.getVariable(contextFieldName); - - @SuppressWarnings("unchecked") - Array<Document> innerDocuments = (Array<Document>) outerDoc.getDocument().getFieldValue(arrayFieldName); - - if (innerDocuments == null) { - @SuppressWarnings("unchecked") - Array<Document> empty = (Array<Document>) outerDoc.getDocument().getDataType().getField(arrayFieldName).getDataType().createFieldValue(); - innerDocuments = empty; - } - - for (DocumentOperation op : processing.getDocumentOperations()) { - if (op instanceof DocumentPut) { - innerDocuments.add(((DocumentPut)op).getDocument()); - } else { - log.log(Level.FINE, () -> "Skipping: " + op); - } - } - processing.getDocumentOperations().clear(); - processing.getDocumentOperations().add(outerDoc); - processing.removeVariable(contextFieldName); - return Progress.DONE; - } - -} diff --git a/docproc/src/main/java/com/yahoo/docproc/util/SplitterDocumentProcessor.java b/docproc/src/main/java/com/yahoo/docproc/util/SplitterDocumentProcessor.java deleted file mode 100644 index 1c6e7617edb..00000000000 --- a/docproc/src/main/java/com/yahoo/docproc/util/SplitterDocumentProcessor.java +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.docproc.util; - -import com.yahoo.document.DocumentOperation; -import com.yahoo.document.DocumentPut; -import com.yahoo.document.config.DocumentmanagerConfig; -import com.yahoo.config.docproc.SplitterJoinerDocumentProcessorConfig; -import com.yahoo.docproc.DocumentProcessor; -import com.yahoo.docproc.Processing; -import com.yahoo.document.ArrayDataType; -import com.yahoo.document.Document; -import com.yahoo.document.DocumentType; -import com.yahoo.document.DocumentTypeManager; -import com.yahoo.document.DocumentTypeManagerConfigurer; -import com.yahoo.document.datatypes.Array; -import java.util.logging.Level; - -import java.util.logging.Logger; -import java.util.stream.Collectors; - -/** - * @author Einar M R Rosenvinge - * @deprecated Will be removed on Vespa 8 without replacement - */ -@Deprecated(forRemoval = true, since = "7") -public class SplitterDocumentProcessor extends DocumentProcessor { - - private static Logger log = Logger.getLogger(SplitterDocumentProcessor.class.getName()); - private String documentTypeName; - private String arrayFieldName; - private String contextFieldName; - DocumentTypeManager manager; - - public SplitterDocumentProcessor(SplitterJoinerDocumentProcessorConfig cfg, DocumentmanagerConfig documentmanagerConfig) { - super(); - this.documentTypeName = cfg.documentTypeName(); - this.arrayFieldName = cfg.arrayFieldName(); - this.contextFieldName = cfg.contextFieldName(); - this.manager = DocumentTypeManagerConfigurer.configureNewManager(documentmanagerConfig); - validate(manager, documentTypeName, arrayFieldName); - } - - @Override - public Progress process(Processing processing) { - if (processing.getDocumentOperations().size() != 1) { - //we were given more than one document, return - log.log(Level.FINE, () -> "More than one document given, returning. (Was given " - + processing.getDocumentOperations().size() + " documents)."); - return Progress.DONE; - } - - if (!doProcessOuterDocument(processing.getDocumentOperations().get(0), documentTypeName)) { - return Progress.DONE; - } - - Document outerDoc = ((DocumentPut)processing.getDocumentOperations().get(0)).getDocument();; - - @SuppressWarnings("unchecked") - Array<Document> innerDocuments = (Array<Document>) outerDoc.getFieldValue(arrayFieldName); - if (innerDocuments == null) { - //the document does not have the field, return - log.log(Level.FINE, () -> "The given Document does not have a field value for field " - + arrayFieldName + ", returning. (Was given " + outerDoc + ")."); - return Progress.DONE; - } - - if (innerDocuments.size() == 0) { - //the array is empty, return - log.log(Level.FINE, () -> "The given Document does not have any elements in array field " - + arrayFieldName + ", returning. (Was given " + outerDoc + ")."); - return Progress.DONE; - } - - split(processing, innerDocuments); - return Progress.DONE; - } - - private void split(Processing processing, Array<Document> innerDocuments) { - processing.setVariable(contextFieldName, processing.getDocumentOperations().get(0)); - processing.getDocumentOperations().clear(); - processing.getDocumentOperations().addAll(innerDocuments.stream() - .map(DocumentPut::new) - .collect(Collectors.toList())); - - innerDocuments.clear(); - } - - - static void validate(DocumentTypeManager manager, String documentTypeName, String arrayFieldName) { - DocumentType docType = manager.getDocumentType(documentTypeName); - - if (docType == null) { - //the document type does not exist, return - throw new IllegalStateException("The document type " + documentTypeName + " is not deployed."); - } - - if (docType.getField(arrayFieldName) == null) { - //the document type does not have the field, return - throw new IllegalStateException("The document type " + documentTypeName - + " does not have a field named " + arrayFieldName + "."); - } - - if (!(docType.getField(arrayFieldName).getDataType() instanceof ArrayDataType)) { - //the data type of the field is wrong, return - throw new IllegalStateException("The data type of the field named " - + arrayFieldName + " in document type " + documentTypeName - + " is not an array type"); - } - - ArrayDataType fieldDataType = (ArrayDataType) docType.getField(arrayFieldName).getDataType(); - - if (!(fieldDataType.getNestedType() instanceof DocumentType)) { - //the subtype of tye array data type of the field is wrong, return - throw new IllegalStateException("The data type of the field named " - + arrayFieldName + " in document type " + documentTypeName - + " is not an array of Document."); - } - } - - static boolean doProcessOuterDocument(Object o, String documentTypeName) { - if ( ! (o instanceof DocumentOperation)) { - if (log.isLoggable(Level.FINE)) { - log.log(Level.FINE, o + " is not a DocumentOperation."); - } - return false; - } - - DocumentOperation outerDocOp = (DocumentOperation)o; - if ( ! (outerDocOp instanceof DocumentPut)) { - //this is not a put, return - if (log.isLoggable(Level.FINE)) { - log.log(Level.FINE, "Given DocumentOperation is not a DocumentPut, returning. (Was given " - + outerDocOp + ")."); - } - return false; - } - - Document outerDoc = ((DocumentPut) outerDocOp).getDocument(); - DocumentType type = outerDoc.getDataType(); - if (!type.getName().equalsIgnoreCase(documentTypeName)) { - //this is not the right document type - if (log.isLoggable(Level.FINE)) { - log.log(Level.FINE, "Given Document is of wrong type, returning. (Was given " + outerDoc + ")."); - } - return false; - } - return true; - } - -} diff --git a/docproc/src/main/java/com/yahoo/docproc/util/package-info.java b/docproc/src/main/java/com/yahoo/docproc/util/package-info.java deleted file mode 100644 index ae68d79bb0e..00000000000 --- a/docproc/src/main/java/com/yahoo/docproc/util/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -@ExportPackage -@PublicApi // TODO Vespa 8: revoke from public api -package com.yahoo.docproc.util; - -import com.yahoo.api.annotations.PublicApi; -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/docproc/src/test/java/com/yahoo/docproc/util/SplitterJoinerTestCase.java b/docproc/src/test/java/com/yahoo/docproc/util/SplitterJoinerTestCase.java deleted file mode 100644 index 10e10011e55..00000000000 --- a/docproc/src/test/java/com/yahoo/docproc/util/SplitterJoinerTestCase.java +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.docproc.util; - -import com.yahoo.config.subscription.ConfigGetter; -import com.yahoo.config.docproc.SplitterJoinerDocumentProcessorConfig; -import com.yahoo.document.DocumentPut; -import com.yahoo.document.config.DocumentmanagerConfig; -import com.yahoo.docproc.Processing; -import com.yahoo.document.Document; -import com.yahoo.document.DocumentTypeManager; -import com.yahoo.document.datatypes.Array; -import com.yahoo.document.datatypes.StringFieldValue; -import org.junit.Test; - -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * @author Einar M R Rosenvinge - */ -@SuppressWarnings({"unchecked", "removal"}) -public class SplitterJoinerTestCase { - - @Test - public void testSplitJoin() { - ConfigGetter<SplitterJoinerDocumentProcessorConfig> getter = new ConfigGetter<>(SplitterJoinerDocumentProcessorConfig.class); - ConfigGetter<DocumentmanagerConfig> docManGetter = new ConfigGetter<>(DocumentmanagerConfig.class); - - SplitterJoinerDocumentProcessorConfig cfg = - getter.getConfig("file:src/test/java/com/yahoo/docproc/util/splitter-joiner-document-processor.cfg"); - DocumentmanagerConfig docManCfg = - docManGetter.getConfig("file:src/test/java/com/yahoo/docproc/util/documentmanager.docindoc.cfg"); - - SplitterDocumentProcessor splitter = new SplitterDocumentProcessor(cfg, docManCfg); - - DocumentTypeManager manager = splitter.manager; - - - // Create documents - - Document inner1 = new Document(manager.getDocumentType("docindoc"), "id:inner:docindoc::one"); - inner1.setFieldValue("name", new StringFieldValue("Donald Duck")); - inner1.setFieldValue("content", new StringFieldValue("Lives in Duckburg")); - Document inner2 = new Document(manager.getDocumentType("docindoc"), "id:inner:docindoc::number:two"); - inner2.setFieldValue("name", new StringFieldValue("Uncle Scrooge")); - inner2.setFieldValue("content", new StringFieldValue("Lives in Duckburg, too.")); - - Array<Document> innerArray = (Array<Document>) manager.getDocumentType("outerdoc").getField("innerdocuments").getDataType().createFieldValue(); - innerArray.add(inner1); - innerArray.add(inner2); - - Document outer = new Document(manager.getDocumentType("outerdoc"), "id:outer:outerdoc::the:only:one"); - outer.setFieldValue("innerdocuments", innerArray); - - // End create documents - - - Processing p = Processing.of(new DocumentPut(outer)); - splitter.process(p); - - assertEquals(2, p.getDocumentOperations().size()); - assertSame(inner1, ((DocumentPut)(p.getDocumentOperations().get(0))).getDocument()); - assertSame(inner2, ((DocumentPut)(p.getDocumentOperations().get(1))).getDocument()); - assertSame(outer, ((DocumentPut)(p.getVariable(cfg.contextFieldName()))).getDocument()); - assertSame(innerArray, outer.getFieldValue("innerdocuments")); - assertTrue(innerArray.isEmpty()); - - - JoinerDocumentProcessor joiner = new JoinerDocumentProcessor(cfg, docManCfg); - - joiner.process(p); - - assertEquals(1, p.getDocumentOperations().size()); - assertSame(outer, ((DocumentPut)p.getDocumentOperations().get(0)).getDocument()); - assertNull(p.getVariable(cfg.contextFieldName())); - assertSame(innerArray, outer.getFieldValue("innerdocuments")); - assertEquals(2, innerArray.size()); - assertSame(inner1, innerArray.get(0)); - assertSame(inner2, innerArray.get(1)); - } - -} diff --git a/docproc/src/test/java/com/yahoo/docproc/util/docindoc.sd b/docproc/src/test/java/com/yahoo/docproc/util/docindoc.sd deleted file mode 100644 index ca774778984..00000000000 --- a/docproc/src/test/java/com/yahoo/docproc/util/docindoc.sd +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -search docindoc { - document docindoc { - field name type string { } - field content type string { } - } -} diff --git a/docproc/src/test/java/com/yahoo/docproc/util/documentmanager.docindoc.cfg b/docproc/src/test/java/com/yahoo/docproc/util/documentmanager.docindoc.cfg deleted file mode 100644 index 0b6c59ca381..00000000000 --- a/docproc/src/test/java/com/yahoo/docproc/util/documentmanager.docindoc.cfg +++ /dev/null @@ -1,73 +0,0 @@ -doctype[3] -doctype[0].name "document" -doctype[0].idx 10000 -doctype[0].contentstruct 10001 -doctype[0].primitivetype[0].idx 10002 -doctype[0].primitivetype[0].internalid 0 -doctype[0].primitivetype[0].name "int" -doctype[0].primitivetype[1].idx 10003 -doctype[0].primitivetype[1].internalid 5 -doctype[0].primitivetype[1].name "double" -doctype[0].primitivetype[2].idx 10004 -doctype[0].primitivetype[2].internalid 2 -doctype[0].primitivetype[2].name "string" -doctype[0].annotationtype[0].idx 10005 -doctype[0].annotationtype[0].name "proximity_break" -doctype[0].annotationtype[0].internalid 8 -doctype[0].annotationtype[0].datatype 10003 -doctype[0].annotationtype[1].idx 10006 -doctype[0].annotationtype[1].name "normalized" -doctype[0].annotationtype[1].internalid 4 -doctype[0].annotationtype[1].datatype 10004 -doctype[0].annotationtype[2].idx 10007 -doctype[0].annotationtype[2].name "reading" -doctype[0].annotationtype[2].internalid 5 -doctype[0].annotationtype[2].datatype 10004 -doctype[0].annotationtype[3].idx 10008 -doctype[0].annotationtype[3].name "term" -doctype[0].annotationtype[3].internalid 1 -doctype[0].annotationtype[3].datatype 10004 -doctype[0].annotationtype[4].idx 10009 -doctype[0].annotationtype[4].name "transformed" -doctype[0].annotationtype[4].internalid 7 -doctype[0].annotationtype[4].datatype 10004 -doctype[0].annotationtype[5].idx 10010 -doctype[0].annotationtype[5].name "canonical" -doctype[0].annotationtype[5].internalid 3 -doctype[0].annotationtype[5].datatype 10004 -doctype[0].annotationtype[6].idx 10011 -doctype[0].annotationtype[6].name "token_type" -doctype[0].annotationtype[6].internalid 2 -doctype[0].annotationtype[6].datatype 10002 -doctype[0].annotationtype[7].idx 10012 -doctype[0].annotationtype[7].name "special_token" -doctype[0].annotationtype[7].internalid 9 -doctype[0].annotationtype[8].idx 10013 -doctype[0].annotationtype[8].name "stem" -doctype[0].annotationtype[8].internalid 6 -doctype[0].annotationtype[8].datatype 10004 -doctype[0].structtype[0].idx 10001 -doctype[0].structtype[0].name document.header -doctype[1].name "docindoc" -doctype[1].idx 10014 -doctype[1].inherits[0].idx 10000 -doctype[1].contentstruct 10015 -doctype[1].structtype[0].idx 10015 -doctype[1].structtype[0].name docindoc.header -doctype[1].structtype[0].field[0].name "name" -doctype[1].structtype[0].field[0].internalid 1160796772 -doctype[1].structtype[0].field[0].type 10004 -doctype[1].structtype[0].field[1].name "content" -doctype[1].structtype[0].field[1].internalid 482196823 -doctype[1].structtype[0].field[1].type 10004 -doctype[2].name "outerdoc" -doctype[2].idx 10016 -doctype[2].inherits[0].idx 10000 -doctype[2].contentstruct 10017 -doctype[2].arraytype[0].idx 10018 -doctype[2].arraytype[0].elementtype 10014 -doctype[2].structtype[0].idx 10017 -doctype[2].structtype[0].name outerdoc.header -doctype[2].structtype[0].field[0].name "innerdocuments" -doctype[2].structtype[0].field[0].internalid 1655182511 -doctype[2].structtype[0].field[0].type 10018 diff --git a/docproc/src/test/java/com/yahoo/docproc/util/outerdoc.sd b/docproc/src/test/java/com/yahoo/docproc/util/outerdoc.sd deleted file mode 100644 index 50981d307b9..00000000000 --- a/docproc/src/test/java/com/yahoo/docproc/util/outerdoc.sd +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -search outerdoc { - document outerdoc { - field innerdocuments type array<docindoc> { } - } -} diff --git a/docproc/src/test/java/com/yahoo/docproc/util/splitter-joiner-document-processor.cfg b/docproc/src/test/java/com/yahoo/docproc/util/splitter-joiner-document-processor.cfg deleted file mode 100644 index 16c26f7a6d8..00000000000 --- a/docproc/src/test/java/com/yahoo/docproc/util/splitter-joiner-document-processor.cfg +++ /dev/null @@ -1,2 +0,0 @@ -documentTypeName "outerdoc" -arrayFieldName "innerdocuments" |