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

Method pigBagToJS

src/org/apache/pig/scripting/js/JsFunction.java:306–320  ·  view source on GitHub ↗

converts a bag to javascript object based on a schema @param bag the bag to convert @param schema the schema to use for conversion @param depth call depth used for debugging messages @return the resulting javascript object @throws FrontendException @throws ExecException

(DataBag bag, Schema schema, int depth)

Source from the content-addressed store, hash-verified

304 * @throws ExecException
305 */
306 private Scriptable pigBagToJS(DataBag bag, Schema schema, int depth) throws FrontendException, ExecException {
307 debugConvertPigToJS(depth, "Bag", bag, schema);
308 if (schema.size() == 1 && schema.getField(0).type == DataType.TUPLE) {
309 // unwrapping as bags always contain a tuple
310 schema = schema.getField(0).schema;
311 }
312 Scriptable array = jsScriptEngine.jsNewArray(bag.size());
313 array.setParentScope(jsScriptEngine.getScope());
314 int i= 0;
315 for (Tuple t : bag) {
316 array.put(i++, array, pigTupleToJS(t, schema, depth + 1));
317 }
318 debugReturn(depth, array);
319 return array;
320 }
321
322 /////////////////////////
323 // Conversion JS to Pig

Callers 1

pigTupleToJSMethod · 0.95

Calls 8

debugConvertPigToJSMethod · 0.95
pigTupleToJSMethod · 0.95
debugReturnMethod · 0.95
jsNewArrayMethod · 0.80
sizeMethod · 0.65
getFieldMethod · 0.45
getScopeMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected