Java Code Examples for org.apache.pig.backend.executionengine.ExecException#printStackTrace()
The following examples show how to use
org.apache.pig.backend.executionengine.ExecException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColumnarTupleStore.java From Cubert with Apache License 2.0 | 6 votes |
@Override public Tuple getTuple(int index, Tuple reuse) { if (reuse == null) { return new ColumnStoreTuple(index); } else if (reuse instanceof ColumnStoreTuple) { ((ColumnStoreTuple) reuse).rowid = index; return reuse; } try { for (int i = 0; i < nColumns; ++i) { reuse.set(i, dataStore[i].get(index)); } return reuse; } catch (ExecException e) { e.printStackTrace(); throw new RuntimeException(e); } }
Example 2
Source File: ColumnarTupleStore.java From Cubert with Apache License 2.0 | 6 votes |
@Override public List<Object> getAll() { List<Object> fields = new ArrayList<Object>(nColumns); try { for (int i = 0; i < nColumns; ++i) { fields.add(get(i)); } return fields; } catch (ExecException e) { e.printStackTrace(); throw new RuntimeException(e); } }
Example 3
Source File: TestPOUserFunc.java From spork with Apache License 2.0 | 6 votes |
@Override public Double exec(Tuple input) throws IOException { double sum = 0; double count = 0; try { DataBag b = (DataBag) input.get(0); Tuple combined = combine(b); sum = (Double) combined.get(0); count = (Long) combined.get(1); } catch (ExecException e) { e.printStackTrace(); } double avg = 0; if (count > 0) { avg = sum / count; } return new Double(avg); }
Example 4
Source File: TestPOUserFunc.java From spork with Apache License 2.0 | 6 votes |
@Override public Double exec(Tuple input) throws IOException { double sum = 0; double count = 0; try { sum = sum(input); count = count(input); } catch (ExecException e) { e.printStackTrace(); } double avg = 0; if (count > 0) avg = sum / count; return new Double(avg); }
Example 5
Source File: TestCompactSerialization.java From Cubert with Apache License 2.0 | 6 votes |
private Tuple newTuple(Object... args) { Tuple tuple = TupleFactory.getInstance().newTuple(args.length); for (int i = 0; i < args.length; i++) { try { tuple.set(i, args[i]); } catch (ExecException e) { e.printStackTrace(); throw new RuntimeException(e); } } return tuple; }
Example 6
Source File: TestPOUserFunc.java From spork with Apache License 2.0 | 6 votes |
@Override public int compare(Tuple t1, Tuple t2) { // TODO Auto-generated method stub Object o1 = null; Object o2 = null; try { o1 = t1.get(2); o2 = t2.get(2); } catch (ExecException e) { // TODO Auto-generated catch block e.printStackTrace(); } if ( o1==null || o2==null ){ return -1; } int i1 = (Integer) o1 - 2; int i2 = (Integer) o2 - 2; return (int) (i1 * i1 - i2 * i2); }
Example 7
Source File: PigAvroDatumWriter.java From spork with Apache License 2.0 | 5 votes |
/** * Called by the implementation of {@link #writeRecord} to retrieve * a record field value. */ protected Object getField(Object record, String name, int pos) { if (record instanceof Tuple) { try { return ((Tuple) record).get(pos); } catch (ExecException e) { e.printStackTrace(); throw new RuntimeException(e); } } else throw new RuntimeException("Unsupported type in record:" + record.getClass()); }
Example 8
Source File: LookUpTable.java From Cubert with Apache License 2.0 | 5 votes |
@Override public boolean containsKey(Object key) { try { return hashCodeArr[keyHashCode((Tuple) key)] != -1; } catch (ExecException e) { e.printStackTrace(); throw new RuntimeException(e); } }
Example 9
Source File: TestFilterUDF.java From spork with Apache License 2.0 | 5 votes |
@Override public Boolean exec(Tuple input) throws IOException { try { int col = (Integer)input.get(0); if (col > 10) return true; } catch (ExecException e) { // TODO Auto-generated catch block e.printStackTrace(); } return false; }
Example 10
Source File: TestPOUserFunc.java From spork with Apache License 2.0 | 5 votes |
@Override public Integer exec(Tuple input) throws IOException { try { return new Integer(((Tuple)input.get(0)).size()); } catch (ExecException e) { // TODO Auto-generated catch block e.printStackTrace(); } return 0; }
Example 11
Source File: TestPOSort.java From spork with Apache License 2.0 | 5 votes |
@Override public int compare(Tuple t1, Tuple t2) { // TODO Auto-generated method stub int result = 0; try { int i1 = ((Integer) t1.get(1) == null ? 0 : (Integer)t1.get(1)); int i2 = ((Integer) t2.get(1) == null ? 0 : (Integer)t2.get(1)); result = (i1 - 50) * (i1 - 50) - (i2 - 50) * (i2 - 50); } catch (ExecException e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; }
Example 12
Source File: TestTuple.java From spork with Apache License 2.0 | 5 votes |
@Test public void testTupleFormat() { try { Tuple tuple = mTupleFactory.newTuple(7); tuple.set(0, 12); Map<String, String> map = new HashMap<String, String>(); map.put("pig", "scalability"); tuple.set(1, map); tuple.set(2, null); tuple.set(3, 12L); tuple.set(4, 1.2F); Tuple innerTuple = mTupleFactory.newTuple(1); innerTuple.set(0, "innerTuple"); tuple.set(5, innerTuple); DataBag bag = BagFactory.getInstance().newDefaultBag(); bag.add(innerTuple); tuple.set(6, bag); assertEquals( "(12,[pig#scalability],,12,1.2,(innerTuple),{(innerTuple)})", TupleFormat.format(tuple)); } catch (ExecException e) { e.printStackTrace(); fail(); } }
Example 13
Source File: TestJobSubmission.java From spork with Apache License 2.0 | 5 votes |
public static void oneTimeSetUp() throws Exception { cluster = MiniGenericCluster.buildCluster(); pc = new PigContext(cluster.getExecType(), cluster.getProperties()); try { pc.connect(); } catch (ExecException e) { // TODO Auto-generated catch block e.printStackTrace(); } GenPhyOp.setPc(pc); Util.copyFromLocalToCluster(cluster, "test/org/apache/pig/test/data/passwd", "/passwd"); }
Example 14
Source File: TupleFormat.java From spork with Apache License 2.0 | 5 votes |
/** * Default implementation of format of tuple (each filed is delimited by * tab) * * @param tuple * @return Default format of Tuple */ @SuppressWarnings("unchecked") public static String format(Tuple tuple) { StringBuilder sb = new StringBuilder(); sb.append('('); for (int i = 0; i < tuple.size(); ++i) { try { Object d = tuple.get(i); if (d != null) { if (d instanceof Map) { sb.append(DataType.mapToString((Map<String, Object>) d)); } else if (d instanceof Tuple) { Tuple t = (Tuple) d; sb.append(TupleFormat.format(t)); } else if (d instanceof DataBag){ DataBag bag=(DataBag)d; sb.append(BagFormat.format(bag)); } else { sb.append(d.toString()); } } else { sb.append(""); } if (i != tuple.size() - 1) sb.append(","); } catch (ExecException e) { e.printStackTrace(); mLog.warn("Exception when format tuple", e); } } sb.append(')'); return sb.toString(); }
Example 15
Source File: CubertPartitioner.java From Cubert with Apache License 2.0 | 5 votes |
@Override public int getPartition(Tuple key, V value, int numPartitions) { try { for (int i = 0; i < partitionKeyIndex.size(); i++) { Object o = null; if (partitionKeyIndex.get(i).getFirst()) o = key.get(partitionKeyIndex.get(i).getSecond()); else o = ((Tuple) value).get(partitionKeyIndex.get(i).getSecond()); keyTuple.set(i, o); } } catch (ExecException e) { e.printStackTrace(); } // This has to be cast to long; // If it is int, and the hashcode is -2147483648, negative or math.abs(), or *-1 // of this all return negative numbers long hashcode = BlockUtils.getBlockId(keyTuple); return (int) (hashcode % numPartitions); }
Example 16
Source File: PigAvroDatumWriter.java From Cubert with Apache License 2.0 | 5 votes |
/** * Called by the implementation of {@link #writeRecord} to retrieve * a record field value. */ protected Object getField(Object record, String name, int pos) { if (record instanceof Tuple) { try { return ((Tuple) record).get(pos); } catch (ExecException e) { e.printStackTrace(); throw new RuntimeException(e); } } else throw new RuntimeException("Unsupported type in record:" + record.getClass()); }
Example 17
Source File: SerializedTupleStore.java From Cubert with Apache License 2.0 | 5 votes |
private void putTupleAndOffset(Tuple mytuple, Integer offset) { Integer startOffsetOfTuple = offset; try { List<Integer> innerList = getInnerOffsetList(mytuple); if (innerList == null) { oneKey.set(mytuple); int key = oneKey.hashCode(); if (tupleMap.get(key) == null) tupleMap.put(key, new HashMap<Integer, ArrayList<Integer>>()); HashMap<Integer, ArrayList<Integer>> subHashTable = tupleMap.get(key); ArrayList<Integer> offsetList = new ArrayList<Integer>(); offsetList.add(startOffsetOfTuple); subHashTable.put(startOffsetOfTuple, offsetList); } else { innerList.add(offset); } } catch (ExecException e) { e.printStackTrace(); } }
Example 18
Source File: PigAvroDatumWriter.java From Cubert with Apache License 2.0 | 4 votes |
/** * Recursively check whether "datum" is an instance of "schema" and called * by {@link #resolveUnionSchema(Schema,Object)}, * {@link #unwrappedInstanceOf(Schema,Object)}. * */ protected boolean instanceOf(Schema schema, Object datum) throws IOException { try { switch (schema.getType()) { case RECORD: if (datum instanceof Tuple) { Tuple tuple = (Tuple) datum; List<Field> fields = schema.getFields(); if (fields.size() != tuple.size()) { return false; } for (int i = 0; i < fields.size(); i++) { if (!instanceOf(fields.get(i).schema(), tuple.get(i))) return false; } return true; } return false; case UNION: @SuppressWarnings("unused") int index = resolveUnionSchema(schema, datum); return true; case ENUM: return datum instanceof String && schema.hasEnumSymbol(((String) datum)) || unwrappedInstanceOf(schema, datum); case ARRAY: return datum instanceof DataBag || unwrappedInstanceOf(schema, datum); case MAP: return datum instanceof Map || unwrappedInstanceOf(schema, datum); case FIXED: return datum instanceof DataByteArray && ((DataByteArray) datum).size() == schema.getFixedSize() || unwrappedInstanceOf(schema, datum); case STRING: return datum instanceof String || unwrappedInstanceOf(schema, datum); case BYTES: return datum instanceof DataByteArray || unwrappedInstanceOf(schema, datum); case INT: return datum instanceof Integer || unwrappedInstanceOf(schema, datum); case LONG: return datum instanceof Long || datum instanceof Integer || unwrappedInstanceOf(schema, datum); case FLOAT: return datum instanceof Float || datum instanceof Integer || datum instanceof Long || unwrappedInstanceOf(schema, datum); case DOUBLE: return datum instanceof Double || datum instanceof Float || datum instanceof Integer || datum instanceof Long || unwrappedInstanceOf(schema, datum); case BOOLEAN: return datum instanceof Boolean || datum instanceof Integer || unwrappedInstanceOf(schema, datum); case NULL: return datum == null; default: throw new RuntimeException("Unexpected type: " + schema); } } catch (ExecException e) { e.printStackTrace(System.err); throw new RuntimeException(e); } }
Example 19
Source File: PigAvroDatumWriter.java From spork with Apache License 2.0 | 4 votes |
/** * Recursively check whether "datum" is an instance of "schema" and called * by {@link #resolveUnionSchema(Schema,Object)}, * {@link #unwrappedInstanceOf(Schema,Object)}. * */ protected boolean instanceOf(Schema schema, Object datum) throws IOException { try { switch (schema.getType()) { case RECORD: if (datum instanceof Tuple) { Tuple tuple = (Tuple) datum; List<Field> fields = schema.getFields(); if (fields.size() != tuple.size()) { return false; } for (int i = 0; i < fields.size(); i++) { if (!instanceOf(fields.get(i).schema(), tuple.get(i))) return false; } return true; } return false; case UNION: @SuppressWarnings("unused") int index = resolveUnionSchema(schema, datum); return true; case ENUM: return datum instanceof String && schema.hasEnumSymbol(((String) datum)) || unwrappedInstanceOf(schema, datum); case ARRAY: return datum instanceof DataBag || unwrappedInstanceOf(schema, datum); case MAP: return datum instanceof Map || unwrappedInstanceOf(schema, datum); case FIXED: return datum instanceof DataByteArray && ((DataByteArray) datum).size() == schema.getFixedSize() || unwrappedInstanceOf(schema, datum); case STRING: return datum instanceof String || unwrappedInstanceOf(schema, datum); case BYTES: return datum instanceof DataByteArray || unwrappedInstanceOf(schema, datum); case INT: return datum instanceof Integer || unwrappedInstanceOf(schema, datum); case LONG: return datum instanceof Long || datum instanceof Integer || unwrappedInstanceOf(schema, datum); case FLOAT: return datum instanceof Float || datum instanceof Integer || datum instanceof Long || unwrappedInstanceOf(schema, datum); case DOUBLE: return datum instanceof Double || datum instanceof Float || datum instanceof Integer || datum instanceof Long || unwrappedInstanceOf(schema, datum); case BOOLEAN: return datum instanceof Boolean || datum instanceof Integer || unwrappedInstanceOf(schema, datum); case NULL: return datum == null; default: throw new RuntimeException("Unexpected type: " + schema); } } catch (ExecException e) { e.printStackTrace(System.err); throw new RuntimeException(e); } }