Class TupleCopier

java.lang.Object
com.streambase.sb.TupleCopier

public class TupleCopier extends Object
A utility class which copies the fields from one tuple to another. TupleCopier uses the given schemas to determine which fields to copy from one Tuple to another. The strict flag on the ctor determines if an Exception is thrown if the fields in the destination schema do not match the fields in the source schema. Fields are matched by name and type. With the strict flag set to false the TupleCopier will only copy the fields between the source and destination that match field name and type. TupleCopier is more efficient than using Tuple's getField(), setField() methods to copy portions of a tuple. TupleCopier's constructor sets up the TupleCopier so that repeated calls to copyTuple() are more efficient. If a full copy is desired Tuple.clone() is probably a more efficient option. An example usage:


     ...
     TupleCopier input2OutputCopier = new TupleCopier(inputSchema, outputSchema, true);
     
     while (true) {
        outputTuple.clear();
        input2OutputCopier.copyTuple(getInputTuple(), outputTuple);
        sendOutput(port, outputTuple);
     }
     
 

Since:
6.4.5
See Also: