Description

The RandomAccessFixedFileReceiver is used to randomly access locations within a fixed file, to modify its data at any given site. To randomly access a specific location within a fixed file, the RandomAccessFixedFileReceiver has a few requirements, defined below. 


In This Article


Requirements

  • Fixed length Columns - The file must contain two or more fixed-length columns that are consistent across all rows within the fixed file.
  • Key Columns - One or more columns within the fixed file can be used to define a key that uniquely identifies a row within the fixed file.
  • Memory Allocation - Make sure the Java Virtual Machine (JVM) has enough memory allocated to it, so that all keys and their index may be mapped in memory. 


Special Notes

  • The Receiver will not modify the values of key columns.
  • The Receiver will throw a GenRocket Exception if a duplicate key column is found within the given fixed file document.
  • All rows within a fixed file document must have the exact same number of bytes.


How It Works  

Before GenRocket starts generating data, it calls the Receiver during an initialization event. During the initialization event, the Receiver executes the following setup steps:

  1. Opens the given fixed file.
  2. Builds a list of column objects defined by its property keys (see Property Keys below).
  3. Determines which columns define the key for each row.
  4. Determines the block size of each row by calculating the length of all columns.
  5. Traverses each row, one block at a time, seeks the data within each row to define its key, and stores the key and row's index into memory.


Receiver Parameters

The RandomAccessFixedFileReceiver requires that the following parameters are defined. Items with an asterisk (*) are required. 

  • path* - Defines the base directory path where the file to access is located.
  • subDir - Defines an optional subdirectory under the path base directory where the file to access is located.
  • fileName - Defines the name of the file to access.
  • delimiterSize* - If the fixed file being accessed has a delimiter between each fixed column, then the size of the delimiter must be defined. For instance, if the delimiting character happens to be a colon ':,' then the size would be 1. The default is 0.
  • endOfLineSize* - If the fixed file being accessed has an end of line character(s) between each fixed row, then the size of the end of line character(s) must be defined. For instance, if the end of line character happens to be a \n, then the size would be 1. If the end of line characters happens to be a \r\n, then the size would be 2. The default is 0.
  • ignoreValue - When there are instances where a value for a given fixed column should not be modified, then the ignoreValue's value should be used as the generated value. When the Receiver sees the ignoredValue, it will not perform an update to the given column for the given iteration.


Receiver Attribute PropertyKeys

  • length - Defines the fixed length of the given column.
  • key - If set to true, the column will be used to define a key to map each row and its row index into memory.
  • include - Determines if the given column within the fixed file may be updated.


Example Stories

The example stories below show different use cases where the RandomAccessFixedFileReceiver is used to modify fixed files with slightly different internal formats. Sometimes, the parameters or property key values determine the Receiver's behavior and how data within a given fixed file are updated. All of the example stories below share the same configuration for the length Attribute property key values and the productId Attribute's key property key value. 


Receivers Attributes Property Keys

The fixed lengths are set for each column, and the productId's key attribute property key value is set to true.


Story 1 -  Modify a Fixed File With Delimiters and End Of Line characters

The fixed file below contains a colon (:) delimiter between each column and a linefeed (\n) at the end of each row.  Thus, the value of the delimiterSize parameter and endOfLineSize parameter needs to be set to 1. 


Receivers Parameters


Before File Modification

This is the form of the fixed file before modifications.  


1000000000:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000001:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000002:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000003:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000004:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000005:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000006:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000007:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000008:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000009:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:


After File Modification

After GenRocket has generated the test data and RandomAccessFixedFileReceiver has updated the fixed file.


1000000000:Item1     :525   :0000041.30:0021682.50:
1000000001:Item2     :274   :0000087.05:0023851.70:
1000000002:Item3     :400   :0000077.10:0030840.00:
1000000003:Item4     :917   :0000092.75:0085051.75:
1000000004:Item5     :986   :0000034.80:0034312.80:
1000000005:Item6     :941   :0000049.65:0046720.65:
1000000006:Item7     :761   :0000100.60:0076556.60:
1000000007:Item8     :509   :0000050.55:0025729.95:
1000000008:Item9     :439   :0000091.65:0040234.35:
1000000009:Item10    :983   :0000034.40:0033815.20:


Story 2 -  Modify a Fixed File With Delimiters and No End of Line Characters

The fixed file below contains a colon (:) delimiter between each column and no end of line characters.  Thus, the value of the delimiterSize parameter needs to be set to the value of 1, and the endOfLineSize parameter needs to remain with its default value of 0.


Receivers Parameters


Before File Modification

This is the form of the fixed file before modifications.  


1000000000BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE
1000000001BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE
1000000002BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE
1000000003BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE
1000000004BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE
1000000005BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE
1000000006BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE
1000000007BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE
1000000008BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE
1000000009BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE


After File Modification

After GenRocket has generated the test data and RandomAccessFixedFileReceiver has updated the fixed file.


1000000000Item1     651   0000060.250039222.75
1000000001Item2     419   0000029.450012339.55
1000000002Item3     797   0000084.750067545.75
1000000003Item4     317   0000098.100031097.70
1000000004Item5     614   0000018.750011512.50
1000000005Item6     421   0000027.500011577.50
1000000006Item7     617   0000002.050001264.85
1000000007Item8     731   0000091.900067178.90
1000000008Item9     68    0000052.400003563.20
1000000009Item10    56    0000077.700004351.20


Story 3 -  Modify a Fixed File With No Delimiters and No End Of Line Characters

The fixed file below contains no delimiter between each column and no end of line characters. It's just a pure block of continuous block of data. Thus, the value of the delimiterSize parameter and endOfLineSize parameter both need to remain with their default values of 0. 


Receivers Parameters


Before File Modification

This is the form of the fixed file before modifications.


1000000000BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE1000000001BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE1000000002BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE1000000003BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE1000000004BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE1000000005BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE1000000006BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE1000000007BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE1000000008BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE1000000009BBBBBBBBBBCCCCCCDDDDDDDDDDEEEEEEEEEE


After File Modification

After GenRocket has generated the test data and RandomAccessFixedFileReceiver has updated the fixed file.


1000000000Item1     155   0000007.800001209.001000000001Item2     316   0000042.700013493.201000000002Item3     623   0000089.950056038.851000000003Item4     770   0000049.800038346.001000000004Item5     782   0000015.500012121.00100000<span class="fr-marker" data-id="0" data-type="false" style="display: none; line-height: 0;"></span><span class="fr-marker" data-id="0" data-type="true" style="display: none; line-height: 0;"></span>0005Item6     861   0000082.700071204.701000000006Item7     846   0000006.250005287.501000000007Item8     29    0000021.800000632.201000000008Item9     471   0000003.600001695.601000000009Item10    14    0000088.900001244.60


Story 4 -  Modify a Fixed File With Delimiters, an End Of Line Character, and Quantity is Excluded

The fixed file below contains a colon (:) delimiter between each column and a linefeed (\n) at the end of each row. Also, we do not want the quantity column to be updated. Thus, the quantity Attribute's include property key value, is set to false to exclude it from being updated.


Receivers Attributes Property Keys

The quantity Attribute's include property key value, is set to false.


Before File Modification

This is the form of the fixed file before modifications.


1000000000:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000001:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000002:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000003:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000004:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000005:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000006:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000007:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000008:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000009:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:


After File Modification

After GenRocket has generated the test data and RandomAccessFixedFileReceiver has updated the fixed file.


1000000000:Item1     :CCCCCC:0000048.80:0042651.20:
1000000001:Item2     :CCCCCC:0000092.50:0053187.50:
1000000002:Item3     :CCCCCC:0000038.50:0027450.50:
1000000003:Item4     :CCCCCC:0000003.40:0000323.00:
1000000004:Item5     :CCCCCC:0000018.10:0014027.50:
1000000005:Item6     :CCCCCC:0000027.00:0023004.00:
1000000006:Item7     :CCCCCC:0000023.45:0000773.85:
1000000007:Item8     :CCCCCC:0000088.35:0082518.90:
1000000008:Item9     :CCCCCC:0000076.60:0066029.20:
1000000009:Item10    :CCCCCC:0000087.25:0075820.25:


Story 5 -  Modify a Fixed File With Delimiters, an End Of Line Character and use ignoreValue as a Toggle

The fixed file below contains a colon (:) delimiter between each column and a linefeed (\n) at the end of each row.  Also, we want to update the value column only when the generated value is not equal to the value defined in the ignoreValue parameter, which is set to the value of IGNORE.


Receivers Parameters


Preview of the Value Column Having Toggled Data 


Modification to the value Attribute Generators

The value Attribute uses three Generators to generate the toggling effect:

  • CalcGen - computes the price * quantity
  • PadGen  - pads the value computed by the CalcGen
  • EvalCaseGen - uses the modulus functions to toggle between the  padded value and the constant, IGNORE.


CalcGen Generator


PadGen Generator


EvalCaseGen Generator


Before File Modification

This is the form of the fixed file before modifications.


1000000000:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000001:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000002:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000003:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000004:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000005:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000006:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000007:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000008:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:
1000000009:BBBBBBBBBB:CCCCCC:DDDDDDDDDD:EEEEEEEEEE:


After File Modification

After GenRocket has generated the test data and RandomAccessFixedFileReceiver has updated the fixed file.


1000000000:Item1     :838   :0000095.45:0079987.10:
1000000001:Item2     :938   :0000027.70:EEEEEEEEEE:
1000000002:Item3     :384   :0000022.60:0008678.40:
1000000003:Item4     :967   :0000033.50:EEEEEEEEEE:
1000000004:Item5     :268   :0000029.90:0008013.20:
1000000005:Item6     :376   :0000005.35:EEEEEEEEEE:
1000000006:Item7     :75    :0000004.60:0000345.00:
1000000007:Item8     :45    :0000084.95:EEEEEEEEEE:
1000000008:Item9     :409   :0000003.70:0001513.30:
1000000009:Item10    :411   :0000062.95:EEEEEEEEEE: