MCPcopy Create free account
hub / github.com/apache/pig / replaceParameters

Method replaceParameters

src/org/apache/pig/scripting/Pig.java:299–320  ·  view source on GitHub ↗

Replaces the $ with their actual values @param qstr the pig script to rewrite @param vars parameters and their values @return the modified version

(String qstr, Map<String, Object> vars)

Source from the content-addressed store, hash-verified

297 * @return the modified version
298 */
299 private String replaceParameters(String qstr, Map<String, Object> vars)
300 throws IOException {
301
302 List<String> params = new ArrayList<String>();
303 for (Entry<String, Object> entry : vars.entrySet()) {
304 params.add(entry.getKey() + "="
305 + fixNonEscapedDollarSign(entry.getValue().toString()));
306 }
307
308 PigContext context = getScriptContext().getPigContext();
309 List<String> contextParams = context.getParams();
310 if (contextParams != null) {
311 for (String param : contextParams) {
312 params.add(param);
313 }
314 }
315
316 BufferedReader reader = new BufferedReader(new StringReader(qstr));
317 String substituted = context.doParamSubstitution(reader, params, context.getParamFiles());
318 context.setParams(contextParams); // reset params that were originally in PigContext
319 return substituted;
320 }
321
322 // Escape the $ so that we can use the parameter substitution
323 // to perform bind operation. Parameter substitution will un-escape $

Callers 1

bindMethod · 0.95

Calls 12

getScriptContextMethod · 0.95
getParamsMethod · 0.95
doParamSubstitutionMethod · 0.95
getParamFilesMethod · 0.95
setParamsMethod · 0.95
entrySetMethod · 0.80
addMethod · 0.65
getValueMethod · 0.65
getKeyMethod · 0.45
toStringMethod · 0.45
getPigContextMethod · 0.45

Tested by

no test coverage detected