diff options
author | Jon Bratseth <bratseth@oath.com> | 2020-08-05 09:09:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-05 09:09:29 +0200 |
commit | 78d1d7c83099639947edb423c67df4961a2cf5e4 (patch) | |
tree | 52b17fad75ba741518f59f01f0a3ab1372a8774b /vespaclient-java | |
parent | 2e82ff0ff2e24811d96c42126d81526da7ea3779 (diff) | |
parent | 2e225436140011754c7d467d5174624d4e451552 (diff) |
Merge pull request #13985 from vespa-engine/balder/minor-fieldset-cleanup
Balder/minor fieldset cleanup
Diffstat (limited to 'vespaclient-java')
5 files changed, 29 insertions, 16 deletions
diff --git a/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java b/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java index 0bfdcbe75ff..b07c54399af 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java @@ -1,6 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespaget; +import com.yahoo.document.fieldset.AllFields; +import com.yahoo.document.fieldset.DocIdOnly; import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; @@ -67,7 +69,7 @@ public class CommandLineOptions { options.addOption(Option.builder("f") .hasArg(true) - .desc("Retrieve the specified fields only (see https://docs.vespa.ai/documentation/documents.html#fieldsets) (default '[all]')") + .desc("Retrieve the specified fields only (see https://docs.vespa.ai/documentation/documents.html#fieldsets) (default '" + AllFields.NAME + "')") .longOpt(FIELDSET_OPTION) .argName("fieldset").build()); @@ -178,9 +180,9 @@ public class CommandLineOptions { } if (printIdsOnly) { - fieldSet = "[id]"; + fieldSet = DocIdOnly.NAME; } else if (fieldSet.isEmpty()) { - fieldSet = "[all]"; + fieldSet = AllFields.NAME; } if (!cluster.isEmpty() && !route.isEmpty()) { diff --git a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java index 83199c76e5a..88eed9dfc59 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java @@ -2,6 +2,7 @@ package com.yahoo.vespavisit; import com.yahoo.document.FixedBucketSpaces; +import com.yahoo.document.fieldset.DocIdOnly; import com.yahoo.document.select.parser.ParseException; import com.yahoo.documentapi.ProgressToken; import com.yahoo.documentapi.VisitorControlHandler; @@ -479,7 +480,7 @@ public class VdsVisit { } if (line.hasOption("i")) { allParams.setPrintIdsOnly(true); - params.fieldSet("[id]"); + params.fieldSet(DocIdOnly.NAME); } if (line.hasOption("p")) { params.setResumeFileName(line.getOptionValue("p")); @@ -512,7 +513,7 @@ public class VdsVisit { if (line.hasOption("statistics")) { allParams.setStatisticsParts(line.getOptionValue("statistics")); - params.fieldSet("[id]"); + params.fieldSet(DocIdOnly.NAME); params.setVisitorLibrary("CountVisitor"); } diff --git a/vespaclient-java/src/test/java/com/yahoo/vespaget/CommandLineOptionsTest.java b/vespaclient-java/src/test/java/com/yahoo/vespaget/CommandLineOptionsTest.java index 50b499b8df2..20d12d3f55f 100644 --- a/vespaclient-java/src/test/java/com/yahoo/vespaget/CommandLineOptionsTest.java +++ b/vespaclient-java/src/test/java/com/yahoo/vespaget/CommandLineOptionsTest.java @@ -1,15 +1,24 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespaget; +import com.yahoo.document.fieldset.AllFields; +import com.yahoo.document.fieldset.DocIdOnly; import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; import java.util.Iterator; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; /** * Test class for {@link CommandLineOptions} @@ -45,7 +54,7 @@ public class CommandLineOptionsTest { assertFalse(params.help); assertFalse(params.documentIds.hasNext()); assertFalse(params.printIdsOnly); - assertEquals("[all]", params.fieldSet); + assertEquals(AllFields.NAME, params.fieldSet); assertEquals("default-get", params.route); assertTrue(params.cluster.isEmpty()); assertEquals("client", params.configId); @@ -92,7 +101,7 @@ public class CommandLineOptionsTest { public void testInvalidCombination3() { exception.expect(IllegalArgumentException.class); exception.expectMessage("Field set option can not be used in combination with print ids option."); - getParsedOptions("--printids", "--fieldset", "[header]"); + getParsedOptions("--printids", "--fieldset", AllFields.NAME); } @Test @@ -138,7 +147,7 @@ public class CommandLineOptionsTest { @Test public void testPrintids() { ClientParameters params = getParsedOptions("--printids"); - assertEquals("[id]", params.fieldSet); + assertEquals(DocIdOnly.NAME, params.fieldSet); } @Test diff --git a/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java b/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java index c662e2fed62..d8b5c267bf2 100644 --- a/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java +++ b/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java @@ -1,11 +1,11 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespaget; -import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.ObjectMapper; import com.yahoo.document.DataType; import com.yahoo.document.Document; import com.yahoo.document.DocumentId; +import com.yahoo.document.fieldset.AllFields; import com.yahoo.documentapi.messagebus.MessageBusDocumentAccess; import com.yahoo.documentapi.messagebus.MessageBusSyncSession; import com.yahoo.documentapi.messagebus.loadtypes.LoadType; @@ -96,7 +96,7 @@ public class DocumentRetrieverTest { .setCluster("") .setRoute("default") .setConfigId("client") - .setFieldSet("[all]") + .setFieldSet(AllFields.NAME) .setPrintIdsOnly(false) .setHelp(false) .setShowDocSize(false) @@ -180,7 +180,7 @@ public class DocumentRetrieverTest { } @Test - public void testJsonOutput() throws DocumentRetrieverException, JsonParseException, IOException { + public void testJsonOutput() throws DocumentRetrieverException, IOException { ClientParameters params = createParameters() .setDocumentIds(asIterator(DOC_ID_1, DOC_ID_2, DOC_ID_3)) .setJsonOutput(true) diff --git a/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java b/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java index d9efe2c5129..4c8fbb1beee 100644 --- a/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java +++ b/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespavisit; +import com.yahoo.document.fieldset.DocIdOnly; import com.yahoo.document.select.parser.ParseException; import com.yahoo.documentapi.*; import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol; @@ -83,7 +84,7 @@ public class VdsVisitTestCase { assertNotNull(params); assertEquals(654321, allParams.getFullTimeout()); assertEquals(654321, params.getTimeoutMs()); - assertEquals("[id]", params.getFieldSet()); + assertEquals(DocIdOnly.NAME, params.getFieldSet()); } @Test @@ -98,7 +99,7 @@ public class VdsVisitTestCase { VisitorParameters params = allParams.getVisitorParameters(); assertNotNull(params); - assertEquals("[id]", params.getFieldSet()); + assertEquals(DocIdOnly.NAME, params.getFieldSet()); assertTrue(allParams.isPrintIdsOnly()); } @@ -295,7 +296,7 @@ public class VdsVisitTestCase { VisitorParameters params = allParams.getVisitorParameters(); assertNotNull(params); assertEquals("foo", allParams.getStatisticsParts()); - assertEquals("[id]", params.getFieldSet()); + assertEquals(DocIdOnly.NAME, params.getFieldSet()); assertEquals("CountVisitor", params.getVisitorLibrary()); } |