ComposantsComponents › TechniqueTechnical
Range les lignes d'un flux dans une liste Java (java.util.List), placée dans globalMap sous le nom donné dans Destination. Le code Java de la suite du job (tJava, tJavaRow, routine) peut ensuite la parcourir. Aucun composant n'est prévu pour la relire dans un flux : le tArrayIn, malgré son nom, n'y arrive pas.
Stores the rows of a flow in a Java list (java.util.List), put in globalMap under the name given in Destination. The Java code of the rest of the job (tJava, tJavaRow, routine) can then go through it. No component is meant to read it back into a flow: the tArrayIn, despite its name, cannot.
EntréeInput
Main un flux, obligatoireone flow, required
SortieOutput
Main un flux, facultatif : les lignes repartent telles quellesone flow, optional: the rows go on unchanged
Déclencheurs en sortieOutput triggers
On Component Ok On Component Error Run if
Le tArray garde les lignes ; un tJava du sous-job suivant récupère la liste dans globalMap et la traite en Java.
The tArray keeps the rows; a tJava of the next subjob gets the list from globalMap and processes it in Java.
row1) : les lignes de la liste sont des objets de la classe row1Struct.
Connect the flow to keep to it. Note the link name (row1): the rows of the list are objects of the row1Struct class.
(java.util.List<row1Struct>) globalMap.get("array_tArray_1"), puis chaque colonne par son nom (row.name).
In a tJava connected with On Subjob Ok, read the list: (java.util.List<row1Struct>) globalMap.get("array_tArray_1"), then each column by its name (row.name).
Le tArray est masqué par défaut : il n'est pas dans la palette tant qu'il n'est pas affiché dans les paramètres du projet. Le réglage est enregistré dans le projet : il vaut pour tous ses jobs et pour tous ceux qui ouvrent le projet. The tArray is hidden by default: it is not in the palette until it is shown in the project settings. The setting is saved in the project: it applies to all its jobs and to everyone who opens the project.
Les libellés Hide, Show, PaletteFilter et Apply and Close sont en anglais, même dans le Studio en français. Un composant déjà utilisé dans un job du projet ne peut pas être masqué de nouveau : le Studio le laisse visible et le signale. The Hide, Show, PaletteFilter and Apply and Close labels are in English, even in the French Studio. A component already used in a job of the project cannot be hidden again: the Studio leaves it visible and says so.
Le nom technique, en gris, est celui du paramètre dans le fichier du job. The technical name, in grey, is the parameter name in the job file.
| ParamètreSetting | DéfautDefault | OngletTab | Description |
|---|---|---|---|
| SchémaSchemaSCHEMA | — | Paramètres simplesBasic settings | Les colonnes copiées dans chaque élément de la liste. Elles viennent du lien entrant. The columns copied into each element of the list. They come from the incoming link. |
| DestinationDESTINATION | array_tArray_1 |
Paramètres simplesBasic settings |
Le nom de la liste dans globalMap. Ce n'est pas une expression Java : écrivez le nom sans guillemets. Il sert aussi de nom de variable dans le code généré : lettres, chiffres et _ seulement, sans chiffre en tête (voir l'erreur).
The name of the list in globalMap. It is not a Java expression: write the name without quotes. It is also used as a variable name in the generated code: letters, digits and _ only, not starting with a digit (see the error).
|
Un tFixedFlowInput envoie trois lignes au tArray par le lien row1. Les sorties sont celles de la console, copiées depuis une exécution du job.
A tFixedFlowInput sends three rows to the tArray through the row1 link. The outputs are the console ones, copied from a run of the job.
| idInteger | nameString | cityString |
|---|---|---|
| 1 | Ada | London |
| 2 | Grace | New York |
| 3 | Alan | Manchester |
Destination par défaut. Code du tJava_1 : Default Destination. tJava_1 code:
java.util.List<row1Struct> rows = (java.util.List<row1Struct>) globalMap.get("array_tArray_1");
System.out.println("Rows in the list: " + rows.size());
for (row1Struct row : rows) {
System.out.println(row.id + " " + row.name + " (" + row.city + ")");
}
System.out.println("tArray_1_NB_LINE: " + globalMap.get("tArray_1_NB_LINE"));
Rows in the list: 3 1 Ada (London) 2 Grace (New York) 3 Alan (Manchester) tArray_1_NB_LINE: null
La variable NB_LINE n'est pas remplie : comptez les lignes avec rows.size().
The NB_LINE variable is not filled: count the rows with rows.size().
Le tArray range les lignes et les passe aussi, inchangées, au composant suivant (tLogRow en mode Simple). The tArray stores the rows and also passes them, unchanged, to the next component (tLogRow in Basic mode).
1|Ada|London 2|Grace|New York 3|Alan|Manchester
tLoop de 1 à 2 ; à chaque itération, deux lignes : pass (Integer) vaut ((Integer) globalMap.get("tLoop_1_CURRENT_VALUE")), name vaut "Ada" puis "Grace". Destination : myArray. Code du tJava_1 :
tLoop from 1 to 2; at each iteration, two rows: pass (Integer) is ((Integer) globalMap.get("tLoop_1_CURRENT_VALUE")), name is "Ada" then "Grace". Destination: myArray. tJava_1 code:
java.util.List<row1Struct> rows = (java.util.List<row1Struct>) globalMap.get("myArray");
for (row1Struct row : rows) {
System.out.println(row.pass + " " + row.name);
}
2 Ada 2 Grace
Chaque itération repart d'une liste vide : seules les lignes de la dernière restent. Each iteration starts again from an empty list: only the rows of the last one remain.
Le nom du job est remplacé par MyJob ; les traces et messages de compilation sont abrégés.
The job name is replaced with MyJob; the traces and compilation messages are shortened.
Destination : "myArray", comme une chaîne Java. Le job ne compile pas :
Destination: "myArray", like a Java string. The job does not compile:
error: not a statement
java.util.List<row1Struct> "myArray" = new java.util.ArrayList<row1Struct>();
^
error: ';' expected
java.util.List<row1Struct> "myArray" = new java.util.ArrayList<row1Struct>();
^
Écrivez myArray, sans guillemets ; le tJava lit alors globalMap.get("myArray").
Write myArray, without quotes; the tJava then reads globalMap.get("myArray").
Même nom de liste des deux côtés (array_tArray_1, la valeur par défaut), même schéma. Le job compile, mais s'arrête à la lecture :
Same list name on both sides (array_tArray_1, the default value), same schema. The job compiles, but stops when reading:
Exception in component tArrayIn_1 (MyJob) java.lang.ClassCastException: class demo.myjob_0_1.MyJob$row1Struct cannot be cast to class demo.myjob_0_1.MyJob$OnSubjobOkStructarray_tArray_1 (…) at demo.myjob_0_1.MyJob.tArrayIn_1Process(MyJob.java:2198) …
Le tArrayIn attend des objets d'une autre classe que ceux du tArray. Pour relire des lignes dans un flux, prenez tHashOutput et tHashInput. Détails sur la page du tArrayIn. The tArrayIn expects objects of another class than those of the tArray. To read rows back into a flow, take tHashOutput and tHashInput. Details on the tArrayIn page.
La liste elle-même, sous le nom de Destination. Elle est complète une fois toutes les lignes passées : lisez-la dans un sous-job suivant. Ses éléments sont de la classe du lien entrant (row1Struct pour row1), avec un champ public par colonne du schéma.
The list itself, under the Destination name. It is complete once all the rows have gone through: read it in a following subjob. Its elements are of the class of the incoming link (row1Struct for row1), with one public field per schema column.
((java.util.List<row1Struct>) globalMap.get("array_tArray_1"))
NB_LINE est proposée dans la liste des variables du composant, mais le tArray ne la remplit pas : globalMap.get("tArray_1_NB_LINE") vaut null (voir l'exemple).
NB_LINE is offered in the variable list of the component, but the tArray does not fill it: globalMap.get("tArray_1_NB_LINE") is null (see the example).
La classe des éléments vient du nom du lien entrant. Renommer le lien row1 en customers change la classe en customersStruct : le code qui lit la liste doit suivre.
The class of the elements comes from the name of the incoming link. Renaming the row1 link to customers changes the class to customersStruct: the code that reads the list must follow.
Le tArray crée une liste vide et la range dans globalMap à chaque démarrage : dans une boucle, elle ne contient que les lignes de la dernière itération (exemple). Pour tout garder, prenez un tHashOutput, qui écrit à la suite.
The tArray creates an empty list and puts it in globalMap at each start: in a loop, it only holds the rows of the last iteration (example). To keep everything, take a tHashOutput, which appends.
Chaque ligne est copiée dans la liste, qui reste dans globalMap jusqu'à la fin du job. Sur un gros volume, retirez-la quand elle ne sert plus : globalMap.remove("array_tArray_1").
Each row is copied into the list, which stays in globalMap until the end of the job. On a large volume, remove it when it is no longer needed: globalMap.remove("array_tArray_1").
Le tArray sert au code Java. Pour renvoyer les lignes dans un flux plus loin dans le job, prenez tHashOutput et tHashInput. The tArray is for Java code. To send the rows back into a flow further in the job, take tHashOutput and tHashInput.
tArrayIn · partie interne de tIterateToFlow et tDenormalizeinternal part of tIterateToFlow and tDenormalizetHashOutput · garde les lignes d'un flux en mémoirekeeps the rows of a flow in memorytHashInput · relit le cache d'un tHashOutputreads the cache of a tHashOutputtJava · code exécuté une foiscode run oncetSetGlobalVar · définit une liste de variables globalessets a list of global variables