本文整理汇总了Java中org.pentaho.di.core.row.ValueMetaInterface.getNumber方法的典型用法代码示例。如果您正苦于以下问题:Java ValueMetaInterface.getNumber方法的具体用法?Java ValueMetaInterface.getNumber怎么用?Java ValueMetaInterface.getNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.core.row.ValueMetaInterface
的用法示例。
在下文中一共展示了ValueMetaInterface.getNumber方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrimitive
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public static Object getPrimitive(ValueMetaInterface valueMeta, Object valueData) throws KettleValueException
{
switch(valueMeta.getType())
{
case ValueMetaInterface.TYPE_BIGNUMBER: return valueMeta.getBigNumber(valueData);
case ValueMetaInterface.TYPE_BINARY: return valueMeta.getBinary(valueData);
case ValueMetaInterface.TYPE_BOOLEAN: return valueMeta.getBoolean(valueData);
case ValueMetaInterface.TYPE_DATE: return valueMeta.getDate(valueData);
case ValueMetaInterface.TYPE_INTEGER: valueMeta.getInteger(valueData);
case ValueMetaInterface.TYPE_NUMBER: return valueMeta.getNumber(valueData);
// case ValueMetaInterface.TYPE_SERIALIZABLE: return valueMeta.(valueData);
case ValueMetaInterface.TYPE_STRING: return valueMeta.getString(valueData);
default: return null;
}
}
示例2: writeRowToBulk
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
private void writeRowToBulk(RowMetaInterface rowMeta, Object[] r) throws KettleException {
try {
for (int i=0;i<data.keynrs.length;i++) {
int index = data.keynrs[i];
ValueMetaInterface valueMeta = rowMeta.getValueMeta(index);
Object valueData = r[index];
switch(valueMeta.getType()) {
case ValueMetaInterface.TYPE_STRING :
data.fifoStream.write(TeraDataBulkLoaderRoutines.convertVarchar(valueMeta.getString(valueData)));
break;
case ValueMetaInterface.TYPE_INTEGER:
data.fifoStream.write(TeraDataBulkLoaderRoutines.convertLong(valueMeta.getInteger(valueData)));
break;
case ValueMetaInterface.TYPE_DATE:
Date date = valueMeta.getDate(valueData);
data.fifoStream.write(TeraDataBulkLoaderRoutines.convertDateTime(date));
break;
case ValueMetaInterface.TYPE_BOOLEAN:
Boolean b= valueMeta.getBoolean(valueData);
data.fifoStream.write(TeraDataBulkLoaderRoutines.convertBoolean(b));
break;
case ValueMetaInterface.TYPE_NUMBER:
Double d = valueMeta.getNumber(valueData);
data.fifoStream.write(TeraDataBulkLoaderRoutines.convertFloat(d));
break;
case ValueMetaInterface.TYPE_BIGNUMBER:
BigDecimal bn = valueMeta.getBigNumber(valueData);
data.fifoStream.write(TeraDataBulkLoaderRoutines.convertBignum(bn));
break;
default:
logError("This is seen when a type in the PDI stream is not handleed by the step. Type is "+valueMeta.getType());
throw new KettleException("Unsupported type in stream");
}
}
}
catch(IOException e)
{
// If something went wrong with writing to the fifo, get the underlying error from MySQL
try{
logError("IOException writing to fifo. Waiting up to " + this.threadWaitTimeText + " for the tbuild command thread to return with the error.");
}
catch (Exception loadEx){
logError("Caught Loadex error :"+ loadEx);
throw new KettleException("loadEx Error serializing rows of data to the fifo file 1", loadEx);
}
// throw the generic "Pipe" exception.
logError("Caught IO error (pipe?):"+ e);
throw new KettleException("IO Error serializing rows of data to the fifo file 2", e);
}
catch (Exception e2){
logError("Caught some error :"+ e2);
// Null pointer exceptions etc.
throw new KettleException("Error serializing rows of data to the fifo file", e2);
}
}
示例3: AddAggregate
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
private synchronized void AddAggregate(RowMetaInterface rowMeta, Object[] r) throws KettleValueException
{
for (int i=0;i<data.fieldnrs.length;i++)
{
ValueMetaInterface valueMeta = rowMeta.getValueMeta(data.fieldnrs[i]);
Object valueData = r[data.fieldnrs[i]];
if (!valueMeta.isNull(valueData))
{
data.counts[i]++; // only count non-zero values!
switch(meta.getAggregateType()[i])
{
case AggregateRowsMeta.TYPE_AGGREGATE_SUM:
case AggregateRowsMeta.TYPE_AGGREGATE_AVERAGE:
{
Double number = valueMeta.getNumber(valueData);
if (data.values[i]==null)
{
data.values[i]=number;
}
else
{
data.values[i] = new Double( ((Double)data.values[i]).doubleValue() + number.doubleValue() );
}
}
break;
case AggregateRowsMeta.TYPE_AGGREGATE_MIN:
{
if (data.values[i]==null)
{
data.values[i]=valueData;
}
else
{
if (valueMeta.compare(data.values[i], valueData)<0) data.values[i]=valueData;
}
}
break;
case AggregateRowsMeta.TYPE_AGGREGATE_MAX:
{
if (data.values[i]==null)
{
data.values[i]=valueData;
}
else
{
if (valueMeta.compare(data.values[i], valueData)>0) data.values[i]=valueData;
}
}
break;
case AggregateRowsMeta.TYPE_AGGREGATE_NONE:
case AggregateRowsMeta.TYPE_AGGREGATE_FIRST:
if (data.values[i]==null)
{
data.values[i]=valueData;
}
break;
case AggregateRowsMeta.TYPE_AGGREGATE_LAST:
data.values[i]=valueData;
break;
}
}
switch(meta.getAggregateType()[i])
{
case AggregateRowsMeta.TYPE_AGGREGATE_FIRST_NULL: // First value, EVEN if it's NULL:
if (data.values[i]==null)
{
data.values[i]=valueData;
}
break;
case AggregateRowsMeta.TYPE_AGGREGATE_LAST_NULL: // Last value, EVEN if it's NULL:
data.values[i]=valueData;
break;
default: break;
}
}
}
示例4: createObjectsForRow
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public static Object[] createObjectsForRow(RowMetaInterface rowMeta, Object[] rowData) throws KettleValueException
{
Object[] values = new Object[rowMeta.size()];
for (int i=0;i<rowMeta.size();i++)
{
ValueMetaInterface valueMeta = rowMeta.getValueMeta(i);
Object valueData = rowData[i];
int length = valueMeta.getLength();
switch(valueMeta.getType())
{
case ValueMetaInterface.TYPE_INTEGER:
if (length<3)
{
values[i] = new Byte( valueMeta.getInteger(valueData).byteValue() );
}
else
{
if (length<5)
{
values[i] = new Short(valueMeta.getInteger(valueData).shortValue());
}
else
{
values[i] = valueMeta.getInteger(valueData);
}
}
break;
case ValueMetaInterface.TYPE_NUMBER:
values[i] = valueMeta.getNumber(valueData);
break;
case ValueMetaInterface.TYPE_DATE:
values[i] = valueMeta.getDate(valueData);
break;
case ValueMetaInterface.TYPE_STRING:
values[i] = valueMeta.getString(valueData);
break;
case ValueMetaInterface.TYPE_BINARY:
values[i] = valueMeta.getBinary(valueData);
break;
case ValueMetaInterface.TYPE_BOOLEAN:
values[i] = valueMeta.getBoolean(valueData);
break;
case ValueMetaInterface.TYPE_BIGNUMBER:
values[i] = valueMeta.getNumber(valueData);
break;
default: break;
}
}
return values;
}
示例5: createObjectsForRow
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public static Object[] createObjectsForRow(RowMetaInterface rowMeta, Object[] rowData) throws KettleValueException
{
Object[] values = new Object[rowMeta.size()];
for (int i=0;i<rowMeta.size();i++)
{
ValueMetaInterface valueMeta = rowMeta.getValueMeta(i);
Object valueData = rowData[i];
// Prevent a NullPointerException below
if (valueData == null || valueMeta == null)
{
values[i] = null;
continue;
}
int length = valueMeta.getLength();
switch(valueMeta.getType())
{
case ValueMetaInterface.TYPE_INTEGER:
if (length<3)
{
values[i] = new Byte( valueMeta.getInteger(valueData).byteValue() );
}
else
{
if (length<5)
{
values[i] = new Short(valueMeta.getInteger(valueData).shortValue());
}
else
{
values[i] = valueMeta.getInteger(valueData);
}
}
break;
case ValueMetaInterface.TYPE_NUMBER:
values[i] = valueMeta.getNumber(valueData);
break;
case ValueMetaInterface.TYPE_DATE:
values[i] = valueMeta.getDate(valueData);
break;
case ValueMetaInterface.TYPE_STRING:
values[i] = valueMeta.getString(valueData);
break;
case ValueMetaInterface.TYPE_BINARY:
values[i] = valueMeta.getBinary(valueData);
break;
case ValueMetaInterface.TYPE_BOOLEAN:
values[i] = valueMeta.getBoolean(valueData);
break;
case ValueMetaInterface.TYPE_BIGNUMBER:
values[i] = valueMeta.getNumber(valueData);
break;
default: break;
}
}
return values;
}