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

Method jsToPigTuple

src/org/apache/pig/scripting/js/JsFunction.java:326–356  ·  view source on GitHub ↗
(Scriptable object, Schema schema, int depth)

Source from the content-addressed store, hash-verified

324 /////////////////////////
325
326 private Tuple jsToPigTuple(Scriptable object, Schema schema, int depth) throws FrontendException, ExecException {
327 debugConvertJSToPig(depth, "Tuple", object, schema);
328 Tuple t = TupleFactory.getInstance().newTuple(schema.size());
329 for (int i = 0; i < schema.size(); i++) {
330 FieldSchema field = schema.getField(i);
331 if (object.has(field.alias, jsScriptEngine.getScope())) {
332 Object attr = object.get(field.alias, object);
333 Object value;
334 if (field.type == DataType.BAG) {
335 value = jsToPigBag((Scriptable)attr, field.schema, depth + 1);
336 } else if (field.type == DataType.TUPLE) {
337 value = jsToPigTuple((Scriptable)attr, field.schema, depth + 1);
338 } else if (field.type == DataType.MAP) {
339 value = jsToPigMap((Scriptable)attr, field.schema, depth + 1);
340 } else if (attr instanceof NativeJavaObject) {
341 value = ((NativeJavaObject)attr).unwrap();
342 } else if (attr instanceof Undefined) {
343 value = null;
344 } else {
345 value = attr;
346 }
347 t.set(i, value);
348 } else {
349 if (LOG.isDebugEnabled()) {
350 LOG.debug("X( "+field.alias+" NOT FOUND");
351 }
352 }
353 }
354 debugReturn(depth, t);
355 return t;
356 }
357
358 private Object jsToPigMap(Scriptable object, Schema schema, int depth) {
359 debugConvertJSToPig(depth, "Map", object, schema);

Callers 2

execMethod · 0.95
jsToPigBagMethod · 0.95

Calls 12

debugConvertJSToPigMethod · 0.95
getInstanceMethod · 0.95
jsToPigBagMethod · 0.95
jsToPigMapMethod · 0.95
setMethod · 0.95
debugReturnMethod · 0.95
debugMethod · 0.80
newTupleMethod · 0.65
sizeMethod · 0.65
getMethod · 0.65
getFieldMethod · 0.45
getScopeMethod · 0.45

Tested by

no test coverage detected