Program: 47755
Project: 47755
Buggy source:
public boolean processRow(StepMetaInterface smi,StepDataInterface sdi) throws KettleException {
  if (first) {
    first=false;
    m_meta=(HBaseInputMeta)smi;
    m_data=(HBaseInputData)sdi;
    try {
      m_connection=HBaseInputData.getHBaseConnection(m_transMeta.environmentSubstitute(m_meta.getZookeeperHosts()),HBaseInputData.stringToURL(m_transMeta.environmentSubstitute(m_meta.getCoreConfigURL())),HBaseInputData.stringToURL(m_transMeta.environmentSubstitute(m_meta.getDefaultConfigURL())));
    }
 catch (    IOException ex) {
      throw new KettleException("String_Node_Str");
    }
    try {
      m_mappingAdmin=new MappingAdmin(m_connection);
    }
 catch (    Exception ex) {
      throw new KettleException("String_Node_Str");
    }
    HBaseAdmin admin=null;
    try {
      admin=new HBaseAdmin(m_connection);
    }
 catch (    Exception ex) {
      throw new KettleException("String_Node_Str");
    }
    String sourceName=m_transMeta.environmentSubstitute(m_meta.getSourceTableName());
    try {
      if (!admin.tableExists(sourceName)) {
        throw new KettleException("String_Node_Str" + sourceName + "String_Node_Str");
      }
      if (admin.isTableDisabled(sourceName) || !admin.isTableAvailable(sourceName)) {
        throw new KettleException("String_Node_Str" + sourceName + "String_Node_Str");
      }
    }
 catch (    IOException ex) {
      throw new KettleException("String_Node_Str" + "String_Node_Str" + sourceName + "String_Node_Str");
    }
    try {
      m_tableMapping=m_mappingAdmin.getMapping(m_transMeta.environmentSubstitute(m_meta.getSourceTableName()),m_transMeta.environmentSubstitute(m_meta.getSourceMappingName()));
      m_columnsMappedByAlias=m_tableMapping.getMappedColumns();
    }
 catch (    IOException ex) {
      throw new KettleException(ex.getMessage());
    }
    m_userOutputColumns=m_meta.getOutputFields();
    if (m_userOutputColumns != null && m_userOutputColumns.size() > 0) {
      for (      HBaseValueMeta vm : m_userOutputColumns) {
        if (!vm.isKey()) {
          if (m_columnsMappedByAlias.get(vm.getAlias()) == null) {
            throw new KettleException("String_Node_Str" + "String_Node_Str" + vm.getAlias() + "String_Node_Str"+ m_tableMapping.getTableName()+ HBaseValueMeta.SEPARATOR+ m_tableMapping.getMappingName()+ "String_Node_Str");
          }
        }
      }
    }
    Scan s=null;
    if (Const.isEmpty(m_meta.getKeyStartValue()) && Const.isEmpty(m_meta.getKeyStopValue())) {
      s=new Scan();
    }
 else {
      byte[] keyLowerBound=HBaseValueMeta.encodeKeyValue(m_transMeta.environmentSubstitute(m_meta.getKeyStartValue()),m_tableMapping.getKeyType());
      if (Const.isEmpty(m_meta.getKeyStopValue())) {
        s=new Scan(keyLowerBound);
      }
 else {
        byte[] keyUpperBound=HBaseValueMeta.encodeKeyValue(m_transMeta.environmentSubstitute(m_meta.getKeyStopValue()),m_tableMapping.getKeyType());
        s=new Scan(keyLowerBound,keyUpperBound);
      }
    }
    if (!Const.isEmpty(m_meta.getScannerCacheSize())) {
      String temp=m_transMeta.environmentSubstitute(m_meta.getScannerCacheSize());
      int sc=Integer.parseInt(temp);
      s.setCaching(sc);
      logBasic("String_Node_Str" + sc + "String_Node_Str");
    }
    if (m_userOutputColumns != null && m_userOutputColumns.size() > 0) {
      for (      HBaseValueMeta currentCol : m_userOutputColumns) {
        if (!currentCol.isKey()) {
          String colFamilyName=currentCol.getColumnFamily();
          String qualifier=currentCol.getColumnName();
          s.addColumn(Bytes.toBytes(colFamilyName),Bytes.toBytes(qualifier));
        }
      }
    }
 else {
      Set<String> aliasSet=m_columnsMappedByAlias.keySet();
      for (      String name : aliasSet) {
        HBaseValueMeta currentCol=m_columnsMappedByAlias.get(name);
        String colFamilyName=currentCol.getColumnFamily();
        String qualifier=currentCol.getColumnName();
        s.addColumn(Bytes.toBytes(colFamilyName),Bytes.toBytes(qualifier));
      }
    }
    if (m_meta.getColumnFilters() != null && m_meta.getColumnFilters().size() > 0) {
      FilterList fl=null;
      if (m_meta.getMatchAnyFilter()) {
        fl=new FilterList(FilterList.Operator.MUST_PASS_ONE);
      }
 else {
        fl=new FilterList(FilterList.Operator.MUST_PASS_ALL);
      }
      for (      ColumnFilter cf : m_meta.getColumnFilters()) {
        HBaseValueMeta mappedCol=m_columnsMappedByAlias.get(cf.getFieldAlias());
        if (mappedCol == null) {
          throw new KettleException("String_Node_Str" + cf.getFieldAlias() + "String_Node_Str");
        }
        if (!Const.isEmpty(cf.getFieldType())) {
          if (!mappedCol.getHBaseTypeDesc().equalsIgnoreCase(cf.getFieldType())) {
            throw new KettleException("String_Node_Str" + cf.getFieldType() + "String_Node_Str"+ cf.getFieldAlias()+ "String_Node_Str"+ "String_Node_Str"+ mappedCol.getHBaseTypeDesc()+ "String_Node_Str");
          }
        }
        CompareFilter.CompareOp comp=null;
        byte[] family=Bytes.toBytes(mappedCol.getColumnFamily());
        byte[] qualifier=Bytes.toBytes(mappedCol.getColumnName());
        ColumnFilter.ComparisonType op=cf.getComparisonOperator();
switch (op) {
case EQUAL:
          comp=CompareFilter.CompareOp.EQUAL;
        break;
case NOT_EQUAL:
      comp=CompareFilter.CompareOp.NOT_EQUAL;
    break;
case GREATER_THAN:
  comp=CompareFilter.CompareOp.GREATER;
break;
case GREATER_THAN_OR_EQUAL:
comp=CompareFilter.CompareOp.GREATER_OR_EQUAL;
break;
case LESS_THAN:
comp=CompareFilter.CompareOp.LESS;
break;
case LESS_THAN_OR_EQUAL:
comp=CompareFilter.CompareOp.LESS_OR_EQUAL;
break;
}
String comparisonString=cf.getConstant().trim();
if (comp != null) {
byte[] comparisonRaw=null;
if (mappedCol.isNumeric()) {
DecimalFormat df=new DecimalFormat();
if (!Const.isEmpty(cf.getFormat())) {
df.applyPattern(cf.getFormat());
}
Number num=null;
try {
num=df.parse(comparisonString);
}
 catch (ParseException e) {
throw new KettleException(e.getMessage());
}
if (mappedCol.isInteger()) {
if (!mappedCol.getIsLongOrDouble()) {
comparisonRaw=Bytes.toBytes(num.intValue());
}
 else {
comparisonRaw=Bytes.toBytes(num.longValue());
}
}
 else {
if (!mappedCol.getIsLongOrDouble()) {
comparisonRaw=Bytes.toBytes(num.floatValue());
}
 else {
comparisonRaw=Bytes.toBytes(num.doubleValue());
}
}
if (!cf.getSignedComparison()) {
SingleColumnValueFilter scf=new SingleColumnValueFilter(family,qualifier,comp,comparisonRaw);
scf.setFilterIfMissing(true);
fl.addFilter(scf);
}
 else {
DeserializedNumericComparator comparator=null;
if (mappedCol.isInteger()) {
if (mappedCol.getIsLongOrDouble()) {
comparator=new DeserializedNumericComparator(mappedCol.isInteger(),mappedCol.getIsLongOrDouble(),num.longValue());
}
 else {
comparator=new DeserializedNumericComparator(mappedCol.isInteger(),mappedCol.getIsLongOrDouble(),num.intValue());
}
}
 else {
if (mappedCol.getIsLongOrDouble()) {
comparator=new DeserializedNumericComparator(mappedCol.isInteger(),mappedCol.getIsLongOrDouble(),num.doubleValue());
}
 else {
comparator=new DeserializedNumericComparator(mappedCol.isInteger(),mappedCol.getIsLongOrDouble(),num.floatValue());
}
}
SingleColumnValueFilter scf=new SingleColumnValueFilter(family,qualifier,comp,comparator);
scf.setFilterIfMissing(true);
fl.addFilter(scf);
}
}
 else if (mappedCol.isDate()) {
SimpleDateFormat sdf=new SimpleDateFormat();
if (!Const.isEmpty(cf.getFormat())) {
sdf.applyPattern(cf.getFormat());
}
Date d=null;
try {
d=sdf.parse(comparisonString);
}
 catch (ParseException e) {
throw new KettleException(e.getMessage());
}
long dateAsMillis=d.getTime();
if (!cf.getSignedComparison()) {
comparisonRaw=Bytes.toBytes(dateAsMillis);
SingleColumnValueFilter scf=new SingleColumnValueFilter(family,qualifier,comp,comparisonRaw);
scf.setFilterIfMissing(true);
fl.addFilter(scf);
}
 else {
DeserializedNumericComparator comparator=new DeserializedNumericComparator(true,true,dateAsMillis);
SingleColumnValueFilter scf=new SingleColumnValueFilter(family,qualifier,comp,comparator);
scf.setFilterIfMissing(true);
fl.addFilter(scf);
}
}
 else if (mappedCol.isBoolean()) {
byte[] tempEncoded=Bytes.toBytes(comparisonString);
Boolean decodedB=HBaseValueMeta.decodeBoolFromString(tempEncoded);
if (decodedB == null) {
continue;
}
DeserializedBooleanComparator comparator=new DeserializedBooleanComparator(decodedB.booleanValue());
SingleColumnValueFilter scf=new SingleColumnValueFilter(family,qualifier,comp,comparator);
scf.setFilterIfMissing(true);
fl.addFilter(scf);
}
}
 else {
WritableByteArrayComparable comparator=null;
comp=CompareFilter.CompareOp.EQUAL;
if (cf.getComparisonOperator() == ColumnFilter.ComparisonType.SUBSTRING) {
comparator=new SubstringComparator(comparisonString);
}
 else {
comparator=new RegexStringComparator(comparisonString);
}
SingleColumnValueFilter scf=new SingleColumnValueFilter(family,qualifier,comp,comparator);
scf.setFilterIfMissing(true);
fl.addFilter(scf);
}
}
if (fl != null && fl.getFilters().size() > 0) {
s.setFilter(fl);
}
}
try {
m_sourceTable=new HTable(m_connection,m_tableMapping.getTableName());
m_resultSet=m_sourceTable.getScanner(s);
}
 catch (IOException e) {
throw new KettleException(e.getMessage());
}
m_data.setOutputRowMeta(new RowMeta());
m_meta.getFields(m_data.getOutputRowMeta(),getStepname(),null,null,this);
}
Result r=null;
try {
r=m_resultSet.next();
}
 catch (IOException e) {
throw new KettleException(e.getMessage());
}
if (r == null) {
m_resultSet.close();
try {
m_sourceTable.close();
}
 catch (IOException e) {
throw new KettleException("String_Node_Str" + e.getMessage());
}
setOutputDone();
return false;
}
int size=(m_userOutputColumns != null && m_userOutputColumns.size() > 0) ? m_userOutputColumns.size() : m_tableMapping.getMappedColumns().keySet().size() + 1;
Object[] outputRowData=RowDataUtil.allocateRowData(size);
if (m_userOutputColumns != null && m_userOutputColumns.size() > 0) {
for (HBaseValueMeta currentCol : m_userOutputColumns) {
if (currentCol.isKey()) {
byte[] rawKey=r.getRow();
Object decodedKey=HBaseValueMeta.decodeKeyValue(rawKey,m_tableMapping);
int keyIndex=m_data.getOutputRowMeta().indexOfValue(currentCol.getAlias());
outputRowData[keyIndex]=decodedKey;
}
 else {
String colFamilyName=currentCol.getColumnFamily();
String qualifier=currentCol.getColumnName();
KeyValue kv=r.getColumnLatest(Bytes.toBytes(colFamilyName),Bytes.toBytes(qualifier));
int outputIndex=m_data.getOutputRowMeta().indexOfValue(currentCol.getAlias());
if (outputIndex < 0) {
throw new KettleException("String_Node_Str" + currentCol.getAlias() + "String_Node_Str");
}
Object decodedVal=HBaseValueMeta.decodeColumnValue(kv,currentCol);
outputRowData[outputIndex]=decodedVal;
}
}
}
 else {
byte[] rawKey=r.getRow();
Object decodedKey=HBaseValueMeta.decodeKeyValue(rawKey,m_tableMapping);
int keyIndex=m_data.getOutputRowMeta().indexOfValue(m_tableMapping.getKeyName());
outputRowData[keyIndex]=decodedKey;
Set<String> aliasSet=m_columnsMappedByAlias.keySet();
for (String name : aliasSet) {
HBaseValueMeta currentCol=m_columnsMappedByAlias.get(name);
String colFamilyName=currentCol.getColumnFamily();
String qualifier=currentCol.getColumnName();
KeyValue kv=r.getColumnLatest(Bytes.toBytes(colFamilyName),Bytes.toBytes(qualifier));
int outputIndex=m_data.getOutputRowMeta().indexOfValue(name);
if (outputIndex < 0) {
throw new KettleException("String_Node_Str" + name + "String_Node_Str"+ "String_Node_Str");
}
Object decodedVal=HBaseValueMeta.decodeColumnValue(kv,currentCol);
outputRowData[outputIndex]=decodedVal;
}
}
putRow(m_data.getOutputRowMeta(),outputRowData);
return true;
}

Fixed version (ground truth):
public boolean processRow(StepMetaInterface smi,StepDataInterface sdi) throws KettleException {
  if (first) {
    first=false;
    m_meta=(HBaseInputMeta)smi;
    m_data=(HBaseInputData)sdi;
    try {
      m_connection=HBaseInputData.getHBaseConnection(m_transMeta.environmentSubstitute(m_meta.getZookeeperHosts()),HBaseInputData.stringToURL(m_transMeta.environmentSubstitute(m_meta.getCoreConfigURL())),HBaseInputData.stringToURL(m_transMeta.environmentSubstitute(m_meta.getDefaultConfigURL())));
    }
 catch (    IOException ex) {
      throw new KettleException("String_Node_Str");
    }
    try {
      m_mappingAdmin=new MappingAdmin(m_connection);
    }
 catch (    Exception ex) {
      throw new KettleException("String_Node_Str");
    }
    HBaseAdmin admin=null;
    try {
      admin=new HBaseAdmin(m_connection);
    }
 catch (    Exception ex) {
      throw new KettleException("String_Node_Str");
    }
    String sourceName=m_transMeta.environmentSubstitute(m_meta.getSourceTableName());
    try {
      if (!admin.tableExists(sourceName)) {
        throw new KettleException("String_Node_Str" + sourceName + "String_Node_Str");
      }
      if (admin.isTableDisabled(sourceName) || !admin.isTableAvailable(sourceName)) {
        throw new KettleException("String_Node_Str" + sourceName + "String_Node_Str");
      }
    }
 catch (    IOException ex) {
      throw new KettleException("String_Node_Str" + "String_Node_Str" + sourceName + "String_Node_Str");
    }
    try {
      m_tableMapping=m_mappingAdmin.getMapping(m_transMeta.environmentSubstitute(m_meta.getSourceTableName()),m_transMeta.environmentSubstitute(m_meta.getSourceMappingName()));
      m_columnsMappedByAlias=m_tableMapping.getMappedColumns();
    }
 catch (    IOException ex) {
      throw new KettleException(ex.getMessage());
    }
    String dateOrNumberConversionMaskForKey=null;
    m_userOutputColumns=m_meta.getOutputFields();
    if (m_userOutputColumns != null && m_userOutputColumns.size() > 0) {
      for (      HBaseValueMeta vm : m_userOutputColumns) {
        if (!vm.isKey()) {
          if (m_columnsMappedByAlias.get(vm.getAlias()) == null) {
            throw new KettleException("String_Node_Str" + "String_Node_Str" + vm.getAlias() + "String_Node_Str"+ m_tableMapping.getTableName()+ HBaseValueMeta.SEPARATOR+ m_tableMapping.getMappingName()+ "String_Node_Str");
          }
        }
 else {
          dateOrNumberConversionMaskForKey=vm.getConversionMask();
        }
      }
    }
    Scan s=null;
    if (Const.isEmpty(m_meta.getKeyStartValue()) && Const.isEmpty(m_meta.getKeyStopValue())) {
      s=new Scan();
    }
 else {
      byte[] keyLowerBound=null;
      String keyStartS=m_transMeta.environmentSubstitute(m_meta.getKeyStartValue());
      String convM=dateOrNumberConversionMaskForKey;
      if (m_tableMapping.getKeyType() != Mapping.KeyType.STRING) {
        String[] parts=keyStartS.split("String_Node_Str");
        if (parts.length == 2) {
          keyStartS=parts[0];
          convM=parts[1];
        }
        if (!Const.isEmpty(convM) && convM.length() > 0) {
          if (m_tableMapping.getKeyType() == Mapping.KeyType.DATE || m_tableMapping.getKeyType() == Mapping.KeyType.UNSIGNED_DATE) {
            SimpleDateFormat sdf=new SimpleDateFormat();
            sdf.applyPattern(convM);
            try {
              Date d=sdf.parse(keyStartS);
              keyLowerBound=HBaseValueMeta.encodeKeyValue(d,m_tableMapping.getKeyType());
            }
 catch (            ParseException e) {
              throw new KettleException("String_Node_Str" + keyStartS + "String_Node_Str");
            }
          }
 else {
            DecimalFormat df=new DecimalFormat();
            df.applyPattern(convM);
            Number num=null;
            try {
              num=df.parse(keyStartS);
              keyLowerBound=HBaseValueMeta.encodeKeyValue(num,m_tableMapping.getKeyType());
            }
 catch (            ParseException e) {
              throw new KettleException("String_Node_Str" + keyStartS + "String_Node_Str");
            }
          }
        }
 else {
          keyLowerBound=HBaseValueMeta.encodeKeyValue(keyStartS,m_tableMapping.getKeyType());
        }
      }
 else {
        keyLowerBound=HBaseValueMeta.encodeKeyValue(keyStartS,m_tableMapping.getKeyType());
      }
      if (Const.isEmpty(m_meta.getKeyStopValue())) {
        s=new Scan(keyLowerBound);
      }
 else {
        byte[] keyUpperBound=null;
        String keyStopS=m_transMeta.environmentSubstitute(m_meta.getKeyStopValue());
        convM=dateOrNumberConversionMaskForKey;
        if (m_tableMapping.getKeyType() != Mapping.KeyType.STRING) {
          String[] parts=keyStopS.split("String_Node_Str");
          if (parts.length == 2) {
            keyStopS=parts[0];
            convM=parts[1];
          }
          if (!Const.isEmpty(convM) && convM.length() > 0) {
            if (m_tableMapping.getKeyType() == Mapping.KeyType.DATE || m_tableMapping.getKeyType() == Mapping.KeyType.UNSIGNED_DATE) {
              SimpleDateFormat sdf=new SimpleDateFormat();
              sdf.applyPattern(convM);
              try {
                Date d=sdf.parse(keyStopS);
                keyUpperBound=HBaseValueMeta.encodeKeyValue(d,m_tableMapping.getKeyType());
              }
 catch (              ParseException e) {
                throw new KettleException("String_Node_Str" + keyStopS + "String_Node_Str");
              }
            }
 else {
              DecimalFormat df=new DecimalFormat();
              df.applyPattern(convM);
              Number num=null;
              try {
                num=df.parse(keyStopS);
                keyUpperBound=HBaseValueMeta.encodeKeyValue(num,m_tableMapping.getKeyType());
              }
 catch (              ParseException e) {
                throw new KettleException("String_Node_Str" + keyStopS + "String_Node_Str");
              }
            }
          }
 else {
            keyUpperBound=HBaseValueMeta.encodeKeyValue(keyStopS,m_tableMapping.getKeyType());
          }
        }
 else {
          keyUpperBound=HBaseValueMeta.encodeKeyValue(keyStartS,m_tableMapping.getKeyType());
        }
        s=new Scan(keyLowerBound,keyUpperBound);
      }
    }
    if (!Const.isEmpty(m_meta.getScannerCacheSize())) {
      String temp=m_transMeta.environmentSubstitute(m_meta.getScannerCacheSize());
      int sc=Integer.parseInt(temp);
      s.setCaching(sc);
      logBasic("String_Node_Str" + sc + "String_Node_Str");
    }
    if (m_userOutputColumns != null && m_userOutputColumns.size() > 0) {
      for (      HBaseValueMeta currentCol : m_userOutputColumns) {
        if (!currentCol.isKey()) {
          String colFamilyName=currentCol.getColumnFamily();
          String qualifier=currentCol.getColumnName();
          s.addColumn(Bytes.toBytes(colFamilyName),Bytes.toBytes(qualifier));
        }
      }
    }
 else {
      Set<String> aliasSet=m_columnsMappedByAlias.keySet();
      for (      String name : aliasSet) {
        HBaseValueMeta currentCol=m_columnsMappedByAlias.get(name);
        String colFamilyName=currentCol.getColumnFamily();
        String qualifier=currentCol.getColumnName();
        s.addColumn(Bytes.toBytes(colFamilyName),Bytes.toBytes(qualifier));
      }
    }
    if (m_meta.getColumnFilters() != null && m_meta.getColumnFilters().size() > 0) {
      FilterList fl=null;
      if (m_meta.getMatchAnyFilter()) {
        fl=new FilterList(FilterList.Operator.MUST_PASS_ONE);
      }
 else {
        fl=new FilterList(FilterList.Operator.MUST_PASS_ALL);
      }
      for (      ColumnFilter cf : m_meta.getColumnFilters()) {
        HBaseValueMeta mappedCol=m_columnsMappedByAlias.get(cf.getFieldAlias());
        if (mappedCol == null) {
          throw new KettleException("String_Node_Str" + cf.getFieldAlias() + "String_Node_Str");
        }
        if (!Const.isEmpty(cf.getFieldType())) {
          if (!mappedCol.getHBaseTypeDesc().equalsIgnoreCase(cf.getFieldType())) {
            throw new KettleException("String_Node_Str" + cf.getFieldType() + "String_Node_Str"+ cf.getFieldAlias()+ "String_Node_Str"+ "String_Node_Str"+ mappedCol.getHBaseTypeDesc()+ "String_Node_Str");
          }
        }
        CompareFilter.CompareOp comp=null;
        byte[] family=Bytes.toBytes(mappedCol.getColumnFamily());
        byte[] qualifier=Bytes.toBytes(mappedCol.getColumnName());
        ColumnFilter.ComparisonType op=cf.getComparisonOperator();
switch (op) {
case EQUAL:
          comp=CompareFilter.CompareOp.EQUAL;
        break;
case NOT_EQUAL:
      comp=CompareFilter.CompareOp.NOT_EQUAL;
    break;
case GREATER_THAN:
  comp=CompareFilter.CompareOp.GREATER;
break;
case GREATER_THAN_OR_EQUAL:
comp=CompareFilter.CompareOp.GREATER_OR_EQUAL;
break;
case LESS_THAN:
comp=CompareFilter.CompareOp.LESS;
break;
case LESS_THAN_OR_EQUAL:
comp=CompareFilter.CompareOp.LESS_OR_EQUAL;
break;
}
String comparisonString=cf.getConstant().trim();
if (comp != null) {
byte[] comparisonRaw=null;
if (mappedCol.isNumeric()) {
DecimalFormat df=new DecimalFormat();
if (!Const.isEmpty(cf.getFormat())) {
df.applyPattern(cf.getFormat());
}
Number num=null;
try {
num=df.parse(comparisonString);
}
 catch (ParseException e) {
throw new KettleException(e.getMessage());
}
if (mappedCol.isInteger()) {
if (!mappedCol.getIsLongOrDouble()) {
comparisonRaw=Bytes.toBytes(num.intValue());
}
 else {
comparisonRaw=Bytes.toBytes(num.longValue());
}
}
 else {
if (!mappedCol.getIsLongOrDouble()) {
comparisonRaw=Bytes.toBytes(num.floatValue());
}
 else {
comparisonRaw=Bytes.toBytes(num.doubleValue());
}
}
if (!cf.getSignedComparison()) {
SingleColumnValueFilter scf=new SingleColumnValueFilter(family,qualifier,comp,comparisonRaw);
scf.setFilterIfMissing(true);
fl.addFilter(scf);
}
 else {
DeserializedNumericComparator comparator=null;
if (mappedCol.isInteger()) {
if (mappedCol.getIsLongOrDouble()) {
comparator=new DeserializedNumericComparator(mappedCol.isInteger(),mappedCol.getIsLongOrDouble(),num.longValue());
}
 else {
comparator=new DeserializedNumericComparator(mappedCol.isInteger(),mappedCol.getIsLongOrDouble(),num.intValue());
}
}
 else {
if (mappedCol.getIsLongOrDouble()) {
comparator=new DeserializedNumericComparator(mappedCol.isInteger(),mappedCol.getIsLongOrDouble(),num.doubleValue());
}
 else {
comparator=new DeserializedNumericComparator(mappedCol.isInteger(),mappedCol.getIsLongOrDouble(),num.floatValue());
}
}
SingleColumnValueFilter scf=new SingleColumnValueFilter(family,qualifier,comp,comparator);
scf.setFilterIfMissing(true);
fl.addFilter(scf);
}
}
 else if (mappedCol.isDate()) {
SimpleDateFormat sdf=new SimpleDateFormat();
if (!Const.isEmpty(cf.getFormat())) {
sdf.applyPattern(cf.getFormat());
}
Date d=null;
try {
d=sdf.parse(comparisonString);
}
 catch (ParseException e) {
throw new KettleException(e.getMessage());
}
long dateAsMillis=d.getTime();
if (!cf.getSignedComparison()) {
comparisonRaw=Bytes.toBytes(dateAsMillis);
SingleColumnValueFilter scf=new SingleColumnValueFilter(family,qualifier,comp,comparisonRaw);
scf.setFilterIfMissing(true);
fl.addFilter(scf);
}
 else {
DeserializedNumericComparator comparator=new DeserializedNumericComparator(true,true,dateAsMillis);
SingleColumnValueFilter scf=new SingleColumnValueFilter(family,qualifier,comp,comparator);
scf.setFilterIfMissing(true);
fl.addFilter(scf);
}
}
 else if (mappedCol.isBoolean()) {
byte[] tempEncoded=Bytes.toBytes(comparisonString);
Boolean decodedB=HBaseValueMeta.decodeBoolFromString(tempEncoded);
if (decodedB == null) {
continue;
}
DeserializedBooleanComparator comparator=new DeserializedBooleanComparator(decodedB.booleanValue());
SingleColumnValueFilter scf=new SingleColumnValueFilter(family,qualifier,comp,comparator);
scf.setFilterIfMissing(true);
fl.addFilter(scf);
}
}
 else {
WritableByteArrayComparable comparator=null;
comp=CompareFilter.CompareOp.EQUAL;
if (cf.getComparisonOperator() == ColumnFilter.ComparisonType.SUBSTRING) {
comparator=new SubstringComparator(comparisonString);
}
 else {
comparator=new RegexStringComparator(comparisonString);
}
SingleColumnValueFilter scf=new SingleColumnValueFilter(family,qualifier,comp,comparator);
scf.setFilterIfMissing(true);
fl.addFilter(scf);
}
}
if (fl != null && fl.getFilters().size() > 0) {
s.setFilter(fl);
}
}
try {
m_sourceTable=new HTable(m_connection,m_tableMapping.getTableName());
m_resultSet=m_sourceTable.getScanner(s);
}
 catch (IOException e) {
throw new KettleException(e.getMessage());
}
m_data.setOutputRowMeta(new RowMeta());
m_meta.getFields(m_data.getOutputRowMeta(),getStepname(),null,null,this);
}
Result r=null;
try {
r=m_resultSet.next();
}
 catch (IOException e) {
throw new KettleException(e.getMessage());
}
if (r == null) {
m_resultSet.close();
try {
m_sourceTable.close();
}
 catch (IOException e) {
throw new KettleException("String_Node_Str" + e.getMessage());
}
setOutputDone();
return false;
}
int size=(m_userOutputColumns != null && m_userOutputColumns.size() > 0) ? m_userOutputColumns.size() : m_tableMapping.getMappedColumns().keySet().size() + 1;
Object[] outputRowData=RowDataUtil.allocateRowData(size);
if (m_userOutputColumns != null && m_userOutputColumns.size() > 0) {
for (HBaseValueMeta currentCol : m_userOutputColumns) {
if (currentCol.isKey()) {
byte[] rawKey=r.getRow();
Object decodedKey=HBaseValueMeta.decodeKeyValue(rawKey,m_tableMapping);
int keyIndex=m_data.getOutputRowMeta().indexOfValue(currentCol.getAlias());
outputRowData[keyIndex]=decodedKey;
}
 else {
String colFamilyName=currentCol.getColumnFamily();
String qualifier=currentCol.getColumnName();
KeyValue kv=r.getColumnLatest(Bytes.toBytes(colFamilyName),Bytes.toBytes(qualifier));
int outputIndex=m_data.getOutputRowMeta().indexOfValue(currentCol.getAlias());
if (outputIndex < 0) {
throw new KettleException("String_Node_Str" + currentCol.getAlias() + "String_Node_Str");
}
Object decodedVal=HBaseValueMeta.decodeColumnValue(kv,currentCol);
outputRowData[outputIndex]=decodedVal;
}
}
}
 else {
byte[] rawKey=r.getRow();
Object decodedKey=HBaseValueMeta.decodeKeyValue(rawKey,m_tableMapping);
int keyIndex=m_data.getOutputRowMeta().indexOfValue(m_tableMapping.getKeyName());
outputRowData[keyIndex]=decodedKey;
Set<String> aliasSet=m_columnsMappedByAlias.keySet();
for (String name : aliasSet) {
HBaseValueMeta currentCol=m_columnsMappedByAlias.get(name);
String colFamilyName=currentCol.getColumnFamily();
String qualifier=currentCol.getColumnName();
KeyValue kv=r.getColumnLatest(Bytes.toBytes(colFamilyName),Bytes.toBytes(qualifier));
int outputIndex=m_data.getOutputRowMeta().indexOfValue(name);
if (outputIndex < 0) {
throw new KettleException("String_Node_Str" + name + "String_Node_Str"+ "String_Node_Str");
}
Object decodedVal=HBaseValueMeta.decodeColumnValue(kv,currentCol);
outputRowData[outputIndex]=decodedVal;
}
}
putRow(m_data.getOutputRowMeta(),outputRowData);
return true;
}