protected T createNewInstance(Class<T> targetClass) { try { return targetClass.newInstance(); } catch (InstantiationException e) { throw new CrunchRuntimeException(e); } catch (IllegalAccessException e) { throw new CrunchRuntimeException(e); } }
public void process(Object input) { try { fn.process(input, emitter); } catch (CrunchRuntimeException e) { if (!e.wasLogged()) { LOG.info("Crunch exception in '{}' for input: {}", new Object[]{nodeName, input, e}); e.markLogged(); } throw e; } }
@Override public String map(T input) { try { return mapper.writeValueAsString(input); } catch (Exception e) { throw new CrunchRuntimeException(e); } } }
public void process(Object input) { try { fn.process(input, emitter); } catch (CrunchRuntimeException e) { if (!e.wasLogged()) { LOG.info(String.format("Crunch exception in '%s' for input: %s", nodeName, input.toString()), e); e.markLogged(); } throw e; } }
@Override public T map(String input) { try { return mapper.readValue(input, clazz); } catch (Exception e) { throw new CrunchRuntimeException(e); } } }
@Override public T makeTuple(Object... values) { try { return constructor.newInstance(values); } catch (Exception e) { throw new CrunchRuntimeException(e); } } }
@Override public void initialize() { try { constructor = clazz.getConstructor(typeArgs); } catch (Exception e) { throw new CrunchRuntimeException(e); } }
@Override public T map(String input) { try { return mapper.readValue(input, clazz); } catch (Exception e) { throw new CrunchRuntimeException(e); } } }
@Override public void initialize() { try { constructor = clazz.getConstructor(typeArgs); } catch (Exception e) { throw new CrunchRuntimeException(e); } }
@Override public String map(T input) { try { return mapper.writeValueAsString(input); } catch (Exception e) { throw new CrunchRuntimeException(e); } } }
@Override public T makeTuple(Object... values) { try { return constructor.newInstance(values); } catch (Exception e) { throw new CrunchRuntimeException(e); } } }
public void cleanup() { if (multipleOutputs != null) { try { multipleOutputs.close(); } catch (IOException e) { throw new CrunchRuntimeException(e); } catch (InterruptedException e) { throw new CrunchRuntimeException(e); } } }
public void cleanup() { if (multipleOutputs != null) { try { multipleOutputs.close(); } catch (IOException e) { throw new CrunchRuntimeException(e); } catch (InterruptedException e) { throw new CrunchRuntimeException(e); } } }
protected T createNewInstance(Class<T> targetClass) { try { Constructor<T> ctor = targetClass.getDeclaredConstructor(); ctor.setAccessible(true); return ctor.newInstance(); } catch (ReflectiveOperationException e) { throw new CrunchRuntimeException(e); } } }
protected void setValueType(String valueType) { if (valueClass == null) { try { valueClass = Class.forName(valueType).asSubclass(Writable.class); } catch (ClassNotFoundException e) { throw new CrunchRuntimeException(e); } } else if (!valueType.equals(valueClass.getName())) { throw new IllegalStateException("Incoming " + valueType + " is not " + valueClass); } }
@Override public void cleanup(Emitter<Pair<K2, V2>> emitter) { if (cleanupMethod != null) { handler.set(emitter); try { cleanupMethod.invoke(instance, context); } catch (Exception e) { throw new CrunchRuntimeException(e); } } } }
@Override public Double map(T input) { try { return call(input); } catch (Exception e) { throw new CrunchRuntimeException(e); } } }
@Override public void initialize() { this.deserializer = ReflectionUtils.newInstance(serClazz, null).getDeserializer(clazz); if (deserializer == null) { throw new CrunchRuntimeException("No Hadoop deserializer for class: " + clazz); } }
@Override public void initialize() { this.serializer = ReflectionUtils.newInstance(serClazz, null).getSerializer(clazz); if (serializer == null) { throw new CrunchRuntimeException("No Hadoop serializer for class: " + clazz); } }
private void delete(View view) { try { boolean deleted = view.deleteAll(); if (!deleted) { LOG.warn("No data was deleted."); } } catch (UnsupportedOperationException e) { LOG.error("Dataset view " + view + " cannot be deleted!"); throw new CrunchRuntimeException("Dataset view cannot be deleted:" + view, e); } }