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

Class PreprocessorContext

src/org/apache/pig/tools/parameters/PreprocessorContext.java:52–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50import org.apache.pig.validator.PigCommandFilter;
51
52public class PreprocessorContext {
53
54 private int tableinitsize = 10;
55 private Deque<Map<String,String>> param_val_stack;
56
57 private PigContext pigContext;
58
59 public Map<String, String> getParamVal() {
60 Map <String, String> ret = new Hashtable <String, String>(tableinitsize);
61
62 //stack (deque) iterates LIFO
63 for (Map <String, String> map : param_val_stack ) {
64 for (Map.Entry<String, String> entry : map.entrySet()) {
65 if( ! ret.containsKey(entry.getKey()) ) {
66 ret.put(entry.getKey(), entry.getValue());
67 }
68 }
69 }
70 return ret;
71 }
72
73 private final Log log = LogFactory.getLog(getClass());
74
75 /**
76 * @param limit - max number of parameters. Passing
77 * smaller number only impacts performance
78 */
79 public PreprocessorContext(int limit) {
80 tableinitsize = limit;
81 param_val_stack = new ArrayDeque<Map<String,String>> ();
82 param_val_stack.push(new Hashtable<String, String> (tableinitsize));
83 }
84
85 public void setPigContext(PigContext context) {
86 this.pigContext = context;
87 }
88
89 /**
90 * This method generates parameter value by running specified command
91 *
92 * @param key - parameter name
93 * @param val - string containing command to be executed
94 */
95 public void processShellCmd(String key, String val) throws ParameterSubstitutionException, FrontendException {
96 processShellCmd(key, val, true);
97 }
98
99 /**
100 * This method generates value for the specified key by
101 * performing substitution if needed within the value first.
102 *
103 * @param key - parameter name
104 * @param val - value supplied for the key
105 */
106 public void processOrdLine(String key, String val) throws ParameterSubstitutionException {
107 processOrdLine(key, val, true);
108 }
109

Callers

nothing calls this directly

Calls 2

getClassMethod · 0.80
compileMethod · 0.45

Tested by

no test coverage detected