将 Joblets 与 tMemorize 和 tJavaFlex 结合使用 [英] using Joblets in talend with tMemorize and tJavaFlex

查看:36
本文介绍了将 Joblets 与 tMemorize 和 tJavaFlex 结合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Talend 中创建一些 joblets,以加快某些进程.我有一个来自 MSSQLInput 的输入,然后对结果进行排序和过滤.然后我有一个 tMemorizeRows 和一个 tJavaFlex,这样做的目的是记住列中的行以进行计数.计数基于客户 ID,一旦 id 更改计数开始回到 1 并且过程再次开始并继续到结束.我已将其重构为 joblet 但它不起作用,错误是:

I am trying to create some joblets in Talend that will speed up some processes. I have an input from a MSSQLInput, the results are then sorted and filtered a little. Then I have a tMemorizeRows and a tJavaFlex, the purpose of this is to memorize the rows in a column to preform a count. The count is based on a customer ID, once the the id changes the count starts back to 1 and the proccess begine again and continues to the end. I have refactored this as a joblet but it does not work, the error is:

ID_tMemorizeRows_1 无法解析为变量

ID_tMemorizeRows_1 cannot be resolved to a variable

我有一个以

int counte = 1;

主要代码是

if(ID_tMemorizeRows_1[0].equals(ID_tMemorizeRows_1[1]))
{
counte = counte + 1; 
} 
else 
{ 
counte = 1; 
} 
context.Enqnum = counte;

Enqnum 变量已正确创建并添加到 tMaps 组件中.

The Enqnum variable and is created correctly and added into a tMaps component.

有谁知道为什么会发生这种情况,有人告诉我这是因为当你将一些东西移到工作岗位时,它会得到一个新的/不同的名字,所以必须在 Java 中专门调用它,如果是这种情况怎么办我找到名字了吗?

Does anyone know why this is happening, one person told me it is because when you move something to a joblet it gets a new/different name so it has to be specifically called in the Java, if this is the case how do I find the name out?

谢谢丰富

推荐答案

我有一个解决方案.我尝试添加图片,但我的声誉不够高.

I do have a resolution. I have tried to add images however my reputation is not high enough.

在使用 joblet 时,我们知道 Talend 通过将 joblet 中使用的代码插入到主要作业的代码中,从而回收利用了 joblet 中使用的代码.

When using joblets we know that Talend essentially recycles the code used in the joblet by inserting it into the code for the main job.

这是我创建的 joblet,我知道它有效,因为我已将其重构为 joblet,而不是从 sctatch 构建它.它所做的只是记住有序数据集中的第 0 行和第 1 行,java 执行计数,tMap 将结果附加到作业(如上所述).

This is the joblet I have created, i know it works because I have refactored it to a joblet instead of building it from sctatch. What its doing is simply memorises row 0 and row 1 in an ordered data set, the java performs a count and the tMap appends the result to the job (as Mentioned above).

(我将在我的问题中尝试插入图像,我没有足够的声望点将其插入问题中).

(I will try it inser image in my question, I do not have enough reputation point to insert it into a question).

当作业运行时,它运行良好.但是当我想在工作的另一部分重用同一个 joblet 时会出现问题.Talend 所做的是根据 joblet 的名称为每个组件分配源代码中的名称.例如,如果 Joblet 被称为 ThisJob,则 tMemorizeRows_1 将被称为 ThisJob_1_tMemorizeRows_1.组件中的行(在本例中为 ReferenceID)将重命名为:ReferenceID_ThisJob_1_tMemorizeRows_1.

When the job is run it runs fine. But problems occur when I want to reuse the same joblet in another part of the job. What Talend does is it assigns names within the source code to each component depending on the name of the joblet. For example, if the Joblet was called ThisJob, then tMemorizeRows_1 would be called ThisJob_1_tMemorizeRows_1. The row within the component (in this example ReferenceID) would renamed as: ReferenceID_ThisJob_1_tMemorizeRows_1.

但是当您将第二个作业添加到您的作业时,它会给它一个新名称,例如 ThisJob_2.该名称将根据您在添加第二个 joblet 之前更改作业的程度而有所不同.因此,名称中的数字将取决于此活动.

But when you add a second joblet to your job it gives it a new name, eg ThisJob_2. This name will be different depending on how much you have been altering your job before you add the second joblet. Therefore the number within the name will depend on this activity.

如果您立即将 joblet 添加到您的作业中,则该 joblet 将被称为 ThisJob_2,如果您在添加之前添加了 5 个其他组件,则该 joblet 可能会被称为 ThisJob_6 等(我不是 100% 确定 talend 如何重命名组件)

If you add the joblet into your job immediately then the joblet would be called ThisJob_2, if you have added 5 other components before you add it in then the joblet is likely to be called ThisJob_6 etc. (I'm not 100% sure how talend renames components)

当您添加作业时,您可以在作业组件上看到作业的名称,然后在您创建与其他组件的任何链接/连接时恢复原始作业名称.

When you add a joblet, You can see the name of the joblet on the joblet component, this then reverts back the the original joblet name when you create any links/joins to other components.

将代码中的每个组件分配给一个名为 currentComponent 的变量也很重要.

Its also important that each component within the code is assigned to a variable called currentComponent.

分辨率

我所做的是使用Java代码使用下面的代码拆分名称.这样我就可以获得joblet的当前名称并在我的Java中使用这个名称.

What I did was used the Java code to split the name using the code below. This way I can get the current name of the of the joblet and use this name in my Java.

String string = currentComponent;
String[] parts = string.split("_");
String part1 = parts[0];
String part2 = parts[1];
String joblet = part1+'_'+part2;
String newrow = "ReferenceID_"+joblet+"_tMemorizeRows_1";

我希望这是有道理的.谢谢

I hope this makes sense. Thanks

这篇关于将 Joblets 与 tMemorize 和 tJavaFlex 结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆