本文整理汇总了Java中org.pentaho.di.core.row.ValueDataUtil类的典型用法代码示例。如果您正苦于以下问题:Java ValueDataUtil类的具体用法?Java ValueDataUtil怎么用?Java ValueDataUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValueDataUtil类属于org.pentaho.di.core.row包,在下文中一共展示了ValueDataUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCumulativeSums
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
private void addCumulativeSums(Object[] row) throws KettleValueException {
// We need to adjust this row with cumulative averages?
//
for (int i=0;i<data.cumulativeSumSourceIndexes.size();i++)
{
int sourceIndex = data.cumulativeSumSourceIndexes.get(i);
Object previousTarget = data.previousSums[i];
Object sourceValue = row[sourceIndex];
int targetIndex = data.cumulativeSumTargetIndexes.get(i);
ValueMetaInterface sourceMeta = data.inputRowMeta.getValueMeta(sourceIndex);
ValueMetaInterface targetMeta = data.outputRowMeta.getValueMeta(targetIndex);
// If the first values where null, or this is the first time around, just take the source value...
//
if (targetMeta.isNull(previousTarget))
{
row[targetIndex]=sourceMeta.convertToNormalStorageType(sourceValue);
}
else
{
// If the source value is null, just take the previous target value
//
if (sourceMeta.isNull(sourceValue))
{
row[targetIndex] = previousTarget;
}
else
{
row[targetIndex] = ValueDataUtil.plus(targetMeta, data.previousSums[i], sourceMeta, row[sourceIndex]);
}
}
data.previousSums[i] = row[targetIndex];
}
}
示例2: getAggregateResult
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
private Object[] getAggregateResult() throws KettleValueException
{
Object[] result = new Object[data.subjectnrs.length];
if (data.subjectnrs!=null)
{
for (int i=0;i<data.subjectnrs.length;i++)
{
Object ag = data.agg[i];
switch(meta.getAggregateType()[i])
{
case GroupByMeta.TYPE_GROUP_SUM : break;
case GroupByMeta.TYPE_GROUP_AVERAGE :
ag=ValueDataUtil.divide(data.aggMeta.getValueMeta(i), ag,
new ValueMeta("c",ValueMetaInterface.TYPE_INTEGER), new Long(data.counts[i]));
break; //$NON-NLS-1$
case GroupByMeta.TYPE_GROUP_COUNT_ALL : ag=new Long(data.counts[i]); break;
case GroupByMeta.TYPE_GROUP_COUNT_DISTINCT : break;
case GroupByMeta.TYPE_GROUP_MIN : break;
case GroupByMeta.TYPE_GROUP_MAX : break;
case GroupByMeta.TYPE_GROUP_STANDARD_DEVIATION :
double sum = (Double)ag / data.counts[i];
ag = Double.valueOf( Math.sqrt( sum ) );
break;
case GroupByMeta.TYPE_GROUP_CONCAT_COMMA:;
case GroupByMeta.TYPE_GROUP_CONCAT_STRING:
ag = ((StringBuilder) ag).toString();
break;
default: break;
}
result[i]=ag;
}
}
return result;
}
示例3: getAggregateResult
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
private Object[] getAggregateResult(Aggregate aggregate) throws KettleValueException
{
Object[] result = new Object[data.subjectnrs.length];
if (data.subjectnrs!=null)
{
for (int i=0;i<data.subjectnrs.length;i++)
{
Object ag = aggregate.agg[i];
switch(meta.getAggregateType()[i])
{
case MemoryGroupByMeta.TYPE_GROUP_SUM : break;
case MemoryGroupByMeta.TYPE_GROUP_AVERAGE :
ag=ValueDataUtil.divide(data.aggMeta.getValueMeta(i), ag,
new ValueMeta("c",ValueMetaInterface.TYPE_INTEGER), new Long(aggregate.counts[i]));
break; //$NON-NLS-1$
case MemoryGroupByMeta.TYPE_GROUP_COUNT_ALL : ag=new Long(aggregate.counts[i]); break;
case MemoryGroupByMeta.TYPE_GROUP_COUNT_DISTINCT : break;
case MemoryGroupByMeta.TYPE_GROUP_MIN : break;
case MemoryGroupByMeta.TYPE_GROUP_MAX : break;
case MemoryGroupByMeta.TYPE_GROUP_STANDARD_DEVIATION :
double sum = (Double)ag / aggregate.counts[i];
ag = Double.valueOf( Math.sqrt( sum ) );
break;
case GroupByMeta.TYPE_GROUP_CONCAT_COMMA:;
case GroupByMeta.TYPE_GROUP_CONCAT_STRING:
ag = ((StringBuilder) ag).toString();
break;
default: break;
}
result[i]=ag;
}
}
return result;
}
示例4: getAggregateResult
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
private Object[] getAggregateResult() throws KettleValueException
{
Object[] result = new Object[data.subjectnrs.length];
if (data.subjectnrs!=null)
{
for (int i=0;i<data.subjectnrs.length;i++)
{
Object ag = data.agg[i];
switch(meta.getAggregateType()[i])
{
case GroupByMeta.TYPE_GROUP_SUM : break;
case GroupByMeta.TYPE_GROUP_AVERAGE :
ag=ValueDataUtil.divide(data.aggMeta.getValueMeta(i), ag,
new ValueMeta("c",ValueMetaInterface.TYPE_INTEGER), new Long(data.counts[i]));
break; //$NON-NLS-1$
case GroupByMeta.TYPE_GROUP_COUNT_ANY :
case GroupByMeta.TYPE_GROUP_COUNT_ALL : ag=new Long(data.counts[i]); break;
case GroupByMeta.TYPE_GROUP_COUNT_DISTINCT : break;
case GroupByMeta.TYPE_GROUP_MIN : break;
case GroupByMeta.TYPE_GROUP_MAX : break;
case GroupByMeta.TYPE_GROUP_STANDARD_DEVIATION :
double sum = (Double)ag / data.counts[i];
ag = Double.valueOf( Math.sqrt( sum ) );
break;
case GroupByMeta.TYPE_GROUP_CONCAT_COMMA:;
case GroupByMeta.TYPE_GROUP_CONCAT_STRING:
ag = ((StringBuilder) ag).toString();
break;
default: break;
}
result[i]=ag;
}
}
return result;
}
示例5: getAggregateResult
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
private Object[] getAggregateResult(Aggregate aggregate) throws KettleValueException
{
Object[] result = new Object[data.subjectnrs.length];
if (data.subjectnrs!=null)
{
for (int i=0;i<data.subjectnrs.length;i++)
{
Object ag = aggregate.agg[i];
switch(meta.getAggregateType()[i])
{
case MemoryGroupByMeta.TYPE_GROUP_SUM : break;
case MemoryGroupByMeta.TYPE_GROUP_AVERAGE :
ag=ValueDataUtil.divide(data.aggMeta.getValueMeta(i), ag,
new ValueMeta("c",ValueMetaInterface.TYPE_INTEGER), new Long(aggregate.counts[i]));
break; //$NON-NLS-1$
case MemoryGroupByMeta.TYPE_GROUP_COUNT_ANY :
case MemoryGroupByMeta.TYPE_GROUP_COUNT_ALL : ag=new Long(aggregate.counts[i]); break;
case MemoryGroupByMeta.TYPE_GROUP_COUNT_DISTINCT : break;
case MemoryGroupByMeta.TYPE_GROUP_MIN : break;
case MemoryGroupByMeta.TYPE_GROUP_MAX : break;
case MemoryGroupByMeta.TYPE_GROUP_STANDARD_DEVIATION :
double sum = (Double)ag / aggregate.counts[i];
ag = Double.valueOf( Math.sqrt( sum ) );
break;
case MemoryGroupByMeta.TYPE_GROUP_CONCAT_COMMA:;
case MemoryGroupByMeta.TYPE_GROUP_CONCAT_STRING:
ag = ((StringBuilder) ag).toString();
break;
default: break;
}
result[i]=ag;
}
}
return result;
}
示例6: addCumulativeSums
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
private void addCumulativeSums( Object[] row ) throws KettleValueException {
// We need to adjust this row with cumulative averages?
//
for ( int i = 0; i < data.cumulativeSumSourceIndexes.size(); i++ ) {
int sourceIndex = data.cumulativeSumSourceIndexes.get( i );
Object previousTarget = data.previousSums[ i ];
Object sourceValue = row[ sourceIndex ];
int targetIndex = data.cumulativeSumTargetIndexes.get( i );
ValueMetaInterface sourceMeta = data.inputRowMeta.getValueMeta( sourceIndex );
ValueMetaInterface targetMeta = data.outputRowMeta.getValueMeta( targetIndex );
// If the first values where null, or this is the first time around, just take the source value...
//
if ( targetMeta.isNull( previousTarget ) ) {
row[ targetIndex ] = sourceMeta.convertToNormalStorageType( sourceValue );
} else {
// If the source value is null, just take the previous target value
//
if ( sourceMeta.isNull( sourceValue ) ) {
row[ targetIndex ] = previousTarget;
} else {
row[ targetIndex ] = ValueDataUtil.plus( targetMeta, data.previousSums[ i ], sourceMeta, row[ sourceIndex ] );
}
}
data.previousSums[ i ] = row[ targetIndex ];
}
}
示例7: getRound2Mode
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
/**
* Get value of private static field ValueDataUtil.ROUND_2_MODE.
*
* @return
*/
private static int getRound2Mode() {
int value = -1;
try {
Class<ValueDataUtil> cls = ValueDataUtil.class;
Field f = cls.getDeclaredField( SYS_PROPERTY_ROUND_2_MODE );
f.setAccessible( true );
value = (Integer) f.get( null );
f.setAccessible( false );
} catch ( Exception e ) {
throw new RuntimeException( e );
}
return value;
}
示例8: setRound2Mode
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
/**
* Set new value of value of private static field ValueDataUtil.ROUND_2_MODE.
*
* @param newValue
*/
private static void setRound2Mode( int newValue ) {
try {
Class<ValueDataUtil> cls = ValueDataUtil.class;
Field f = cls.getDeclaredField( SYS_PROPERTY_ROUND_2_MODE );
f.setAccessible( true );
f.set( null, newValue );
f.setAccessible( false );
} catch ( Exception e ) {
throw new RuntimeException( e );
}
}
示例9: addCumulativeAverages
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
private void addCumulativeAverages(Object[] row) throws KettleValueException {
// We need to adjust this row with cumulative sums
//
for (int i=0;i<data.cumulativeAvgSourceIndexes.size();i++)
{
int sourceIndex = data.cumulativeAvgSourceIndexes.get(i);
Object previousTarget = data.previousAvgSum[i];
Object sourceValue = row[sourceIndex];
int targetIndex = data.cumulativeAvgTargetIndexes.get(i);
ValueMetaInterface sourceMeta = data.inputRowMeta.getValueMeta(sourceIndex);
ValueMetaInterface targetMeta = data.outputRowMeta.getValueMeta(targetIndex);
// If the first values where null, or this is the first time around, just take the source value...
//
Object sum = null;
if (targetMeta.isNull(previousTarget))
{
sum=sourceMeta.convertToNormalStorageType(sourceValue);
}
else
{
// If the source value is null, just take the previous target value
//
if (sourceMeta.isNull(sourceValue))
{
sum = previousTarget;
}
else
{
if (sourceMeta.isInteger())
{
sum = ValueDataUtil.plus(data.valueMetaInteger, data.previousAvgSum[i], sourceMeta, row[sourceIndex]);
}
else
{
sum = ValueDataUtil.plus(targetMeta, data.previousAvgSum[i], sourceMeta, row[sourceIndex]);
}
}
}
data.previousAvgSum[i] = sum;
if (!sourceMeta.isNull(sourceValue)) data.previousAvgCount[i]++;
if (sourceMeta.isInteger()) {
// Change to number as the exception
//
if (sum==null)
{
row[targetIndex] = null;
}
else
{
row[targetIndex] = new Double( ((Long)sum).doubleValue() / data.previousAvgCount[i] );
}
}
else
{
row[targetIndex] = ValueDataUtil.divide(targetMeta, sum, data.valueMetaInteger, data.previousAvgCount[i]);
}
}
}
示例10: multiply
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
public Value multiply(Value v) throws KettleValueException
{
// a number and a string!
if (isNull() || v.isNull())
{
setNull();
return this;
}
if ((v.isString() && isNumeric()) || (v.isNumeric() && isString()))
{
StringBuffer s;
String append="";
int n;
if (v.isString())
{
s=new StringBuffer(v.getString());
append=v.getString();
n=(int)getInteger();
}
else
{
s=new StringBuffer(getString());
append=getString();
n=(int)v.getInteger();
}
if (n==0) s.setLength(0);
else
for (int i=1;i<n;i++) s.append(append);
setValue(s);
}
else
// big numbers
if (isBigNumber() || v.isBigNumber())
{
setValue(ValueDataUtil.multiplyBigDecimals(getBigNumber(), v.getBigNumber(), null));
}
else
// numbers
if (isNumber() || v.isNumber())
{
setValue(getNumber()*v.getNumber());
}
else
// integers
if (isInteger() || v.isInteger())
{
setValue(getInteger()*v.getInteger());
}
else
{
throw new KettleValueException("Multiplication can only be done with numbers or a number and a string!");
}
return this;
}
示例11: addCumulativeAverages
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
private void addCumulativeAverages( Object[] row ) throws KettleValueException {
// We need to adjust this row with cumulative sums
//
for ( int i = 0; i < data.cumulativeAvgSourceIndexes.size(); i++ ) {
int sourceIndex = data.cumulativeAvgSourceIndexes.get( i );
Object previousTarget = data.previousAvgSum[ i ];
Object sourceValue = row[ sourceIndex ];
int targetIndex = data.cumulativeAvgTargetIndexes.get( i );
ValueMetaInterface sourceMeta = data.inputRowMeta.getValueMeta( sourceIndex );
ValueMetaInterface targetMeta = data.outputRowMeta.getValueMeta( targetIndex );
// If the first values where null, or this is the first time around, just take the source value...
//
Object sum = null;
if ( targetMeta.isNull( previousTarget ) ) {
sum = sourceMeta.convertToNormalStorageType( sourceValue );
} else {
// If the source value is null, just take the previous target value
//
if ( sourceMeta.isNull( sourceValue ) ) {
sum = previousTarget;
} else {
if ( sourceMeta.isInteger() ) {
sum = ValueDataUtil.plus( data.valueMetaInteger, data.previousAvgSum[ i ], sourceMeta, row[ sourceIndex ] );
} else {
sum = ValueDataUtil.plus( targetMeta, data.previousAvgSum[ i ], sourceMeta, row[ sourceIndex ] );
}
}
}
data.previousAvgSum[ i ] = sum;
if ( !sourceMeta.isNull( sourceValue ) ) {
data.previousAvgCount[ i ]++;
}
if ( sourceMeta.isInteger() ) {
// Change to number as the exception
//
if ( sum == null ) {
row[ targetIndex ] = null;
} else {
row[ targetIndex ] = new Double( ( (Long) sum ).doubleValue() / data.previousAvgCount[ i ] );
}
} else {
row[ targetIndex ] = ValueDataUtil.divide( targetMeta, sum, data.valueMetaInteger, data.previousAvgCount[ i ] );
}
}
}
示例12: getAggregateResult
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
/**
* Used for junits in GroupByAggregationNullsTest
*
* @return
* @throws KettleValueException
*/
Object[] getAggregateResult() throws KettleValueException {
if ( data.subjectnrs == null ) {
return new Object[ 0 ];
}
Object[] result = new Object[ data.subjectnrs.length ];
for ( int i = 0; i < data.subjectnrs.length; i++ ) {
Object ag = data.agg[ i ];
switch ( meta.getAggregateType()[ i ] ) {
case GroupByMeta.TYPE_GROUP_SUM:
break;
case GroupByMeta.TYPE_GROUP_AVERAGE:
ag =
ValueDataUtil.divide( data.aggMeta.getValueMeta( i ), ag,
new ValueMetaInteger( "c" ), new Long( data.counts[ i ] ) );
break;
case GroupByMeta.TYPE_GROUP_MEDIAN:
case GroupByMeta.TYPE_GROUP_PERCENTILE:
double percentile = 50.0;
if ( meta.getAggregateType()[ i ] == GroupByMeta.TYPE_GROUP_PERCENTILE ) {
percentile = Double.parseDouble( meta.getValueField()[ i ] );
}
@SuppressWarnings( "unchecked" )
List<Double> valuesList = (List<Double>) data.agg[ i ];
double[] values = new double[ valuesList.size() ];
for ( int v = 0; v < values.length; v++ ) {
values[ v ] = valuesList.get( v );
}
ag = new Percentile().evaluate( values, percentile );
break;
case GroupByMeta.TYPE_GROUP_COUNT_ANY:
case GroupByMeta.TYPE_GROUP_COUNT_ALL:
ag = new Long( data.counts[ i ] );
break;
case GroupByMeta.TYPE_GROUP_COUNT_DISTINCT:
break;
case GroupByMeta.TYPE_GROUP_MIN:
break;
case GroupByMeta.TYPE_GROUP_MAX:
break;
case GroupByMeta.TYPE_GROUP_STANDARD_DEVIATION:
if ( ag == null ) {
// PMD-1037 - when all input data is null ag is null, npe on access ag
break;
}
double sum = (Double) ag / data.counts[ i ];
ag = Double.valueOf( Math.sqrt( sum ) );
break;
case GroupByMeta.TYPE_GROUP_CONCAT_COMMA:
case GroupByMeta.TYPE_GROUP_CONCAT_STRING:
ag = ( (StringBuilder) ag ).toString();
break;
default:
break;
}
if ( ag == null && allNullsAreZero ) {
// PDI-10250, 6960 seems all rows for min function was nulls...
// get output subject meta based on original subject meta calculation
ValueMetaInterface vm = data.aggMeta.getValueMeta( i );
ag = ValueDataUtil.getZeroForValueMetaType( vm );
}
result[ i ] = ag;
}
return result;
}
示例13: getAggregateResult
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
/**
* Used for junits in MemoryGroupByAggregationNullsTest
*
* @param aggregate
* @return
* @throws KettleValueException
*/
Object[] getAggregateResult( Aggregate aggregate ) throws KettleValueException {
Object[] result = new Object[data.subjectnrs.length];
if ( data.subjectnrs != null ) {
for ( int i = 0; i < data.subjectnrs.length; i++ ) {
Object ag = aggregate.agg[i];
switch ( meta.getAggregateType()[i] ) {
case MemoryGroupByMeta.TYPE_GROUP_SUM:
break;
case MemoryGroupByMeta.TYPE_GROUP_AVERAGE:
ag = ValueDataUtil.divide(
data.aggMeta.getValueMeta( i ), ag,
new ValueMetaInteger( "c" ), aggregate.counts[i]
);
break;
case MemoryGroupByMeta.TYPE_GROUP_MEDIAN:
case MemoryGroupByMeta.TYPE_GROUP_PERCENTILE:
double percentile = 50.0;
if ( meta.getAggregateType()[i] == MemoryGroupByMeta.TYPE_GROUP_PERCENTILE ) {
percentile = Double.parseDouble( meta.getValueField()[i] );
}
@SuppressWarnings( "unchecked" )
List<Double> valuesList = (List<Double>) aggregate.agg[i];
double[] values = new double[valuesList.size()];
for ( int v = 0; v < values.length; v++ ) {
values[v] = valuesList.get( v );
}
ag = new Percentile().evaluate( values, percentile );
break;
case MemoryGroupByMeta.TYPE_GROUP_COUNT_ANY:
case MemoryGroupByMeta.TYPE_GROUP_COUNT_ALL:
case MemoryGroupByMeta.TYPE_GROUP_COUNT_DISTINCT:
ag = aggregate.counts[i];
break;
case MemoryGroupByMeta.TYPE_GROUP_MIN:
break;
case MemoryGroupByMeta.TYPE_GROUP_MAX:
break;
case MemoryGroupByMeta.TYPE_GROUP_STANDARD_DEVIATION:
double sum = (Double) ag / aggregate.counts[i];
ag = Double.valueOf( Math.sqrt( sum ) );
break;
case MemoryGroupByMeta.TYPE_GROUP_CONCAT_COMMA:
case MemoryGroupByMeta.TYPE_GROUP_CONCAT_STRING:
ag = ( (StringBuilder) ag ).toString();
break;
default:
break;
}
if ( ag == null && allNullsAreZero ) {
// PDI-11530 seems all rows for min function was nulls...
ValueMetaInterface vm = data.aggMeta.getValueMeta( i );
ag = ValueDataUtil.getZeroForValueMetaType( vm );
}
result[i] = ag;
}
}
return result;
}
示例14: getZero
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
private Object getZero( int field ) throws KettleValueException {
ValueMetaInterface vm = data.outputRowMeta.getValueMeta( field );
return ValueDataUtil.getZeroForValueMetaType( vm );
}
示例15: multiply
import org.pentaho.di.core.row.ValueDataUtil; //导入依赖的package包/类
public Value multiply( Value v ) throws KettleValueException {
// a number and a string!
if ( isNull() || v.isNull() ) {
setNull();
return this;
}
if ( ( v.isString() && isNumeric() ) || ( v.isNumeric() && isString() ) ) {
StringBuilder s;
String append = "";
int n;
if ( v.isString() ) {
s = new StringBuilder( v.getString() );
append = v.getString();
n = (int) getInteger();
} else {
s = new StringBuilder( getString() );
append = getString();
n = (int) v.getInteger();
}
if ( n == 0 ) {
s.setLength( 0 );
} else {
for ( int i = 1; i < n; i++ ) {
s.append( append );
}
}
setValue( s );
} else if ( isBigNumber() || v.isBigNumber() ) {
// big numbers
setValue( ValueDataUtil.multiplyBigDecimals( getBigNumber(), v.getBigNumber(), null ) );
} else if ( isNumber() || v.isNumber() ) {
// numbers
setValue( getNumber() * v.getNumber() );
} else if ( isInteger() || v.isInteger() ) {
// integers
setValue( getInteger() * v.getInteger() );
} else {
throw new KettleValueException( "Multiplication can only be done with numbers or a number and a string!" );
}
return this;
}