aboutsummaryrefslogtreecommitdiffstats
path: root/vespaclient-java/src/main/java/com/yahoo/vespaget/ClientParameters.java
blob: e4b87d8643a5d7905c7fbfb3c7579e60e783712d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespaget;

import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol;

import java.util.Iterator;
/**
 * This class contains the program parameters.
 *
 * @author bjorncs
 */
public class ClientParameters {

    // Determines if the help page should be presented
    public final boolean help;
    // Contains the document ids. Is backed by either a list iterator if the ids were given as CLI arguments or Scanner(System.in) if ids are provided by standard input.
    public final Iterator<String> documentIds;
    // Print only the id for retrieved documents
    public final boolean printIdsOnly;
    // Determines which document fields to retrieve. Default is '[document]'.
    public final String fieldSet;
    // The Vespa route
    public final String route;
    // Alternative way to specify the route using cluster name.
    public final String cluster;
    // The configuration id for message bus. Default "client".
    public final String configId;
    // Determines if the serialized document size should be printed
    public final boolean showDocSize;
    // Document request timeout
    public final double timeout;
    // Determines whether or not the document request can be resent
    public final boolean noRetry;
    // Vespa trace level
    public final int traceLevel;
    // Document request priority
    public final DocumentProtocol.Priority priority;
    // If full documents are printed, they will be printed as JSON (instead of XML)
    public final boolean jsonOutput;
    // Output JSON tensors in short form
    public final boolean tensorShortForm;
    // Output JSON tensorvalues directly
    public final boolean tensorDirectValues;

    private ClientParameters(
            boolean help, Iterator<String> documentIds, boolean printIdsOnly,
            String fieldSet, String route, String cluster, String configId,
            boolean showDocSize, double timeout, boolean noRetry, int traceLevel,
            DocumentProtocol.Priority priority, boolean jsonOutput, boolean tensorShortForm,
            boolean tensorDirectValues) {

        this.help = help;
        this.documentIds = documentIds;
        this.printIdsOnly = printIdsOnly;
        this.fieldSet = fieldSet;
        this.route = route;
        this.cluster = cluster;
        this.configId = configId;
        this.showDocSize = showDocSize;
        this.timeout = timeout;
        this.noRetry = noRetry;
        this.traceLevel = traceLevel;
        this.priority = priority;
        this.jsonOutput = jsonOutput;
        this.tensorShortForm = tensorShortForm;
        this.tensorDirectValues = tensorDirectValues;
    }

    public static class Builder {
        private boolean help;
        private Iterator<String> documentIds;
        private boolean printIdsOnly;
        private String fieldSet;
        private String route;
        private String cluster;
        private String configId;
        private boolean showDocSize;
        private double timeout;
        private boolean noRetry;
        private int traceLevel;
        private DocumentProtocol.Priority priority;
        private boolean jsonOutput = true;
        private boolean tensorShortForm;
        private boolean tensorDirectValues;

        public Builder setHelp(boolean help) {
            this.help = help;
            return this;
        }

        public Builder setDocumentIds(Iterator<String> documentIds) {
            this.documentIds = documentIds;
            return this;
        }

        public Builder setPrintIdsOnly(boolean printIdsOnly) {
            this.printIdsOnly = printIdsOnly;
            return this;
        }

        public Builder setFieldSet(String fieldSet) {
            this.fieldSet = fieldSet;
            return this;
        }

        public Builder setRoute(String route) {
            this.route = route;
            return this;
        }

        public Builder setCluster(String cluster) {
            this.cluster = cluster;
            return this;
        }

        public Builder setConfigId(String configId) {
            this.configId = configId;
            return this;
        }

        public Builder setShowDocSize(boolean showDocSize) {
            this.showDocSize = showDocSize;
            return this;
        }

        public Builder setTimeout(double timeout) {
            this.timeout = timeout;
            return this;
        }

        public Builder setNoRetry(boolean noRetry) {
            this.noRetry = noRetry;
            return this;
        }

        public Builder setTraceLevel(int traceLevel) {
            this.traceLevel = traceLevel;
            return this;
        }

        public Builder setPriority(DocumentProtocol.Priority priority) {
            this.priority = priority;
            return this;
        }

        public Builder setJsonOutput(boolean jsonOutput) {
            this.jsonOutput = jsonOutput;
            return this;
        }

        public Builder setTensorShortForm(boolean tensorShortForm) {
            this.tensorShortForm = tensorShortForm;
            return this;
        }

        public Builder setTensorDirectValues(boolean tensorDirectValues) {
            this.tensorDirectValues = tensorDirectValues;
            return this;
        }

        public ClientParameters build() {
            return new ClientParameters(
                    help, documentIds, printIdsOnly, fieldSet, route, cluster, configId,
                    showDocSize, timeout, noRetry, traceLevel, priority, jsonOutput, tensorShortForm, tensorDirectValues);
        }
    }


}