zoukankan      html  css  js  c++  java
  • etl实现字段值相加

    数据库USERS表:

    etl步骤:

    (2)

    (3)

    其中java代码为:

        import test.Test;
         
        public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
        {
            Object[] r = getRow();
            if (r == null) {
                setOutputDone();
                return false;
            }
            if (first)
            {
                first = false;
            } 
            // It is always safest to call createOutputRow() to ensure that your output row's Object[] is large
            // enough to handle any new fields you are creating in this step.
            //r = createOutputRow(r, outputRowSize);    
            /* TODO: Your code here. (See Sample)         
            / Get the value from an input field
            String foobar = get(Fields.In, "a_fieldname").getString(r);   
            foobar += "bar";       
            // Set a value in a new output field
            get(Fields.Out, "output_fieldname").setValue(r, foobar);   
            */
             //获取参数
            // String AGEField = getParameter("ID");        
            String ID = get(Fields.In, "ID").getString(r); //输入参数  
             get(Fields.Out, "ID").setValue(r, ID); //输出参数
            //调用jar
            String foobar = get(Fields.In, "NAME").getString(r); //输入参数
            foobar += Test.getMyName("我是谁的水");
            get(Fields.Out, "NAME").setValue(r, foobar);
    //获取参数
            // String AGEField = getParameter("ID");        
            //String ID = get(Fields.In, "ID").getString(r); //输入参数  
             get(Fields.Out, "aa").setValue(r, "xx"); //输出参数
            // Send the row on to the next step.
            putRow(data.outputRowMeta, r);
            return true;

    }

    打成jar包丢到kettle目录下:

    执行结果:

  • 相关阅读:
    九宫格代码
    数组相关
    动画设置模式大全
    extjs 学习小窍门
    linux mysql root密码重置
    (ExtJs 3.4)Ext.Ajax.request的同步请求实现
    Ext中renderer用法及参数
    Extjs 3.4 复选框的,默认选中 ,禁用,(纯属于自己代码中需要,总结!)
    linux部署安装nginx
    报表报500,tomcat日志显示报错:Can't connect to X11 window server using 'localhost:10.0' as the value of the DISPLAY variable
  • 原文地址:https://www.cnblogs.com/kongxc/p/6247825.html
Copyright © 2011-2022 走看看