Hitachi Vantara Pentaho Community Forums
Results 1 to 1 of 1

Thread: Help Needed... UDJC Error

  1. #1
    Join Date
    Jan 2011
    Posts
    3

    Default Help Needed... UDJC Error

    Hello all,

    The below code inside a UDJC is throwing the following error:

    java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
    java.util.ArrayList.RangeCheck(ArrayList.java:547)
    java.util.ArrayList.get(ArrayList.java:322)


    The behavior is that it that the UDJC processes the first row beautifully but then fails on the second input row when executing Object[] r = getRow();

    I'm hoping someone has seen this before i'm not a Java programmer so i'm sure i'm doing something glaringly wrong. If anyone could just point me towards my mistake i would greatly appreciate it. i've attached to transformation



    import java.util.*;

    private ArrayList allInfoRows = new ArrayList(20);

    public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
    {
    logBasic("Getting the next row...");

    Object[] r = getRow();

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

    if (first)
    {
    first = false;
    FieldHelper infoClaimID = get(Fields.Info, "claim_id");
    FieldHelper diag1 = get(Fields.Info, "d1");
    FieldHelper diag2 = get(Fields.Info, "d2");
    FieldHelper diag3 = get(Fields.Info, "d3");
    FieldHelper diag4 = get(Fields.Info, "d4");
    FieldHelper diag5 = get(Fields.Info, "d5");
    FieldHelper diag6 = get(Fields.Info, "d6");
    FieldHelper diag7 = get(Fields.Info, "d7");
    FieldHelper diag8 = get(Fields.Info, "d8");
    FieldHelper diag9 = get(Fields.Info, "d9");
    FieldHelper diag10 = get(Fields.Info, "d10");
    RowSet infoStream = findInfoRowSet("infoStep");

    Object[] infoRow = null;
    ArrayList aRow = null;
    while((infoRow = getRowFrom(infoStream)) != null){
    logBasic("gettingRowFrom(infoStream)");
    aRow = new ArrayList(20);
    aRow.add(infoClaimID.getString(infoRow));
    aRow.add(diag1.getString(infoRow));
    aRow.add(diag2.getString(infoRow));
    aRow.add(diag3.getString(infoRow));
    aRow.add(diag4.getString(infoRow));
    aRow.add(diag5.getString(infoRow));
    aRow.add(diag6.getString(infoRow));
    aRow.add(diag7.getString(infoRow));
    aRow.add(diag8.getString(infoRow));
    aRow.add(diag9.getString(infoRow));
    aRow.add(diag10.getString(infoRow));
    allInfoRows.add(aRow);
    }

    }



    //Object[] out_row = RowDataUtil.createResizedCopy(r, data.outputRowMeta.size());

    //String value = inputField.getString(r);

    Long claimId = (Long) r[0];
    int allRowsSize = allInfoRows.size();
    for( int i = 0; i < allRowsSize; i++){

    Object[] out_row = RowDataUtil.createResizedCopy(r, data.outputRowMeta.size());

    logBasic("i = " + i);
    ArrayList inputRow = new ArrayList(Arrays.asList(r));

    ArrayList infoRow = (ArrayList) allInfoRows.get(i);

    //int infoClaimid = (int)infoRow[0];

    logBasic("claimId = " + claimId + "and infoRow(0) = " + infoRow.get(0));
    if (!(claimId.equals(infoRow.get(0)))){

    inputRow.retainAll( infoRow );

    int size = inputRow.size();
    logBasic("size = " + size);
    if (size >0 ){

    for ( int j = 0; j < size; j++){

    logBasic("j = " + j);
    logBasic("diagcode is: " + (String)infoRow.get(j));
    get(Fields.Out, j+"").setValue(out_row,(String)infoRow.get(j));
    putRow(data.outputRowMeta, out_row);
    }
    }

    }
    }

    logBasic("returning...");

    return true;
    }
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.