@Override public boolean nextKeyValue() throws IOException { if(key == null) { key = new GuaguaWritableAdapter<BytesWritable>(new BytesWritable()); } if(value == null) { value = new GuaguaWritableAdapter<BytesWritable>(new BytesWritable()); } return this.sequenceReader.next(key.getWritable(), value.getWritable()); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (isHalt() ? 1231 : 1237); result = prime * result + ((writable == null) ? 0 : writable.hashCode()); return result; }
/** * Contructor with Hadoop Writable setting. * * @param writable * Hadoop Writable instance */ public GuaguaWritableAdapter(W writable) { this.setWritable(writable); }
@Override public void load(GuaguaWritableAdapter<Text> currentKey, GuaguaWritableAdapter<Text> currentValue, WorkerContext<GuaguaWritableAdapter<LongWritable>, GuaguaWritableAdapter<LongWritable>> workerContext) { this.list.add(Long.parseLong(currentValue.getWritable().toString())); }
@Override public GuaguaWritableAdapter<LongWritable> compute( MasterContext<GuaguaWritableAdapter<LongWritable>, GuaguaWritableAdapter<LongWritable>> context) { long sum = 0l; if(context.getWorkerResults() == null) { LOG.info("Master accumulates worker results with null or empty."); return null; } for(GuaguaWritableAdapter<LongWritable> longWritable: context.getWorkerResults()) { if(longWritable != null) { sum += longWritable.getWritable().get(); } } LOG.info("master:{}", sum); GuaguaWritableAdapter<LongWritable> result = new GuaguaWritableAdapter<LongWritable>(new LongWritable(sum)); if(sum > 1000000L) { result.setHalt(true); } return result; }
GuaguaWritableAdapter<Writable> result = new GuaguaWritableAdapter<Writable>(writable); DataInputStream dataIn = null; try { ByteArrayInputStream in = new ByteArrayInputStream(data); dataIn = new DataInputStream(in); result.readFields(dataIn); } catch (Exception e) { throw new GuaguaRuntimeException(e);
@Override public GuaguaWritableAdapter<Tuple> getCurrentValue() { try { return new GuaguaWritableAdapter<Tuple>(this.parquetRecordReader.getCurrentValue()); } catch (IOException e) { throw new GuaguaRuntimeException(e); } catch (InterruptedException e) { throw new GuaguaRuntimeException(e); } }
@Override public void load(GuaguaWritableAdapter<Text> currentKey, GuaguaWritableAdapter<Text> currentValue, WorkerContext<GuaguaWritableAdapter<LongWritable>, GuaguaWritableAdapter<LongWritable>> workerContext) { this.list.add(Long.parseLong(currentValue.getWritable().toString())); }
@Override public GuaguaWritableAdapter<LongWritable> compute( MasterContext<GuaguaWritableAdapter<LongWritable>, GuaguaWritableAdapter<LongWritable>> context) { long sum = 0l; if(context.getWorkerResults() == null) { LOG.info("Master accumulates worker results with null or empty."); return null; } for(GuaguaWritableAdapter<LongWritable> longWritable: context.getWorkerResults()) { if(longWritable != null) { sum += longWritable.getWritable().get(); } } LOG.info("master:{}", sum); GuaguaWritableAdapter<LongWritable> result = new GuaguaWritableAdapter<LongWritable>(new LongWritable(sum)); if(sum > 1000000L) { result.setHalt(true); } return result; }
GuaguaWritableAdapter<Writable> result = new GuaguaWritableAdapter<Writable>(writable); DataInputStream dataIn = null; try { ByteArrayInputStream in = new ByteArrayInputStream(data); dataIn = new DataInputStream(in); result.readFields(dataIn); } catch (Exception e) { throw new GuaguaRuntimeException(e);
@Override public boolean nextKeyValue() throws IOException { if(key == null) { key = new GuaguaWritableAdapter<Text>(new Text()); } if(value == null) { value = new GuaguaWritableAdapter<Text>(new Text()); } return this.sequenceReader.next(key.getWritable(), value.getWritable()); }
@Override public void load(GuaguaWritableAdapter<LongWritable> currentKey, GuaguaWritableAdapter<Text> currentValue, WorkerContext<GuaguaWritableAdapter<LongWritable>, GuaguaWritableAdapter<LongWritable>> workerContext) { this.list.add(Long.parseLong(currentValue.getWritable().toString())); }
GuaguaWritableAdapter<Writable> result = new GuaguaWritableAdapter<Writable>(writable); DataInputStream dataIn = null; try { ByteArrayInputStream in = new ByteArrayInputStream(data); dataIn = new DataInputStream(in); result.readFields(dataIn); } catch (Exception e) { throw new GuaguaRuntimeException(e);
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (isHalt() ? 1231 : 1237); result = prime * result + ((writable == null) ? 0 : writable.hashCode()); return result; }
/** * Contructor with Hadoop Writable setting. * * @param writable * Hadoop Writable instance */ public GuaguaWritableAdapter(W writable) { this.setWritable(writable); }
@Override public boolean nextKeyValue() throws IOException { if(key == null) { key = new GuaguaWritableAdapter<Text>(new Text()); } if(value == null) { value = new GuaguaWritableAdapter<Text>(new Text()); } return this.sequenceReader.next(key.getWritable(), value.getWritable()); }
@Override public void load(GuaguaWritableAdapter<LongWritable> currentKey, GuaguaWritableAdapter<Text> currentValue, WorkerContext<GuaguaWritableAdapter<LongWritable>, GuaguaWritableAdapter<LongWritable>> context) { this.list.append(Long.parseLong(currentValue.getWritable().toString())); }
GuaguaWritableAdapter<Writable> result = new GuaguaWritableAdapter<Writable>(writable); DataInputStream dataIn = null; try { ByteArrayInputStream in = new ByteArrayInputStream(data); dataIn = new DataInputStream(in); result.readFields(dataIn); } catch (Exception e) { throw new GuaguaRuntimeException(e);
@Override public boolean equals(Object obj) { if(this == obj) return true; if(obj == null) return false; if(getClass() != obj.getClass()) return false; GuaguaWritableAdapter<?> other = (GuaguaWritableAdapter<?>) obj; if(isHalt() != other.isHalt()) return false; if(writable == null) { if(other.writable != null) return false; } else if(!writable.equals(other.writable)) return false; return true; }
@Override public boolean nextKeyValue() throws IOException { if(key == null) { key = new GuaguaWritableAdapter<BytesWritable>(new BytesWritable()); } if(value == null) { value = new GuaguaWritableAdapter<BytesWritable>(new BytesWritable()); } return this.sequenceReader.next(key.getWritable(), value.getWritable()); }