ComposantsComponents

ComposantsComponents › DiversMisc

tBufferOutput

tBufferOutput

DiversMisc

Ajoute les lignes d'un flux au tampon du job : une liste en mémoire, propre à chaque exécution du job. Elle sert à renvoyer des lignes au job parent, qui les reçoit par la sortie de son tRunJob, ou à les relire plus loin dans le même job avec un tBufferInput. Un job n'a qu'un tampon : tous ses tBufferOutput y ajoutent leurs lignes, et rien ne le vide avant la fin du job. Adds the rows of a flow to the job buffer: an in-memory list that belongs to each run of the job. It is used to return rows to the parent job, which receives them through the output of its tRunJob, or to read them again later in the same job with a tBufferInput. A job has only one buffer: all its tBufferOutput components add their rows to it, and nothing empties it before the end of the job.

EntréeInput

Main un flux, obligatoireone flow, required

SortieOutput

Main facultatif : les lignes repartent telles quellesoptional: the rows go on unchanged

Déclencheurs en sortieOutput triggers

On Component Ok On Component Error Run if

UtilisationUsage

Renvoyer des lignes au job parentReturn rows to the parent job

ChildJob

row1 (Main) tFileInputDelimited_1 tBufferOutput_1

MyJob

row1 (Main) tRunJob_1 tMap_1

Le job enfant remplit son tampon. Quand il a fini, le tRunJob du job parent envoie chaque ligne du tampon dans son lien de sortie, convertie selon son propre schéma. The child job fills its buffer. When it has finished, the tRunJob of the parent job sends each row of the buffer into its output link, converted according to its own schema.

Relire dans le même jobRead again in the same job

row1 (Main) OnSubjobOk row2 (Main) tFileInputDelimited_1 tBufferOutput_1 tBufferInput_1 tMap_1

Le tBufferInput relit tout le tampon, dans un sous-job lancé après celui du tBufferOutput. The tBufferInput reads the whole buffer, in a subjob run after the one of the tBufferOutput.

  1. Déposez le tBufferOutput depuis la famille Divers de la palette, et reliez-lui le flux à garder (clic droit › Ligne › Main) : son schéma se remplit à partir du lien. Drop the tBufferOutput from the Misc family of the palette, and connect the flow to keep to it (right-click › Row › Main): its schema is filled from the link.
  2. Pour le job parent : sélectionnez le tRunJob qui lance ce job, cliquez sur Copier le schéma du Job enfant, à côté de son schéma, puis reliez sa sortie Main au composant suivant. Le tRunJob doit tourner dans la machine Java du parent : Utiliser un processus indépendant pour exécuter le sous-Job décoché. For the parent job: select the tRunJob that runs this job, click Copy Child Job Schema, next to its schema, then connect its Main output to the next component. The tRunJob must run in the Java machine of the parent: Use an independent process to run subjob unchecked.
  3. Pour le même job : déposez un tBufferInput au début d'un autre sous-job, donnez-lui les mêmes colonnes, dans le même ordre, et reliez le sous-job du tBufferOutput au sien par On Subjob Ok. For the same job: drop a tBufferInput at the start of another subjob, give it the same columns, in the same order, and connect the subjob of the tBufferOutput to its own with On Subjob Ok.

Paramètres simplesBasic settings

Le libellé est celui de l'onglet Composant ; le nom technique, en gris, est celui du paramètre dans le fichier du job. Le composant n'a pas d'autre paramètre, ni de paramètres avancés propres. The label is the one of the Component tab; the technical name, in grey, is the parameter name in the job file. The component has no other setting, and no advanced settings of its own.

ParamètreSetting DéfautDefault VisibleShown Description
SchémaSchemaSCHEMA — ToujoursAlways Les colonnes gardées, dans leur ordre. Elles viennent du lien entrant. Pour la suite, seul l'ordre compte : le tBufferInput ou le tRunJob qui relit les lignes prend les valeurs par position, pas par nom (voir l'exemple). The kept columns, in their order. They come from the incoming link. Afterwards, only the order matters: the tBufferInput or the tRunJob that reads the rows takes the values by position, not by name (see the example).

Valeurs gardées et variables globalesKept values and global variables

Tout devient du texteEverything becomes text

Chaque ligne est rangée comme un tableau de textes (String[]), une case par colonne du schéma, dans l'ordre. Celui qui relit le tampon reconvertit chaque case dans le type de sa propre colonne (voir l'exemple). Each row is stored as an array of texts (String[]), one cell per schema column, in order. Whoever reads the buffer converts each cell back to the type of its own column (see the example).

  • Nombres et booléens : leur écriture Java, comme 1234.5 ou true. Un BigDecimal est d'abord arrondi à la précision de la colonne, si elle est renseignée : avec 2, 3.14159 est gardé 3.14.Numbers and booleans: their Java writing, such as 1234.5 or true. A BigDecimal is first rounded to the precision of the column, if it is set: with 2, 3.14159 is kept as 3.14.
  • Dates : écrites avec le modèle de date de la colonne ("dd-MM-yyyy" donne 11-11-2026).Dates: written with the date pattern of the column ("dd-MM-yyyy" gives 11-11-2026).
  • byte[] : décodé en texte avec l'encodage par défaut de la machine Java (voir l'Encodage du tBufferInput).byte[]: decoded into text with the default encoding of the Java machine (see the Encoding of the tBufferInput).
  • null reste null.null stays null.

Variables globalesGlobal variables

Aucune : le composant ne fournit pas de NB_LINE. Le nombre de lignes relues est le NB_LINE du tBufferInput. None: the component gives no NB_LINE. The number of rows read is the NB_LINE of the tBufferInput.

Le tampon lui-même est un champ du job, globalBuffer, une List<String[]> qu'un tJava peut lire : The buffer itself is a field of the job, globalBuffer, a List<String[]> that a tJava can read:

System.out.println(globalBuffer.size());

ExemplesExamples

Les sorties sont celles de la console, copiées depuis une exécution du job. Les tLogRow sont en mode Simple ; certains affichent leur nom unique. Le job parent s'appelle ici MyJob, le job enfant ChildJob. The outputs are the console ones, copied from a run of the job. The tLogRow components are in Basic mode; some print their unique name. The parent job is called MyJob here, the child job ChildJob.

Renvoyer des lignes au job parentReturn rows to the parent job

ChildJob

row1 (Main) tFixedFlowInput_1 tBufferOutput_1

MyJob

row1 (Main) OnSubjobOk row2 (Main) OnSubjobOk tRunJob_1 tLogRow_1 tBufferInput_1 tLogRow_2 tJava_1
idInteger nameString
1Ada
2Grace

Le job enfant met ces deux lignes dans son tampon. Dans le parent, le tRunJob_1 a le même schéma que le tBufferOutput_1, et le tBufferInput_1 aussi. Code du tJava_1 : The child job puts these two rows in its buffer. In the parent, tRunJob_1 has the same schema as tBufferOutput_1, and so does tBufferInput_1. tJava_1 code:

System.out.println("tBufferInput_1_NB_LINE: " + globalMap.get("tBufferInput_1_NB_LINE"));
[tLogRow_1] 1|Ada
[tLogRow_1] 2|Grace
tBufferInput_1_NB_LINE: 0

Les lignes du job enfant arrivent par la sortie du tRunJob_1. Elles ne vont pas dans le tampon du parent : son tBufferInput_1 ne lit rien. À l'inverse, un tBufferInput du job enfant ne voit pas le tampon du parent (exemple). The rows of the child job arrive through the output of tRunJob_1. They do not go into the buffer of the parent: its tBufferInput_1 reads nothing. Conversely, a tBufferInput of the child job does not see the buffer of the parent (example).

Un lancement par itérationOne run per iteration

Iterate row1 (Main) tLoop_1 tRunJob_1 tLogRow_1

tLoop de 1 à 2 ; le tRunJob_1 lance le même ChildJob. tLoop from 1 to 2; tRunJob_1 runs the same ChildJob.

1|Ada
2|Grace
1|Ada
2|Grace

Chaque lancement repart d'un tampon vide : le parent reçoit les deux lignes de chaque lancement, sans celles des lancements précédents. Each run starts with an empty buffer: the parent receives the two rows of each run, without those of the previous runs.

Avec un lien de sortieWith an output link

row1 (Main) row2 (Main) OnSubjobOk row3 (Main) tFixedFlowInput_1 tBufferOutput_1 tLogRow_1 tBufferInput_1 tLogRow_2

Les deux lignes du premier exemple, dans un seul job. The two rows of the first example, in a single job.

[tLogRow_1] 1|Ada
[tLogRow_1] 2|Grace
[tLogRow_2] 1|Ada
[tLogRow_2] 2|Grace

Le tBufferOutput garde les lignes et les passe aussi, inchangées, au composant suivant. The tBufferOutput keeps the rows and also passes them, unchanged, to the next component.

Deux tBufferOutput dans un jobTwo tBufferOutput in a job

row1 (Main) OnSubjobOk row2 (Main) OnSubjobOk row3 (Main) tFixedFlowInput_1 tBufferOutput_1 tFixedFlowInput_2 tBufferOutput_2 tBufferInput_1 tLogRow_1

tFixedFlowInput_1 : colonnes id (Integer), name (1 Ada, 2 Grace). tFixedFlowInput_2 : colonnes code (Integer), label, city (10 Alan Manchester, 11 Margaret Boston). tBufferInput_1 : colonnes id (Integer), name, city. tFixedFlowInput_1: columns id (Integer), name (1 Ada, 2 Grace). tFixedFlowInput_2: columns code (Integer), label, city (10 Alan Manchester, 11 Margaret Boston). tBufferInput_1: columns id (Integer), name, city.

1|Ada|
2|Grace|
10|Alan|Manchester
11|Margaret|Boston

Un seul tampon : les lignes s'y suivent dans l'ordre d'exécution, chacune avec son nombre de valeurs. code et label sont lus par position dans id et name ; les lignes du tBufferOutput_1 n'ont que deux valeurs, city y reste vide (null). A single buffer: the rows follow one another in run order, each with its number of values. code and label are read by position into id and name; the rows of tBufferOutput_1 only have two values, city stays empty there (null).

Les valeurs passent par du texteValues go through text

row1 (Main) OnSubjobOk row2 (Main) OnSubjobOk row3 (Main) OnSubjobOk tFixedFlowInput_1 tBufferOutput_1 tBufferInput_1 tLogRow_1 tBufferInput_2 tLogRow_2 tJava_1

Colonnes id (Integer), price (Double), day (Date, modèle "dd-MM-yyyy"), active (Boolean). Deux lignes : 1, 1234.5, TalendDate.parseDate("yyyy-MM-dd", "2026-11-11"), true ; puis 2, null, null, false. Le tBufferInput_1 a les mêmes colonnes, toutes en String ; le tBufferInput_2 a le schéma du tBufferOutput_1. Code du tJava_1 : Columns id (Integer), price (Double), day (Date, pattern "dd-MM-yyyy"), active (Boolean). Two rows: 1, 1234.5, TalendDate.parseDate("yyyy-MM-dd", "2026-11-11"), true; then 2, null, null, false. tBufferInput_1 has the same columns, all String; tBufferInput_2 has the schema of tBufferOutput_1. tJava_1 code:

String[] first = globalBuffer.get(0);
System.out.println("Values: " + first.length + " " + first[0].getClass().getSimpleName());
[tLogRow_1] 1|1234.5|11-11-2026|true
[tLogRow_1] 2|||false
[tLogRow_2] 1|1234.5|11-11-2026|true
[tLogRow_2] 2|||false
Values: 4 String

Le tBufferInput_1 montre le texte rangé : la date est écrite avec le modèle de la colonne, les null restent null. Le tBufferInput_2 reconvertit ce texte dans les types de son schéma. tBufferInput_1 shows the stored text: the date is written with the pattern of the column, the null values stay null. tBufferInput_2 converts this text back to the types of its schema.

Erreurs et pièges avec un tRunJobErrors and pitfalls with a tRunJob

Le job parent du premier exemple, réduit au tRunJob_1 relié au tLogRow_1 (sans nom unique). Les noms des jobs sont remplacés par MyJob et ChildJob, les traces sont abrégées. The parent job of the first example, reduced to tRunJob_1 connected to tLogRow_1 (without unique name). The job names are replaced with MyJob and ChildJob, the traces are shortened.

Schéma du tRunJob dans un autre ordretRunJob schema in another order

Le tRunJob_1 a les colonnes name (String), puis id (Integer). tRunJob_1 has the columns name (String), then id (Integer).

Exception in component tRunJob_1 (MyJob)
java.lang.NumberFormatException: For input string: "Ada"
	at …

Les valeurs sont prises par position : la 2e, Ada, arrive dans id, un Integer. Le parent s'arrête avec le code 1. The values are taken by position: the 2nd one, Ada, goes into id, an Integer. The parent stops with code 1.

Job enfant sans tBufferOutputChild job without tBufferOutput

Le job enfant n'a qu'un tJava : System.out.println("Child job: no tBufferOutput");. Le tRunJob_1 garde ses colonnes id, name. The child job only has a tJava: System.out.println("Child job: no tBufferOutput");. tRunJob_1 keeps its columns id, name.

Child job: no tBufferOutput
0|

Le tRunJob envoie quand même une ligne : le code de retour du job enfant (0) dans la 1re colonne, rien dans les autres. The tRunJob still sends one row: the exit code of the child job (0) in the 1st column, nothing in the others.

Processus indépendantIndependent process

Utiliser un processus indépendant pour exécuter le sous-Job coché sur le tRunJob_1. Use an independent process to run subjob checked on tRunJob_1.

when tRunJob runs in an independent process, it can't extract datas from tBufferOutput of child job.
|

Le tRunJob écrit ce message sur la sortie d'erreur, puis envoie une seule ligne, vide : les lignes du tampon ne reviennent pas. Le job se termine avec le code 0. The tRunJob writes this message on the error output, then sends a single row, empty: the rows of the buffer do not come back. The job ends with code 0.

Conseils et limitesTips and limits

Lancé seul, le job ne montre rienRun alone, the job shows nothing

Exécuté seul, et non par un tRunJob, le job enfant garde ses lignes dans le tampon puis s'arrête : elles sont perdues, la console reste vide. Pour le tester seul, ajoutez un tLogRow après le tBufferOutput : les lignes le traversent (exemple). Run alone, and not by a tRunJob, the child job keeps its rows in the buffer and then stops: they are lost, the console stays empty. To test it alone, add a tLogRow after the tBufferOutput: the rows go through it (example).

Le même schéma des deux côtésThe same schema on both sides

Copier le schéma du Job enfant, sur le tRunJob, reprend le schéma d'un seul tBufferOutput du job enfant, le premier trouvé. Avec plusieurs tBufferOutput, gardez le même ordre de colonnes et les mêmes types dans tous. Copy Child Job Schema, on the tRunJob, takes the schema of a single tBufferOutput of the child job, the first one found. With several tBufferOutput components, keep the same column order and the same types in all of them.

Un tampon par exécutionOne buffer per run

Le tampon appartient à une exécution du job : le parent et l'enfant ont chacun le leur, et chaque lancement par un tRunJob part d'un tampon vide. Pendant l'exécution, rien ne le vide : relu, il reste plein, et un tBufferOutput dans une boucle y ajoute ses lignes à chaque itération. The buffer belongs to one run of the job: the parent and the child each have their own, and each run by a tRunJob starts with an empty buffer. During the run, nothing empties it: once read, it stays full, and a tBufferOutput in a loop adds its rows at each iteration.

Tout est en mémoireEverything is in memory

Toutes les lignes, sous forme de texte, occupent la mémoire de la JVM jusqu'à la fin du job. Pour un gros volume, prévoyez la mémoire (-Xmx) ou passez par un fichier. All the rows, as text, use the memory of the JVM until the end of the job. For a large volume, plan the memory (-Xmx) or go through a file.

Ce que renvoie le jobWhat the job returns

La classe Java du job renvoie le tampon, en String[][], par sa méthode runJob(String[] args) : c'est elle qu'appelle le tRunJob. Sans tBufferOutput dans le job, elle renvoie une seule ligne, le code de retour (voir les pièges). The Java class of the job returns the buffer, as String[][], through its runJob(String[] args) method: this is what the tRunJob calls. Without tBufferOutput in the job, it returns a single row, the exit code (see the pitfalls).

Plusieurs ensembles de lignesSeveral sets of rows

Pour garder dans un même job plusieurs ensembles de lignes séparés, avec leurs types, prenez tHashOutput et tHashInput : chaque tHashOutput a son propre cache. To keep several separate sets of rows in one job, with their types, use tHashOutput and tHashInput: each tHashOutput has its own cache.

Voir aussiSee also