Bug 131186 Enhance birt.data.aggregation extension point to support multipass
The current org.eclipse.birt.data.aggregation extension point ( and associated org.eclipse.birt.data.engine.api.aggregation classes) can only support single-pass aggregates. We need to extend this framework to support custom multi-pass aggregates. One example: a percentage-to-total aggregate ( x/SUM(x) ) will require two passes over the series. A prelimary design of the new extension point: Introduce a new Aggregation abstract class in birt.data.engine.api: public abstract class Aggregation implements IAggregation { /** Returns the number of passes over the data series that the accumulator of this aggregate requires. For SUMMARY aggregates, the accumulator returns a value after all passes are complete. For RUNNING aggregates, the accumulator returns data in the last pass. */ public int getNumberOfPasses() { return 1; } } The Accumulator class can remain as is. However the comment to indicate that for multipass aggregates, start() and finish() will be called at the beginning and end of each pass. The aggregation extension point's aggregateClass element should indicate that the class needs to subclass Aggregation. Also, this element's kind should be changed to "java" and its "Based On" changed to "org.eclipse.birt.data.engine.api.aggregation.Aggregation".
data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/api/aggregation/Accumulator.java
/*
 *************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *  
 *************************************************************************
 */ 
package org.eclipse.birt.data.engine.api.aggregation;
import org.eclipse.birt.data.engine.core.DataException;
/**
 * The Accumulator class calculates values for its associated Aggregation. Calculation of 
 * aggregate values in BIRT is iteration-driven. The data engine make a pass over the range of
 * data rows on which an aggregation is defined, and passes the values calculated on each row to
 * the Accumulator to process. There are 3 steps involved in calculating an aggregate value: