<commit_before>package com.splicemachine.derby.impl.sql.catalog;

import com.splicemachine.derby.impl.load.HdfsImport;
import com.splicemachine.derby.impl.storage.TableSplit;
import com.splicemachine.derby.impl.storage.TempSplit;
import com.splicemachine.derby.utils.SpliceAdmin;
import java.util.List;
import java.util.Map;

import com.splicemachine.derby.utils.TransactionAdmin;
import org.apache.derby.catalog.UUID;
import org.apache.derby.catalog.types.RoutineAliasInfo;
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
import org.apache.derby.iapi.store.access.TransactionController;
import org.apache.derby.impl.sql.catalog.DefaultSystemProcedureGenerator;
import org.apache.derby.impl.sql.catalog.Procedure;

/**
 * @author <NAME>
 *         Created on: 2/28/13
 */
public class SpliceSystemProcedures extends DefaultSystemProcedureGenerator {

	private static final String IMPORT_DATA_NAME = "SYSCS_IMPORT_DATA";
	private static final String XPLAIN_SCHEMA_NAME = "SYSCS_SET_XPLAIN_SCHEMA";
	private static volatile boolean initialized = false;  // Flag to ensure the list of procedures is only initialized once.

	public SpliceSystemProcedures(DataDictionary dictionary) {
		super(dictionary);
	}

    @Override
    protected Map/*<UUID,List<Procedure>*/ getProcedures(DataDictionary dictionary, TransactionController tc) throws StandardException {
        Map sysProcedures =  super.getProcedures(dictionary, tc);

        // Only initialize the list of system procedures once.
        if (initialized) {
        	return sysProcedures;
        }

        // Only one initialization at a time.
        synchronized (this) {

        	// Check if the list was initialized while we were waiting.
        	if (initialized) {
        		return sysProcedures;
        	}

        	// SYS_UTIL schema
        	UUID sysUUID = dictionary.getSystemUtilSchemaDescriptor().getUUID();

        	/*
        	 * Our import process is different than Vanilla Derby's, so find that Procedure in
        	 * the map and replace it with our own Procedure
        	 */
        	for(Object key : sysProcedures.keySet()){
        		@SuppressWarnings("unchecked") List<Procedure> procedures = (List<Procedure>)sysProcedures.get(key);<commit_msg>DB-1233 Fixed double-checked locking to synchronize on the parent class that contains the static lists of sysprocs.<commit_after>package com.splicemachine.derby.impl.sql.catalog;

import com.splicemachine.derby.impl.load.HdfsImport;
import com.splicemachine.derby.impl.storage.TableSplit;
import com.splicemachine.derby.impl.storage.TempSplit;
import com.splicemachine.derby.utils.SpliceAdmin;
import java.util.List;
import java.util.Map;

import com.splicemachine.derby.utils.TransactionAdmin;
import org.apache.derby.catalog.UUID;
import org.apache.derby.catalog.types.RoutineAliasInfo;
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
import org.apache.derby.iapi.store.access.TransactionController;
import org.apache.derby.impl.sql.catalog.DefaultSystemProcedureGenerator;
import org.apache.derby.impl.sql.catalog.Procedure;

/**
 * @author <NAME>
 *         Created on: 2/28/13
 */
public class SpliceSystemProcedures extends DefaultSystemProcedureGenerator {

	private static final String IMPORT_DATA_NAME = "SYSCS_IMPORT_DATA";
	private static final String XPLAIN_SCHEMA_NAME = "SYSCS_SET_XPLAIN_SCHEMA";
	private static volatile boolean initialized = false;  // Flag to ensure the list of procedures is only initialized once.

	public SpliceSystemProcedures(DataDictionary dictionary) {
		super(dictionary);
	}

    @Override
    protected Map/*<UUID,List<Procedure>*/ getProcedures(DataDictionary dictionary, TransactionController tc) throws StandardException {
        Map sysProcedures =  super.getProcedures(dictionary, tc);

        // Only initialize the list of system procedures once.
        if (initialized) {
        	return sysProcedures;
        }

        // Only one initialization at a time.
        // Synchronize on the parent class since the lists of system procedures are all static members of it.
        synchronized (DefaultSystemProcedureGenerator.class) {

        	// Check if the list was initialized while we were waiting.
        	if (initialized) {
        		return sysProcedures;
        	}

        	// SYS_UTIL schema
        	UUID sysUUID = dictionary.getSystemUtilSchemaDescriptor().getUUID();

        	/*
        	 * Our import process is different than Vanilla Derby's, so find that Procedure in
        	 * the map and replace it with our own Procedure
        	 */
        	for(Object key : sysProcedures.keySet()){
        		@SuppressWarnings("unchecked") List<Procedure> procedures = (List<Procedure>)sysProcedures.get(key);
{'fraction_non_alphanumeric': 0.08586799089592385, 'fraction_numerical': 0.0028967515001034555, 'mean_word_length': 3.711500974658869, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6821762', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1403, 'n_words': 340}