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

    执行结果:

  • 相关阅读:
    公司技术的确定
    数据结构
    如何利用百度ocr实现验证码自动识别
    redis 主从复制
    redis哨兵机制
    redis集群搭建
    webmagic自定义存储(mysql、redis存储)
    redis安装与使用
    maven插件mybatis-generator自动生成代码
    python 中的“集合”(list、tuple、set、dict)
  • 原文地址:https://www.cnblogs.com/kongxc/p/6247825.html
Copyright © 2011-2022 走看看