/** * @param flowProcess * @param sourceCall * @return * @throws IOException */ @Override public boolean source( FlowProcess<JobConf> flowProcess, SourceCall<BSONWritable[], RecordReader> sourceCall) throws IOException { Tuple result = new Tuple(); BSONWritable key = sourceCall.getContext()[0]; BSONWritable value = sourceCall.getContext()[1]; if (!sourceCall.getInput().next(key, value)) { logger.info("Nothing left to read, exiting"); return false; } for (String columnFieldName : columnFieldNames) { Object tupleEntry = value.get(columnFieldName); if (tupleEntry != null) { result.add(tupleEntry); } else if (columnFieldName != this.keyColumnName) { result.add(""); } } sourceCall.getIncomingEntry().setTuple(result); return true; }
/** * @param flowProcess * @param sourceCall */ @Override public void sourcePrepare( FlowProcess<JobConf> flowProcess, SourceCall<BSONWritable[], RecordReader> sourceCall) { sourceCall.setContext(new BSONWritable[2]); sourceCall.getContext()[0] = (BSONWritable) sourceCall.getInput().createKey(); sourceCall.getContext()[1] = (BSONWritable) sourceCall.getInput().createValue(); }
@SuppressWarnings("unchecked") @Override public boolean source(FlowProcess<JobConf> fp, SourceCall<Object[], RecordReader> sc) throws IOException { Container<Tuple> value = (Container<Tuple>) sc.getInput().createValue(); boolean hasNext = sc.getInput().next(null, value); if (!hasNext) { return false; } // Skip nulls if (value == null) { return true; } sc.getIncomingEntry().setTuple(value.get()); return true; }
@Override public void sourcePrepare( FlowProcess<? extends Properties> flowProcess, SourceCall<LineNumberReader, InputStream> sourceCall) throws IOException { sourceCall.setContext(createInput(sourceCall.getInput())); sourceCall.getIncomingEntry().setTuple(TupleViews.createObjectArray()); }