public DataByteArray append(byte [] ba){ return append(ba, 0, ba.length); }
public DataByteArray append(String str){ try { return append(str.getBytes("UTF8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } //TODO: better error here throw new RuntimeException("Unable to append str: " + str); }
/** * Append given byte array to the internal byte array. * @param b byte array who's contents to append. The contents of the byte array are * copied. */ public DataByteArray append(DataByteArray b) { byte[] ba = (b == null) ? null : b.get(); return append(ba, 0, ba == null ? 0 : ba.length); }
@Override public DataByteArray exec(Tuple input) throws IOException { try { if (input == null || input.size() == 0) return null; DataByteArray db = new DataByteArray(); for (int i = 0; i < input.size(); i++) { if (input.get(i)==null) return null; db.append((DataByteArray)(input.get(i))); } return db; } catch (ExecException exp) { throw exp; } catch (Exception e) { int errCode = 2106; String msg = "Error while computing concat in " + this.getClass().getSimpleName(); throw new ExecException(msg, errCode, PigException.BUG, e); } }
/** * This calls to the append function of the underlying DataByteArray. This accepts * the same types that set accepts. * * @param context the context the method is being executed in * @param arg a value to append to the encpasulated DataByteArray. In the case of a * RubyDataByteArray, the bytes will be copied and appended; in the case * of a String, the bits will be added; in the case of a byte array, * the bytes will be appended directly. */ @JRubyMethod(name = {"add!", "append"}) public void append(ThreadContext context, IRubyObject arg) { Ruby runtime = context.getRuntime(); RubyDataByteArray toAppend = new RubyDataByteArray(runtime, runtime.getClass("DataByteArray")).initialize(arg); internalDBA.append(toAppend.getDBA()); }