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

The following examples show how to use cascading.tuple.Tuple#set() . 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: DefinedTupleSerializer.java    From cascading-flink with Apache License 2.0 6 votes vote down vote up
@Override
public Tuple copy(Tuple from) {
	Tuple target = Tuple.size(from.size());
	for (int i = 0; i < from.size(); i++) {
		try {
			Object orig = from.getObject(i);
			if (orig != null) {
				target.set(i, fieldSers[i].copy(orig));
			}
			else {
				target.set(i, null);
			}
		}
		catch(ClassCastException cce) {
			throw new FlowException("Unexpected type of field \""+fields.get(i)+"\" encountered. " +
									"Should have been "+fields.getType(i)+" but was "+from.getObject(i).getClass()+".", cce);
		}
	}
	return target;
}
 
Example 2
Source File: DefinedTupleSerializer.java    From cascading-flink with Apache License 2.0 6 votes vote down vote up
@Override
public Tuple deserialize(DataInputView source) throws IOException {

	// read null mask
	NullMaskSerDeUtils.readNullMask(this.nullFields, this.length, source);

	// read non-null fields
	Tuple tuple = Tuple.size(this.length);
	for (int i = 0; i < this.length; i++) {
		Object field;
		if(!this.nullFields[i]) {
			field = fieldSers[i].deserialize(source);
		}
		else {
			field = null;
		}
		tuple.set(i, field);
	}

	return tuple;
}
 
Example 3
Source File: DefinedTupleSerializer.java    From cascading-flink with Apache License 2.0 6 votes vote down vote up
@Override
public Tuple deserialize(Tuple reuse, DataInputView source) throws IOException {

	Tuple tuple = getReuseOrNew(reuse);

	// read null mask
	NullMaskSerDeUtils.readNullMask(nullFields, this.length, source);

	for (int i = 0; i < this.length; i++) {
		Object field;
		if(!this.nullFields[i]) {
			field = fieldSers[i].deserialize(source);
		}
		else {
			field = null;
		}
		tuple.set(i, field);
	}

	return tuple;
}
 
Example 4
Source File: UnknownTupleSerializer.java    From cascading-flink with Apache License 2.0 5 votes vote down vote up
@Override
public Tuple deserialize(DataInputView source) throws IOException {

	// read length
	int arity = source.readInt();

	// initialize or resize null fields if necessary
	if(this.nullFields == null || this.nullFields.length < arity) {
		this.nullFields = new boolean[arity];
	}

	// read null mask
	NullMaskSerDeUtils.readNullMask(this.nullFields, arity, source);

	// read non-null fields
	Tuple tuple = Tuple.size(arity);
	for (int i = 0; i < arity; i++) {
		Object field;
		if(!this.nullFields[i]) {
			field = fieldSer.deserialize(source);
		}
		else {
			field = null;
		}
		tuple.set(i, field);
	}

	return tuple;
}
 
Example 5
Source File: UnknownTupleSerializer.java    From cascading-flink with Apache License 2.0 5 votes vote down vote up
@Override
public Tuple deserialize(Tuple reuse, DataInputView source) throws IOException {

	// read length
	int arity = source.readInt();

	// initialize or resize null fields if necessary
	if(this.nullFields == null || this.nullFields.length < arity) {
		this.nullFields = new boolean[arity];
	}

	Tuple tuple = getReuseOrNew(reuse, arity);

	// read null mask
	NullMaskSerDeUtils.readNullMask(nullFields, arity, source);

	for (int i = 0; i < arity; i++) {
		Object field;
		if(!this.nullFields[i]) {
			field = fieldSer.deserialize(source);
		}
		else {
			field = null;
		}
		tuple.set(i, field);
	}

	return tuple;
}