aboutsummaryrefslogtreecommitdiffstats
path: root/vespaclient-java/src/main/java/com/yahoo
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@yahooinc.com>2022-12-05 13:56:34 +0100
committerTor Brede Vekterli <vekterli@yahooinc.com>2022-12-05 14:02:05 +0100
commit23e9f20ebc1b0d013bd3f95a9463a9fe92a2cb44 (patch)
tree0343335032ebc686ae2d91ebabacb46dfde982f3 /vespaclient-java/src/main/java/com/yahoo
parent8890a936e4fddea023fcb94b2841f5b4208ad908 (diff)
Add tensor short form output option to vespa-visit tool
Specified with `--tensor-short-form`. No single-char option alias, as short form output will be the default on Vespa 9 and we're running out of usable option characters for this tool anyway.
Diffstat (limited to 'vespaclient-java/src/main/java/com/yahoo')
-rw-r--r--vespaclient-java/src/main/java/com/yahoo/vespavisit/StdOutVisitorHandler.java13
-rw-r--r--vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java22
2 files changed, 30 insertions, 5 deletions
diff --git a/vespaclient-java/src/main/java/com/yahoo/vespavisit/StdOutVisitorHandler.java b/vespaclient-java/src/main/java/com/yahoo/vespavisit/StdOutVisitorHandler.java
index ee8aa903d33..2ac0510a2a3 100644
--- a/vespaclient-java/src/main/java/com/yahoo/vespavisit/StdOutVisitorHandler.java
+++ b/vespaclient-java/src/main/java/com/yahoo/vespavisit/StdOutVisitorHandler.java
@@ -40,25 +40,30 @@ public class StdOutVisitorHandler extends VdsVisitHandler {
private int processTimeMilliSecs;
private PrintStream out;
private final boolean jsonOutput;
+ private final boolean tensorShortForm;
private VisitorDataHandler dataHandler;
public StdOutVisitorHandler(boolean printIds, boolean indentXml,
boolean showProgress, boolean showStatistics, boolean doStatistics,
- boolean abortOnClusterDown, int processtime, boolean jsonOutput)
+ boolean abortOnClusterDown, int processtime, boolean jsonOutput,
+ boolean tensorShortForm)
{
- this(printIds, indentXml, showProgress, showStatistics, doStatistics, abortOnClusterDown, processtime, jsonOutput, createStdOutPrintStream());
+ this(printIds, indentXml, showProgress, showStatistics, doStatistics, abortOnClusterDown, processtime,
+ jsonOutput, tensorShortForm, createStdOutPrintStream());
}
StdOutVisitorHandler(boolean printIds, boolean indentXml,
boolean showProgress, boolean showStatistics, boolean doStatistics,
- boolean abortOnClusterDown, int processtime, boolean jsonOutput, PrintStream out)
+ boolean abortOnClusterDown, int processtime, boolean jsonOutput,
+ boolean tensorShortForm, PrintStream out)
{
super(showProgress, showStatistics, abortOnClusterDown);
this.printIds = printIds;
this.indentXml = indentXml;
this.processTimeMilliSecs = processtime;
this.jsonOutput = jsonOutput;
+ this.tensorShortForm = tensorShortForm;
this.out = out;
this.dataHandler = new DataHandler(doStatistics);
}
@@ -169,7 +174,7 @@ public class StdOutVisitorHandler extends VdsVisitHandler {
private void writeJsonDocument(Document doc) throws IOException {
writeFeedStartOrRecordSeparator();
- out.write(JsonWriter.toByteArray(doc));
+ out.write(JsonWriter.toByteArray(doc, tensorShortForm));
}
@Override
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 9a5df96b705..c022713cbb6 100644
--- a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java
+++ b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java
@@ -348,6 +348,13 @@ public class VdsVisit {
FixedBucketSpaces.defaultSpace(), FixedBucketSpaces.globalSpace(), FixedBucketSpaces.defaultSpace()))
.build());
+ // TODO Vespa 9 replace with --tensor-long-form ?
+ options.addOption(Option.builder()
+ .longOpt("tensor-short-form")
+ .desc("Output JSON tensors in short form. Will be the default on Vespa 9")
+ .hasArg(false)
+ .build());
+
return options;
}
@@ -363,6 +370,7 @@ public class VdsVisit {
private int processTime = 0;
private int fullTimeout = 7 * 24 * 60 * 60 * 1000;
private boolean jsonOutput = false;
+ private boolean tensorShortForm = false; // TODO Vespa 9: change default to true
public VisitorParameters getVisitorParameters() {
return visitorParameters;
@@ -431,6 +439,14 @@ public class VdsVisit {
public void setJsonOutput(boolean jsonOutput) {
this.jsonOutput = jsonOutput;
}
+
+ public boolean tensorShortForm() {
+ return tensorShortForm;
+ }
+
+ public void setTensorShortForm(boolean tensorShortForm) {
+ this.tensorShortForm = tensorShortForm;
+ }
}
protected static class ArgumentParser {
@@ -553,6 +569,9 @@ public class VdsVisit {
throttlePolicy.setMaxPendingCount(((Number)line.getParsedOptionValue("maxpendingsuperbuckets")).intValue());
params.setThrottlePolicy(throttlePolicy);
}
+ if (line.hasOption("tensor-short-form")) {
+ allParams.setTensorShortForm(true);
+ }
boolean jsonOutput = line.hasOption("jsonoutput");
boolean xmlOutput = line.hasOption("xmloutput");
@@ -723,7 +742,8 @@ public class VdsVisit {
params.getStatisticsParts() != null,
params.getAbortOnClusterDown(),
params.getProcessTime(),
- params.jsonOutput);
+ params.jsonOutput,
+ params.tensorShortForm);
if (visitorParameters.getResumeFileName() != null) {
handler.setProgressFileName(visitorParameters.getResumeFileName());