📄 aggregationsum.java
字号:
/* * @(#)$Id: AggregationSum.java,v 1.9 2005/04/13 20:17:44 huebsch Exp $ * * Copyright (c) 2001-2004 Regents of the University of California. * All rights reserved. * * This file is distributed under the terms in the attached BERKELEY-LICENSE * file. If you do not find these files, copies can be found by writing to: * Computer Science Division, Database Group, Universite of California, * 617 Soda Hall #1776, Berkeley, CA 94720-1776. Attention: Berkeley License * * Copyright (c) 2003-2004 Intel Corporation. All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE file. * If you do not find these files, copies can be found by writing to: * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, * Berkeley, CA, 94704. Attention: Intel License Inquiry. */package pier.helpers.aggregation;import pier.data.DataTypes;import util.network.serialization.GenericByteBuffer;import util.network.serialization.SerializationManager;/** * Class AggregationSum * */public class AggregationSum implements AggregationOperator { public static long serialVersionUID = SerializationManager.getSerialUID( "pier.helpers.aggregation.AggregationSum"); private Object sum; /** * DeSerialize the object from the provided GenericByteBuffer. * * @param inputBuffer */ /** * Constructor AggregationSum * * @param inputBuffer */ public AggregationSum(GenericByteBuffer inputBuffer) { this.sum = SerializationManager.deSerializeExtended(inputBuffer); } /** * Serialize the object into the provided GenericByteBuffer. * * @param outputBuffer * @return */ /** * Method serialize * * @param outputBuffer * @return */ public long serialize(GenericByteBuffer outputBuffer) { SerializationManager.serializeExtended(outputBuffer, sum); return serialVersionUID; } /** * Constructor AggregationSum */ public AggregationSum() { sum = null; } /** * Method addBaseValue * * @param data * @return */ public boolean addBaseValue(Object data) { if (sum == null) { sum = DataTypes.getClone(data); return true; } else { Object oldsum = DataTypes.getClone(sum); sum = DataTypes.add(sum, data); if (DataTypes.compareTo(oldsum, sum) == 0) { return false; } else { return true; } } } /** * Method addPartialResult * * @param data * @return */ public boolean addPartialResult(AggregationOperator data) { return addBaseValue(((AggregationSum) data).sum); } /** * Method result * @return */ public Object result() { return sum; } /** * Method getSize * @return */ public int getSize() { return DataTypes.getSize(sum); } /** * Method hashCode * @return */ public int hashCode() { return sum.hashCode(); } /** * Method equals * * @param other * @return */ public boolean equals(Object other) { return (sum.equals(((AggregationSum) other).sum)); } /** * Method compareTo * * @param o * @return */ public int compareTo(Object o) { return DataTypes.compareTo(sum, ((AggregationSum) o).sum); } /** * Method getClone * @return */ public Object getClone() { AggregationSum newObject = new AggregationSum(); newObject.sum = DataTypes.getClone(sum); return newObject; } /** * Method add * * @param other * @return */ public Object add(Object other) { throw new RuntimeException( "DataTypes: Unsupported data type for adding: " + this.getClass() + " and " + other.getClass()); } /** * Method divide * * @param denominator * @return */ public Object divide(long denominator) { throw new RuntimeException( "DataTypes: Unsupported data type for division: " + this.getClass()); } /** * Method toString * @return */ public String toString() { return new String("AGG-SUM:" + sum); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -