1 21 22 package org.apache.derby.impl.sql.execute; 23 24 import org.apache.derby.iapi.services.sanity.SanityManager; 25 import org.apache.derby.iapi.types.NumberDataValue; 26 import org.apache.derby.iapi.error.StandardException; 27 import org.apache.derby.iapi.sql.execute.ExecAggregator; 28 import org.apache.derby.iapi.types.DataValueDescriptor; 29 30 import org.apache.derby.iapi.services.io.StoredFormatIds; 31 32 38 public class SumAggregator 39 extends OrderableAggregator 40 { 41 50 protected void accumulate(DataValueDescriptor addend) 51 throws StandardException 52 { 53 54 58 if (value == null) 59 { 60 63 value = addend.getClone(); 64 } 65 else 66 { 67 NumberDataValue input = (NumberDataValue)addend; 68 NumberDataValue nv = (NumberDataValue) value; 69 70 value = nv.plus( 71 input, nv, nv); } 75 } 76 77 80 public ExecAggregator newAggregator() 81 { 82 return new SumAggregator(); 83 } 84 85 95 public int getTypeFormatId() { return StoredFormatIds.AGG_SUM_V01_ID; } 96 } 97 | Popular Tags |