用 Kettle UDJC 组件实现用户行为组序列

Posted Lio5n

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用 Kettle UDJC 组件实现用户行为组序列相关的知识,希望对你有一定的参考价值。

用户登录APP,然后浏览了一些列页面。如果获取用户行为数据时没有对每次登陆分组,那么想知道用户每次登陆的行为数据就有点难了。下面使用 Kettle UDJC 组件给用户行为序列分组添加序列。

private String diffListId = "";
private String diffFuncNo = "";
private int fieldSeq = 0;

public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
    Object[] r = getRow();

    if (r == null) {
        setOutputDone();
        return false;
    }

    if (first) {
        first = false;
    }

    r = createOutputRow(r, data.outputRowMeta.size());
    
    // Get the value from an input field
    String fieldListId = get(Fields.In, "LIST_ID").getString(r);
    String fieldFuncNo = get(Fields.In, "FUNC_NO").getString(r);

    if (!diffListId.equals(fieldListId) || fieldFuncNo.equals("PU001")) {
        diffListId = fieldListId;
        fieldSeq++;
    }
    
    
    // Set a value in a new output field
    get(Fields.Out, "SEQ").setValue(r, fieldSeq);

    // Send the row on to the next step.
    putRow(data.outputRowMeta, r);

    return true;
}

 

以上是关于用 Kettle UDJC 组件实现用户行为组序列的主要内容,如果未能解决你的问题,请参考以下文章

kettle插入序列问题

kettle工具如何自动生成id

使用 UDJC 在 Pentaho 中读取受密码保护的 PDF

ActionListener的三种实现方法

Kettle从零开始第五弹之Kettle转换中常用组件介绍

Kettle从零开始第五弹之Kettle转换中常用组件介绍