📄 aggregationcount.java
字号:
/* * @(#)$Id: AggregationCount.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 services.network.Payload;import util.network.serialization.GenericByteBuffer;import util.network.serialization.SerializationManager;/** * Class AggregationCount * */public class AggregationCount implements AggregationOperator { public static long serialVersionUID = SerializationManager.getSerialUID( "pier.helpers.aggregation.AggregationCount"); private long count; /** * DeSerialize the object from the provided GenericByteBuffer. * * @param inputBuffer */ /** * Constructor AggregationCount * * @param inputBuffer */ public AggregationCount(GenericByteBuffer inputBuffer) { this.count = inputBuffer.getLong(); } /** * Serialize the object into the provided GenericByteBuffer. * * @param outputBuffer * @return */ /** * Method serialize * * @param outputBuffer * @return */ public long serialize(GenericByteBuffer outputBuffer) { outputBuffer.putLong(count); return serialVersionUID; } /** * Constructor AggregationCount */ public AggregationCount() { count = 0; } /** * Method addBaseValue * * @param data * @return */ public boolean addBaseValue(Object data) { count++; return true; } /** * Method addPartialResult * * @param data * @return */ public boolean addPartialResult(AggregationOperator data) { long add = ((AggregationCount) data).count; if (add > 0) { count += add; return true; } else { return false; } } /** * Method result * @return */ public Object result() { return new Long(count); } /** * Method getSize * @return */ public int getSize() { return Payload.LONG_SIZE; } /** * Method hashCode * @return */ public int hashCode() { return new Long(count).hashCode(); } /** * Method equals * * @param other * @return */ public boolean equals(Object other) { return (count == (((AggregationCount) other).count)); } /** * Method compareTo * * @param o * @return */ public int compareTo(Object o) { if (count > (((AggregationCount) o).count)) { return 1; } if (count < (((AggregationCount) o).count)) { return -1; } return 0; } /** * Method getClone * @return */ public Object getClone() { AggregationCount newObject = new AggregationCount(); newObject.count = count; return newObject; } /** * Method add * * @param other * @return */ public Object add(Object other) { AggregationCount newObject = new AggregationCount(); newObject.count = count + ((AggregationCount) other).count; return newObject; } /** * Method divide * * @param denominator * @return */ public Object divide(long denominator) { AggregationCount newObject = new AggregationCount(); newObject.count = count / denominator; return newObject; } /** * Method toString * @return */ public String toString() { return new String("AGG-COUNT:" + count); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -