本文整理汇总了Java中org.pentaho.di.core.row.ValueDataUtil.divide方法的典型用法代码示例。如果您正苦于以下问题:Java ValueDataUtil.divide方法的具体用法?Java ValueDataUtil.divide怎么用?Java ValueDataUtil.divide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.core.row.ValueDataUtil
的用法示例。
在下文中一共展示了ValueDataUtil.divide方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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]);
}
}
}
示例6: 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 ] );
}
}
}
示例7: 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;
}
示例8: 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;
}