Java Code Examples for cascading.tuple.Tuple#add()

The following examples show how to use cascading.tuple.Tuple#add() . 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: HBaseRawScheme.java    From SpyGlass with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean source(FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall)
		throws IOException {
	Tuple result = new Tuple();

	Object key = sourceCall.getContext()[0];
	Object value = sourceCall.getContext()[1];
	boolean hasNext = sourceCall.getInput().next(key, value);
	if (!hasNext) {
		return false;
	}

	// Skip nulls
	if (key == null || value == null) {
		return true;
	}

	ImmutableBytesWritable keyWritable = (ImmutableBytesWritable) key;
	Result row = (Result) value;
	result.add(keyWritable);
	result.add(row);
	sourceCall.getIncomingEntry().setTuple(result);
	return true;
}
 
Example 2
Source File: TestParquetTBaseScheme.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
@Override
public void operate(FlowProcess flowProcess, FunctionCall functionCall) {
  TupleEntry arguments = functionCall.getArguments();
  Tuple result = new Tuple();

  Name name = new Name();
  name.setFirst_name(arguments.getString(0));
  name.setLast_name(arguments.getString(1));

  result.add(name);
  functionCall.getOutputCollector().add(result);
}
 
Example 3
Source File: TestParquetTBaseScheme.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
@Override
public void operate(FlowProcess flowProcess, FunctionCall functionCall) {
  TupleEntry arguments = functionCall.getArguments();
  Tuple result = new Tuple();

  Name name = (Name) arguments.get(0);
  result.add(name.getFirst_name());
  result.add(name.getLast_name());
  functionCall.getOutputCollector().add(result);
}
 
Example 4
Source File: ParquetScroogeSchemeTest.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
@Override
public void operate(FlowProcess flowProcess, FunctionCall functionCall) {
  Object record = functionCall.getArguments().getObject(0);
  Tuple result = new Tuple();
  result.add(record.toString());
  functionCall.getOutputCollector().add(result);
}
 
Example 5
Source File: ParquetScroogeSchemeTest.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
@Override
public void operate(FlowProcess flowProcess, FunctionCall functionCall) {
  TupleEntry arguments = functionCall.getArguments();
  Tuple result = new Tuple();

  Name name = Name$.MODULE$.apply(arguments.getString(0), Option.apply(arguments.getString(1)));

  result.add(name);
  functionCall.getOutputCollector().add(result);
}
 
Example 6
Source File: ParquetScroogeSchemeTest.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
@Override
public void operate(FlowProcess flowProcess, FunctionCall functionCall) {
  TupleEntry arguments = functionCall.getArguments();
  Tuple result = new Tuple();

  Name name = (Name) arguments.getObject(0);
  result.add(name.firstName());
  result.add(name.lastName().get());
  functionCall.getOutputCollector().add(result);
}
 
Example 7
Source File: TestParquetTBaseScheme.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
@Override
public void operate(FlowProcess flowProcess, FunctionCall functionCall) {
  TupleEntry arguments = functionCall.getArguments();
  Tuple result = new Tuple();

  Name name = new Name();
  name.setFirst_name(arguments.getString(0));
  name.setLast_name(arguments.getString(1));

  result.add(name);
  functionCall.getOutputCollector().add(result);
}
 
Example 8
Source File: TestParquetTBaseScheme.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
@Override
public void operate(FlowProcess flowProcess, FunctionCall functionCall) {
  TupleEntry arguments = functionCall.getArguments();
  Tuple result = new Tuple();

  Name name = (Name) arguments.getObject(0);
  result.add(name.getFirst_name());
  result.add(name.getLast_name());
  functionCall.getOutputCollector().add(result);
}
 
Example 9
Source File: TestParquetTupleScheme.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
@Override
public void operate(FlowProcess flowProcess, FunctionCall functionCall) {
  TupleEntry arguments = functionCall.getArguments();
  Tuple result = new Tuple();

  Tuple name = new Tuple();
  name.addString(arguments.getString(0));
  name.addString(arguments.getString(1));

  result.add(name);
  functionCall.getOutputCollector().add(result);
}
 
Example 10
Source File: TestParquetTupleScheme.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
@Override
    public void operate(FlowProcess flowProcess, FunctionCall functionCall) {
      TupleEntry arguments = functionCall.getArguments();
      Tuple result = new Tuple();

      Tuple name = new Tuple();
      name.addString(arguments.getString(0));
//      name.addString(arguments.getString(1));

      result.add(name);
      functionCall.getOutputCollector().add(result);
    }
 
Example 11
Source File: HBaseScheme.java    From SpyGlass with Apache License 2.0 5 votes vote down vote up
@Override
public boolean source(FlowProcess<JobConf> flowProcess,
    SourceCall<Object[], RecordReader> sourceCall) throws IOException {
  Tuple result = new Tuple();

  Object key = sourceCall.getContext()[0];
  Object value = sourceCall.getContext()[1];
  boolean hasNext = sourceCall.getInput().next(key, value);
  if (!hasNext) { return false; }

  // Skip nulls
  if (key == null || value == null) { return true; }

  ImmutableBytesWritable keyWritable = (ImmutableBytesWritable) key;
  Result row = (Result) value;
  result.add(keyWritable);

  for (int i = 0; i < this.familyNames.length; i++) {
    String familyName = this.familyNames[i];
    byte[] familyNameBytes = Bytes.toBytes(familyName);
    Fields fields = this.valueFields[i];
    for (int k = 0; k < fields.size(); k++) {
      String fieldName = (String) fields.get(k);
      byte[] fieldNameBytes = Bytes.toBytes(fieldName);
      byte[] cellValue = row.getValue(familyNameBytes, fieldNameBytes);
      result.add(cellValue != null ? new ImmutableBytesWritable(cellValue) : null);
    }
  }

  sourceCall.getIncomingEntry().setTuple(result);

  return true;
}
 
Example 12
Source File: TupleRecord.java    From SpyGlass with Apache License 2.0 4 votes vote down vote up
public void readFields( ResultSet resultSet ) throws SQLException {
    tuple = new Tuple();

    for( int i = 0; i < resultSet.getMetaData().getColumnCount(); i++ )
        tuple.add( (Comparable) resultSet.getObject( i + 1 ) );
}