<commit_before>/*******************************************************************************
 * Copyright (c) 2004, 2008 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 java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.eclipse.birt.core.framework.FrameworkException;
import org.eclipse.birt.core.framework.IConfigurationElement;
import org.eclipse.birt.core.framework.IExtension;
import org.eclipse.birt.core.framework.IExtensionPoint;
import org.eclipse.birt.core.framework.IExtensionRegistry;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.data.engine.api.aggregation.AggrFunctionWrapper.ParameterDefn;
import org.eclipse.birt.data.engine.core.DataException;
import org.eclipse.birt.data.engine.i18n.DataResourceHandle;
import org.eclipse.birt.data.engine.i18n.ResourceConstants;

/**
 * 
 */

public class AggregationManager
{

	private static final String ELEMENT_AGGREGATION_FACTORY = "AggregationFactory";//$NON-NLS-1$
	private static final String ATTRIBUTE_AGGREGATION_CLASS = "aggregationClass";//$NON-NLS-1$
	private static final String EXTENSION_POINT = "org.eclipse.birt.data.aggregation";//$NON-NLS-1$
	private static final String ELEMENT_AGGREGATIONS = "Aggregations";//$NON-NLS-1$
	private static final String ELEMENT_AGGREGATION = "Aggregation";//$NON-NLS-1$

	private static final String ELEMENT_UIINFO = "UIInfo";//$NON-NLS-1$
	private static final String ATTRIBUTE_PARAMETER_META_INFO = "parameterMetaInfo";//$NON-NLS-1$
	private static final String ATTRIBUTE_TEXT_DATA = "textData";//$NON-NLS-1$

	private static AggregationManager instance;
	public static Map aggrMap;

	// log instance
	private static Logger logger = Logger.getLogger( AggregationManager.class.getName( ) );
	
	/**
	 * allowed aggregation function names in x-tab
	 */
	private static String[] xTabAggrNames = new String[]{
			"SUM",
			"AVE",
			"MAX",
			"MIN",
			"FIRST",
			"LAST",
			"COUNT",
			"COUNTDISTINCT",
			"MEDIAN",
			"MODE",
			"STDDEV",
			"VARIANCE",
			"RANK",
			"RUNNINGSUM"
	};

	public static final int AGGR_TABULAR = 0;
	public static final int AGGR_XTAB = 1;
	public static final int AGGR_MEASURE = 2;

	/**
	 * allowed aggregation function names in cube measure.
	 */
	private static String[] measureAggrNames = new String[]{
			"SUM",//$NON-NLS-1$
			"MAX", //$NON-NLS-1$
			"MIN", //$NON-NLS-1$
			"FIRST", //$NON-NLS-1$
			"LAST", //$NON-NLS-1$
			"COUNT", //$NON-NLS-1$
			"COUNTDISTINCT"//$NON-NLS-1$
	};

	private static List allAggrNames = new ArrayList( );

	/**
	 * Return a shared instance of AggregationManager.
	 * 
	 * @return
	 * @throws DataException
	 */
	public static AggregationManager getInstance( ) throws DataException
	{
		if ( instance == null )
		{
			synchronized ( AggregationManager.class )
			{
				if ( instance == null )
				{
					aggrMap = new HashMap( );
					instance = new AggregationManager( );<commit_msg>Remove Count Distinct from Cube Builder. [47141]<commit_after>/*******************************************************************************
 * Copyright (c) 2004, 2008 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 java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.eclipse.birt.core.framework.FrameworkException;
import org.eclipse.birt.core.framework.IConfigurationElement;
import org.eclipse.birt.core.framework.IExtension;
import org.eclipse.birt.core.framework.IExtensionPoint;
import org.eclipse.birt.core.framework.IExtensionRegistry;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.data.engine.api.aggregation.AggrFunctionWrapper.ParameterDefn;
import org.eclipse.birt.data.engine.core.DataException;
import org.eclipse.birt.data.engine.i18n.DataResourceHandle;
import org.eclipse.birt.data.engine.i18n.ResourceConstants;

/**
 * 
 */

public class AggregationManager
{

	private static final String ELEMENT_AGGREGATION_FACTORY = "AggregationFactory";//$NON-NLS-1$
	private static final String ATTRIBUTE_AGGREGATION_CLASS = "aggregationClass";//$NON-NLS-1$
	private static final String EXTENSION_POINT = "org.eclipse.birt.data.aggregation";//$NON-NLS-1$
	private static final String ELEMENT_AGGREGATIONS = "Aggregations";//$NON-NLS-1$
	private static final String ELEMENT_AGGREGATION = "Aggregation";//$NON-NLS-1$

	private static final String ELEMENT_UIINFO = "UIInfo";//$NON-NLS-1$
	private static final String ATTRIBUTE_PARAMETER_META_INFO = "parameterMetaInfo";//$NON-NLS-1$
	private static final String ATTRIBUTE_TEXT_DATA = "textData";//$NON-NLS-1$

	private static AggregationManager instance;
	public static Map aggrMap;

	// log instance
	private static Logger logger = Logger.getLogger( AggregationManager.class.getName( ) );
	
	/**
	 * allowed aggregation function names in x-tab
	 */
	private static String[] xTabAggrNames = new String[]{
			"SUM",
			"AVE",
			"MAX",
			"MIN",
			"FIRST",
			"LAST",
			"COUNT",
			"COUNTDISTINCT",
			"MEDIAN",
			"MODE",
			"STDDEV",
			"VARIANCE",
			"RANK",
			"RUNNINGSUM"
	};

	public static final int AGGR_TABULAR = 0;
	public static final int AGGR_XTAB = 1;
	public static final int AGGR_MEASURE = 2;

	/**
	 * allowed aggregation function names in cube measure.
	 */
	private static String[] measureAggrNames = new String[]{
			"SUM",//$NON-NLS-1$
			"MAX", //$NON-NLS-1$
			"MIN", //$NON-NLS-1$
			"FIRST", //$NON-NLS-1$
			"LAST", //$NON-NLS-1$
			"COUNT", //$NON-NLS-1$
//			"COUNTDISTINCT"//$NON-NLS-1$	// Temporarily remove count distinct aggregation function. 
	};

	private static List allAggrNames = new ArrayList( );

	/**
	 * Return a shared instance of AggregationManager.
	 * 
	 * @return
	 * @throws DataException
	 */
	public static AggregationManager getInstance( ) throws DataException
	{
		if ( instance == null )
		{
			synchronized ( AggregationManager.class )
			{
				if ( instance == null )
				{
					aggrMap = new HashMap( );
					instance = new AggregationManager( );
{'fraction_non_alphanumeric': 0.16262239250744998, 'fraction_numerical': 0.01035901802185327, 'mean_word_length': 4.327286470143613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5017502', 'n_tokens_mistral': 2433, 'n_tokens_neox': 2192, 'n_words': 514}