List of usage examples for org.apache.hadoop.mapred FileSplit write
public void write(DataOutput out) throws IOException
From source file:com.ibm.jaql.lang.expr.io.MakeFileSplitFn.java
License:Apache License
@Override public JsonRecord eval(Context context) throws Exception { if (out == null) { out = new DataOutputBuffer(); className = new MutableJsonString(); rawSplit = new MutableJsonBinary(); values = new JsonValue[] { className, rawSplit, null }; resultRec = new BufferedJsonRecord(); resultRec.set(NAMES, values, NAMES.length); }/*from ww w .j av a 2s . co m*/ JsonString jfile = (JsonString) exprs[0].eval(context); JsonNumber jstart = (JsonNumber) exprs[1].eval(context); JsonNumber jlength = (JsonNumber) exprs[2].eval(context); JsonArray jhosts = (JsonArray) exprs[3].eval(context); String file = jfile.toString(); long start = jstart.longValueExact(); long length = jlength.longValueExact(); if (jhosts == null) jhosts = JsonArray.EMPTY; String[] hosts = new String[(int) jhosts.count()]; JsonIterator iter = jhosts.iter(); for (int i = 0; i < hosts.length; i++) { iter.moveNext(); JsonString jhost = (JsonString) iter.current(); hosts[i] = jhost.toString(); } FileSplit split = new FileSplit(new Path(file), start, length, hosts); className.setCopy(split.getClass().getCanonicalName()); out.reset(); split.write(out); rawSplit.set(out.getData(), out.getLength()); values[2] = jhosts; return resultRec; }