...
A sequence defines and caches a list of unique values that PhixFlow can then assign to items.
The curValue and nextValue functions are used to get the current and next values in the cached sequence.
Use the block size to specify the range of values in the sequence. For example, set a block size of 100 to cache 100 consecutive values. PhixFlow checks the database to determine the next available number in the sequence and then sets the next sequence of numbers as "used" in the database. The numbers are stored in the cache. When PhixFlow needs the next number in the sequence, it uses a number from the cache.
When all the values have been used, PhixFlow generates the next set of values in the sequence and saves it to the cache.
Tip |
---|
It is much quicker for PhixFlow to |
...
assign a |
...
number from |
...
memory than it is to |
...
assign a number from the database. It also takes time to |
...
reserve the next |
...
If something clears the cache, such as Tomcat being restarted, any remaining numbers in the cache are lost. This can lead to item values having gaps in the sequence.
...
block of numbers. |
Gaps in the Number Sequence
Sequence numbers are unique, but there may be gaps between sequence numbers. This depends on:
- the block size specified when the sequence is set up
- unexpected server shut-down.
Server shut-down clears any remaining numbers from memory. When the server restarts, PhixFlow reserves a new block from the last reserved value. This can leave a gap between:
- the last number allocated before PhixFlow was shut down
- and the first number allocated after PhixFlow is restarted.
For example,
- You create a sequence with a block size of 100. It has the values 0-99.
- You have allocated the numbers 1 to 50 from memory.
- PhixFlow shuts down.
- On restart, PhixFlow reserves a new block from 100 to 199.
- PhixFlow starts issuing numbers from memory, starting with 100.
- The numbers from 51 to 99 will never be issued.
Block Size and Performance
Anchor | ||||
---|---|---|---|---|
|
Use the block size to specify the range of values in the sequence. The block size affects PhixFlow performance.
- A very small block size increases the number of times that PhixFlow has to go to the database to reserve another block. This slows down performance.
- A very large block size increases the risk that PhixFlow is shut down with unallocated numbers in memory.
Tip |
---|
We recommend you set a large block size, to optimise performance. If you require a continuous sequence of values for items:
|
Sequence Properties
To create a sequence, in the repository, right-click Sequences and click
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Basic Settings
Field | Description |
---|---|
Name |
...
Enter the name of the sequence. |
Start Value |
...
Enter the first value in the sequence. |
Block Size |
...
Enter a number to set the |
...
To configure the sequence to generate values without any gaps in the sequence, set the block size to 1. This causes slow performance as PhixFlow has to perform database calculations for before providing the next value in the sequence.
Tip |
---|
If you require a continuous sequence of values for items, and the data set being processed is small, you may decide to accept the added overhead of calculating every value in the sequence. If the data set is large, it is better to use a large block size, to optimise performance. If you require a continuous sequence consider an alternative method of assigning the value. |
...
size of the sequence of numbers. This will depend on the number of records in the stream set to which you are allocating unique numbers. For example, if the stream set has 10,000 records, the block size should be at least 10,000.
Block size has an effect on performance; see Block Size and Performance, above. | ||
Current Value | PhixFlow displays the highest value already allocated. |
Example: Using a Sequence
To set a stream attribute to a unique order ID:
- Create a
...
- sequence and set its Name to
order_id
...
- .
Create a
...
stream with an Integer attribute.
Set its attribute expression to:
...
nextValue('order_id')
Every time a new record is generated in this stream,
nextValue
will return a new unique value for the attribute.