本文整理汇总了Java中org.pentaho.di.core.row.ValueMetaInterface.compare方法的典型用法代码示例。如果您正苦于以下问题:Java ValueMetaInterface.compare方法的具体用法?Java ValueMetaInterface.compare怎么用?Java ValueMetaInterface.compare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.core.row.ValueMetaInterface
的用法示例。
在下文中一共展示了ValueMetaInterface.compare方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compare
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
/**
* Compare 2 rows of data using the natural keys and indexes specified.
*
* @param o1
* @param o2
* @return
*/
public int compare(Object[] o1, Object[] o2) {
try {
// First compare on the natural keys...
//
int cmp = rowMeta.compare(o1, o2, keyIndexes);
if (cmp!=0) return cmp;
// Then see if the start of the date range of o2 falls between the start and end of o2
//
ValueMetaInterface fromDateMeta = rowMeta.getValueMeta(fromDateIndex);
ValueMetaInterface toDateMeta = rowMeta.getValueMeta(toDateIndex);
Date fromDate = fromDateMeta.getDate(o1[fromDateIndex]);
Date toDate = toDateMeta.getDate(o1[toDateIndex]);
Date lookupDate = fromDateMeta.getDate(o2[fromDateIndex]);
if (toDate!=null) {
int cmpTo = lookupDate.compareTo(toDate);
if (fromDate==null && cmpTo<0) return 0; // match!
int cmpFrom = lookupDate.compareTo(fromDate);
if (fromDate!=null && cmpFrom>=0 && cmpTo<0) return 0; // match
}
return fromDateMeta.compare(o1[fromDateIndex], o2[fromDateIndex]);
}
catch(Exception e) {
throw new RuntimeException(e);
}
}
示例2: 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;
}
}
}