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目录下:

    执行结果:

  • 相关阅读:
    爬虫实战篇(模拟登录)---我们以模拟去哪儿网为例
    requests库详解
    爬取拉钩网职位信息写入mongodb数据库(小白学爬虫--实战篇1)
    《Vue项目关于i18n双语切换》
    《Vue+Vuetify》
    《Vue项目的创建以及初始化(两种方法)》
    《关于Vue的涟漪点击》
    《Vue的父子组件传值》
    《vue 页面进出类似APP的滑动效果》
    《Vue里的路由拦截》
  • 原文地址:https://www.cnblogs.com/kongxc/p/6247825.html
Copyright © 2011-2022 走看看