U2 Dictionaries [Part 2]
In the last post I suggested that each piece of information in a file record needed an associated dictionary item.
Some may look at their files and realise it just cannot be done. In that case, “you’re doing it wrong”.
Common case: You have a file that logs transactions of some sort. For each transaction, it just appends it to the record, creating a new attribute.
There are several issues with this style of record structure.
Firstly. You cannot create dictionary items to reference any information (except of course, unless you create subroutine and call it from the dictionary). For example, if each transaction has a time-stamp, you cannot use UniQuery/RetrieVe to select all records with a certain time-stamp.
Secondly, any time you read in the record and need to count how many transactions are in the record, it needs to parse the entire record. Now, if you have each bit of information in a record stored in its own attribute (say time-stamp in , amount in , etc) it would only need to parse the first attribute, potentially cutting down on the CPU expense greatly.
So, if you must store some sort of transaction/log style data in a U2 record, please reconsider the traditional approach of appending the whole transaction to the end and take a more U2 perspective by splitting each bit of information into its own attribute. This way, it will be much easier to use U2′s inbuilt features when manipulating and reporting on your data.