/** * Method entryStream returns a {@link Stream} of {@link TupleEntry} instances from the given * Tap instance. * <p> * Also see {@link cascading.tuple.TupleEntryStream#entryStream(Tap, FlowProcess, Fields)}. * <p> * Note, the returned Stream instance must be closed in order to clean up underlying resources. This * is simply accomplished with a try-with-resources statement. * * @param flowProcess represents the current platform configuration * @param selector the fields to select from the underlying TupleEntry * @return a Stream of TupleEntry instances */ public Stream<TupleEntry> entryStream( FlowProcess<? extends Config> flowProcess, Fields selector ) { return entryStream( flowProcess ).map( tupleEntry -> tupleEntry.selectEntry( selector ) ); }
boolean isRemove( FlowProcess flowProcess, TupleEntry partitionEntry ) { return filter.isRemove( flowProcess, getFilterCallWith( partitionEntry.selectEntry( argumentFields ) ) ); }
@Override public boolean isRemove(@SuppressWarnings("rawtypes") FlowProcess flowProcess, FilterCall<Void> filterCall) { PrintStream stream = streamSupplier.getPrintStream(); if (firstRecord) { stream.append(prefix); for (Comparable<?> value : filterCall.getArguments().getFields().select(fieldsOfInterest)) { stream.append(value.toString()); stream.append('\t'); } stream.append('\n'); firstRecord = false; } stream.append(prefix); for (String value : filterCall.getArguments().selectEntry(fieldsOfInterest).asIterableOf(String.class)) { stream.append(value); stream.append('\t'); } stream.append('\n'); return false; }
@Override public void sink(FlowProcess<JobConf> flowProcess, SinkCall<Object[], OutputCollector> sinkCall) throws IOException { TupleEntry tupleEntry = sinkCall.getOutgoingEntry(); OutputCollector outputCollector = sinkCall.getOutput(); Tuple key = tupleEntry.selectTuple(keyField); ImmutableBytesWritable keyBytes = (ImmutableBytesWritable) key.getObject(0); Put put = new Put(keyBytes.get()); for (int i = 0; i < valueFields.length; i++) { Fields fieldSelector = valueFields[i]; TupleEntry values = tupleEntry.selectEntry(fieldSelector); for (int j = 0; j < values.getFields().size(); j++) { Fields fields = values.getFields(); Tuple tuple = values.getTuple(); ImmutableBytesWritable valueBytes = (ImmutableBytesWritable) tuple.getObject(j); put.add(Bytes.toBytes(familyNames[i]), Bytes.toBytes((String) fields.get(j)), valueBytes.get()); } } outputCollector.collect(null, put); }