 				if (!array)
 					return NaN;
 				
-				switch (_metadata ? _metadata[ColumnMetadata.AGGREGATION] : null)
-				{
-					default:
-					case Aggregation.FIRST:
-						return array[0];
-					case Aggregation.LAST:
-						return array[array.length - 1];
-					case Aggregation.COUNT:
-						return array.length;
-					case Aggregation.MEAN:
-						return StandardLib.mean(array);
-					case Aggregation.SUM:
-						return StandardLib.sum(array);
-					case Aggregation.MIN:
-						return Math.min.apply(null, array);
-					case Aggregation.MAX:
-						return Math.max.apply(null, array);
-				}
+				return aggregate(array, _metadata);
 			}
 			
 			if (dataType === String)

*/

package weave.data.AttributeColumns
{
	import weave.api.data.Aggregation;
	import weave.api.data.ColumnMetadata;
	import weave.api.data.DataType;
	import weave.api.data.IPrimitiveColumn;
	import weave.api.data.IQualifiedKey;
	import weave.api.reportError;
	import weave.compiler.Compiler;
	import weave.compiler.StandardLib;
	import weave.utils.Dictionary2D;
	
	/**

		{
			return debugId(this) + '{recordCount: '+keys.length+', keyType: "'+getMetadata('keyType')+'", title: "'+getMetadata('title')+'"}';
		}

		public static function aggregate(array:Array, metadata:Object):Number
		{

			switch (metadata ? metadata[ColumnMetadata.AGGREGATION] : null)
			{
				default:
				case Aggregation.FIRST:
					return array[0];
				case Aggregation.LAST:
					return array[array.length - 1];
				case Aggregation.COUNT:
					return array.length;
				case Aggregation.MEAN:
					return StandardLib.mean(array);
				case Aggregation.SUM:
					return StandardLib.sum(array);
				case Aggregation.MIN:
					return Math.min.apply(null, array);
				case Aggregation.MAX:
					return Math.max.apply(null, array);
			}
		}
	}
}
