--- title: "Phase 3 - Mapping (OutOfMemoryError)" slug: "intro-tips-tricks-out-of-memory-phase3" updated: 2025-11-18T09:53:27Z published: 2025-12-04T02:44:08Z canonical: "docs.lobstersoftware.com/intro-tips-tricks-out-of-memory-phase3" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # Phase 3 - Mapping (OutOfMemoryError) ## No more than necessary Not all of the data that goes into a profile is always relevant. You can save a good deal of memory and speed by limiting your structures to what is essential. Sometimes it is even possible to ignore the input data completely. ## Routing the file based on partial data Let’s take the following case. You receive various EDIFACT documents, and all you want to do is to transfer them somewhere 'as received', e.g. to store them in directories. However, the files need to end up in different directories depending on the sender. The sender can normally be determined from the channels through which the data arrives. But what if the files are simply sitting in the same directory that you regularly scan, and the filenames do not allow you to identify where they originally came from? The sender, i.e. the creator of the data, is contained in the *UNB* segment. ```plaintext UNB+UNOB:2+Sender+Recipient+.... ``` In the example, you are always the recipient, but files can come from *Partner1* and *Partner2*. ```plaintext UNB+UNOB:2+Partner1+You+... ``` ```plaintext UNB+UNOB:2+Partner2+You+... ``` You could, of course, set up a 1:1 mapping with the corresponding EDIFACT templates and check the appropriate field there. This is not difficult with EDIFACT files because large amounts of data are unlikely. Nonetheless, there is also a more efficient (and therefore faster) way to do it. So let’s create a profile that will handle the data like a CSV file. Specifically, we use the delimiter ', which is normally a segment separator in EDIFACT files. ![images/download/attachments/189463966/379-version-1-modificationdate-1738746779849-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/379-version-1-modificationdate-1738746779849-api-v2.png) Supposing the file starts like this. ```plaintext UNA:+.? 'UNB+UNOA:2+Partner1+You+040820:0006+3689'UNH+.... ``` Then the first line is the *UNA* segment, the second is the *UNB* segment, etc. If the data in the EDIFACT file is all on one line or formatted in 80 character blocks, everything is fine. It always splits at ', and the sender and recipient should still be in the first 80 characters, so a line break would not mess things up either way. However, if the file has each segment nicely in a separate line, we need to do a little groundwork for our routing profile. The line breaks need to be removed. To do this, use the [EncodingPatcher](/docs/en/encoding-patcher) as preparser class, and ensure that the configuration file has the following content. ```plaintext 0x0A= 0x0D= ``` This tells the preparser that the two characters representing line breaks in Windows (*0x0D0A*) and Linux/Unix (*0x0A*) should be replaced with nothing, i.e. deleted, and the file becomes a one-liner. The structure should then look as follows, with the node only reading the *UNB* segment. ![images/download/attachments/189463966/306-version-1-modificationdate-1738746779861-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/306-version-1-modificationdate-1738746779861-api-v2.png) ![images/download/attachments/189463966/308-version-1-modificationdate-1738746779854-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/308-version-1-modificationdate-1738746779854-api-v2.png) The [Delimiter column/row](/docs/en/phase-3-source-structure-attributes) for node *OnlyUNB* should be left blank so that the entire segment is written in field *Content*. Use *Starts with* and *UNB* as matchcode. This mapping produces the following. ![images/download/attachments/189463966/307-version-1-modificationdate-1738746779860-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/307-version-1-modificationdate-1738746779860-api-v2.png) Now you can use functions to check whether the *UNB* segment in the target field contains the character strings *Partner1* or *Partner2* and use variables to use the appropriate Response. Similar methods work for other formats. With XML, you should limit the source structure to the essentials but still use the XML parser. Taking the following data as an example. ```xml 123 Meier ... 987 ...