MCPcopy Create free account
hub / github.com/apache/solr / runImpl

Method runImpl

solr/core/src/java/org/apache/solr/cli/StreamTool.java:139–251  ·  view source on GitHub ↗
(CommandLine cli)

Source from the content-addressed store, hash-verified

137 }
138
139 @Override
140 @SuppressWarnings({"rawtypes"})
141 public void runImpl(CommandLine cli) throws Exception {
142
143 String expressionArgument = cli.getArgs()[0];
144 String execution = cli.getOptionValue(EXECUTION_OPTION, "remote");
145 String arrayDelimiter = cli.getOptionValue(ARRAY_DELIMITER_OPTION, "|");
146 String delimiter = cli.getOptionValue(DELIMITER_OPTION, " ");
147 boolean includeHeaders = cli.hasOption(HEADER_OPTION);
148 String[] outputHeaders = getOutputFields(cli);
149
150 LineNumberReader bufferedReader = null;
151 String expr;
152 try {
153 Reader inputStream =
154 expressionArgument.toLowerCase(Locale.ROOT).endsWith(".expr")
155 ? new InputStreamReader(
156 new FileInputStream(expressionArgument), Charset.defaultCharset())
157 : new StringReader(expressionArgument);
158
159 bufferedReader = new LineNumberReader(inputStream);
160 expr = StreamTool.readExpression(bufferedReader, cli.getArgs());
161 echoIfVerbose("Running Expression: " + expr);
162 } finally {
163 if (bufferedReader != null) {
164 bufferedReader.close();
165 }
166 }
167
168 // Validate inputs before opening any connection to Solr.
169 boolean local = execution.equalsIgnoreCase("local");
170 if (!local) {
171 if (!cli.hasOption(COLLECTION_OPTION)) {
172 throw new IllegalStateException(
173 "You must provide --name COLLECTION with --execution remote parameter.");
174 }
175 if (expr.toLowerCase(Locale.ROOT).contains("stdin(")) {
176 throw new IllegalStateException(
177 "The stdin() expression is only usable with --execution local.");
178 }
179 }
180
181 // a stream needs a context
182 StreamContext streamContext = createStreamContext(cli);
183 // create the stream
184 PushBackStream pushBackStream = null;
185 try {
186 if (local) {
187 pushBackStream = doLocalMode(expr, streamContext.getStreamFactory());
188 } else {
189 pushBackStream = doRemoteMode(expr, cli);
190 }
191 pushBackStream.setStreamContext(streamContext);
192 pushBackStream.open();
193
194 if (outputHeaders == null) {
195
196 Tuple tuple = pushBackStream.read();

Callers

nothing calls this directly

Calls 15

getOutputFieldsMethod · 0.95
readExpressionMethod · 0.95
createStreamContextMethod · 0.95
doLocalModeMethod · 0.95
getStreamFactoryMethod · 0.95
doRemoteModeMethod · 0.95
setStreamContextMethod · 0.95
openMethod · 0.95
readMethod · 0.95
pushBackMethod · 0.95
outMethod · 0.95

Tested by

no test coverage detected