Sequences

Sequence object generates series of numeric information. They are able to store their state after the graph execution has finished. To achieve this functionality, every sequence is bounds to a binary file stored in filesystem. CloverETL designer provides wizard/editor for definition of sequence attributes:

  • name - human-readable name of sequence object
  • start - the first value of numeric sequence
  • step - incrementing step
  • cache - number of values that will be precomputed and cached
  • file - location of a binary file, where sequence value are stored
  • current value - current value of sequence stored in the file of persistence

All attributes except current value are editable. When creating a new sequence, its current value is set to start value. When modifying an existing sequence, you may reset its value to start value.

CloverETL engine supports graph-local definition of sequence objects. However you may use the same file among multiple graphs to share sequence's value in them (other parameters of sequence may be modified). When a graph is using a sequence, the file will be locked, thus concurrent usage of simple sequence is not possible.

Xml definition:

  <Global>
    ...
    <Sequence id="Sequence0" type="SIMPLE_SEQUENCE" 
              fileURL="sequence.dat" name="seq" 
              start="1" step="1" cached="5"
    />
  </Global>
 
  <Node id="REFORMAT0" type="REFORMAT">
    <attr name="transform">
      import org.jetel.component.DataRecordTransform;
      import org.jetel.data.DataRecord;
      import org.jetel.data.GetVal;
      import org.jetel.data.SetVal;
      import org.jetel.data.sequence.Sequence;
      import org.jetel.graph.TransformationGraph;
 
      public class reformatOrders extends DataRecordTransform {
	Sequence sequence;
 
	public boolean init(){
		sequence = this.graph.getSequence("Sequence0");
                return true;
	}
 
	public boolean transform(DataRecord source[], DataRecord[] target){
		try{
			// OrderKey gets its value from sequence
			SetVal.setInt(target[0],"PRODUCTID",sequence.nextValueInt());
		}catch(Exception ex){
			return false;
		}
		return true;
	 }
      }
    </attr>
  </Node>

Sequence definition dialog:

graph_elements/sequences.txt · Last modified: 2009/09/16 12:27 (external edit)
Back to top
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0