Connecting Components with Edges
Once you have inserted the components to the Graph Editor pane, you need to connect them with edges. Select the Edge tool on the Palette and click the output port of one component and connect it with the input port of the following component by clicking again. Do the same with all selected components.
The newly connected edges are still dotted.
(See Edges for more information about Edges.)
Now you need to prepare some input file. Move to the Project Explorer pane, which is on the left side of the screen. Right-click the data-in
folder of your project and select New > File.
Once the new window appears, select the name of your input file in this window. For example, input.txt
. Click Finish. The file will open in the window in the middle of the screen.
Type some data in this file, for example, you can type pairs of first name and last name like this: John|Brown
. Type more rows whose form should be similar. Do not forget to create also a new empty row at the end. The rows (records) will look like this:
You can copy in the following lines to avoid typing:
John|Brown
Peter|Gordon
Albert|Brown
John|Smith
Charles|Brown
Charlws|Gordon
Peter|Smith
Save the file by pressing Ctrl+S.
After that, double-click the first edge on the left and select Create metadata from the menu that appears beside the edge. In the Metadata editor, click the green Plus sign button. Another (second) field appears. You can click any of the two fields and rename them. By clicking any of them, it turns blue, you can rename it and press Enter. (See Metadata for more information about creating Metadata.)
After doing that, the names of the two fields will be Firstname and Lastname, respectively.
After clicking Finish, metadata is created and assigned to the edge. The edge now appears as a solid line.
The metadata on the second edge have been auto-propagated from the first edge.
Now, double-click FlatFileReader, click the File URL attribute row and click the button that appears in this File URL attribute row.
For information about FlatFileReader, see FlatFileReader.
After that, the URL File Dialog will open. Double-click the data-in
folder and double-click the input.txt
file inside this folder. The file name will appear in the pane on the right.
Then click OK. The File URL attribute row will look like this:
Click OK to close the FlatFileReader editor.
Then, double click FlatFileWriter. For more information, see FlatFileWriter.
Click the File URL attribute row and click the button that appears in the row. In the URL File Dialog, double-click the data-out
folder. Then click OK. The File URL attribute row will look like this:
Click twice on the File URL attribute row and type ${DATAOUT_DIR}/output.txt
there. The result will be as follows:
Click OK to close the FlatFileWriter editor.
Now you only need to set up the ExtSort component. For more information, see ExtSort.
Double-click the component and its Sort key attribute row. After that, move the two metadata fields from the left pane (Fields) to the right pane (Key parts). Move Lastname first, then move Firstname.
When you click OK, you will see the Sort key attribute row as follows:
Click OK to close the ExtSort editor and save the graph by pressing Ctrl+S.
Now right-click in any place of the Graph Editor (outside any component or edge) and select Run Data Shaper Graph.
Ways how graphs can be run are described in Execution.
Once a graph runs successfully, green circles are displayed on the components and numbers of parsed records can be seen below the edges:
When you expand the data-out
folder in the Project Explorer pane and open the output file, you can see the following contents of the file:
You can see that all persons have been sorted alphabetically. Last names first, first names last. This way, you have built and run your first graph.
Updated 8 months ago