cascading.tuple.TupleEntryIterator Java Examples

The following examples show how to use cascading.tuple.TupleEntryIterator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TapDataReader.java    From plunger with Apache License 2.0 6 votes vote down vote up
/**
 * Reads the {@link Tuple Tuples} from the {@link Tap} and returns them wrapped in a {@link Data} instance whose
 * {@link Fields} confirm to those supplied by {@link Tap#getSourceFields()}.
 */
Data read() throws IOException {
  TupleEntryIterator tuples = null;
  try {
    Class<?> tapConfigClass = TapTypeUtil.getTapConfigClass(source);

    if (Configuration.class.equals(tapConfigClass)) {
      tuples = getHadoopTupleEntryIterator();
    } else if (Properties.class.equals(tapConfigClass)) {
      tuples = getLocalTupleEntryIterator();
    } else {
      throw new IllegalArgumentException("Unsupported tap type: " + source.getClass());
    }
    List<Tuple> resultTuples = new ArrayList<Tuple>();
    while (tuples.hasNext()) {
      Tuple copy = new Tuple(tuples.next().getTupleCopy());
      resultTuples.add(copy);
    }
    return new Data(source.getSourceFields(), Collections.unmodifiableList(resultTuples));
  } finally {
    if (tuples != null) {
      tuples.close();
    }
  }
}
 
Example #2
Source File: TapDataReader.java    From plunger with Apache License 2.0 5 votes vote down vote up
private TupleEntryIterator getHadoopTupleEntryIterator() throws IOException {
  @SuppressWarnings("unchecked")
  Tap<JobConf, ?, ?> hadoopTap = (Tap<JobConf, ?, ?>) source;
  JobConf conf = new JobConf();
  FlowProcess<JobConf> flowProcess = new HadoopFlowProcess(conf);
  hadoopTap.sourceConfInit(flowProcess, conf);
  return hadoopTap.openForRead(flowProcess);
}
 
Example #3
Source File: TapDataReader.java    From plunger with Apache License 2.0 5 votes vote down vote up
private TupleEntryIterator getLocalTupleEntryIterator() throws IOException {
  @SuppressWarnings("unchecked")
  Tap<Properties, ?, ?> localTap = (Tap<Properties, ?, ?>) source;
  Properties properties = new Properties();
  FlowProcess<Properties> flowProcess = new LocalFlowProcess(properties);
  localTap.sourceConfInit(flowProcess, properties);
  return localTap.openForRead(flowProcess);
}
 
Example #4
Source File: TupleListTapTest.java    From plunger with Apache License 2.0 5 votes vote down vote up
@Test
public void openForRead() throws IOException {
  TupleEntryIterator iterator = tap.openForRead(null, null);
  assertThat(iterator.hasNext(), is(true));
  assertThat(iterator.next(), is(new TupleEntry(FIELDS, TUPLE_1)));
  assertThat(iterator.hasNext(), is(true));
  assertThat(iterator.next(), is(new TupleEntry(FIELDS, TUPLE_2)));
  assertThat(iterator.hasNext(), is(false));
}
 
Example #5
Source File: FlinkFlowProcess.java    From cascading-flink with Apache License 2.0 4 votes vote down vote up
@Override
public TupleEntryIterator openTapForRead(Tap tap) throws IOException {
	return tap.openForRead( this );
}
 
Example #6
Source File: TupleListTap.java    From plunger with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 * <p/>
 * Returned type is a {@link ListTupleEntryIterator}.
 */
@Override
public TupleEntryIterator openForRead(FlowProcess<? extends Properties> flowProcess, Iterator<Tuple> input)
  throws IOException {
  return new ListTupleEntryIterator(getSourceFields(), this.input);
}
 
Example #7
Source File: Bucket.java    From plunger with Apache License 2.0 4 votes vote down vote up
/**
 * Always throws {@link UnsupportedOperationException} - this is a sink not a tap.
 *
 * @throws UnsupportedOperationException always.
 */
@Override
public TupleEntryIterator openForRead(FlowProcess<? extends Properties> flowProcess, Iterator<Tuple> input)
    throws IOException {
  throw new UnsupportedOperationException("cannot read from a " + getClass().getSimpleName());
}
 
Example #8
Source File: UnsupportedTap.java    From plunger with Apache License 2.0 4 votes vote down vote up
@Override
public TupleEntryIterator openForRead(FlowProcess<? extends String> flowProcess, Long input) throws IOException {
  return null;
}
 
Example #9
Source File: JDBCTap.java    From SpyGlass with Apache License 2.0 4 votes vote down vote up
@Override
public TupleEntryIterator openForRead( FlowProcess<JobConf> flowProcess, RecordReader input ) throws IOException {
    // input may be null when this method is called on the client side or cluster side when accumulating
    // for a HashJoin
    return new HadoopTupleEntrySchemeIterator( flowProcess, this, input );
}
 
Example #10
Source File: HBaseTap.java    From SpyGlass with Apache License 2.0 4 votes vote down vote up
@Override
public TupleEntryIterator openForRead(FlowProcess<JobConf> jobConfFlowProcess, RecordReader recordReader) throws IOException {
  return new HadoopTupleEntrySchemeIterator(jobConfFlowProcess, this, recordReader);
}
 
Example #11
Source File: HBaseRawTap.java    From SpyGlass with Apache License 2.0 4 votes vote down vote up
@Override
public TupleEntryIterator openForRead(FlowProcess<JobConf> jobConfFlowProcess, RecordReader recordReader)
		throws IOException {
	return new HadoopTupleEntrySchemeIterator(jobConfFlowProcess, this, recordReader);
}