简体   繁体   中英

SSIS script transformation task taking way to long

I have the following script transformation component.

public class ScriptMain : UserComponent
{
    Regex findCOMMAexp, findAmpersandExp, findANDExp;

    public override void PreExecute()
    {
        base.PreExecute();

        //extract and compress publishers.
        findANDExp = new Regex(@"(\w+\s*)+(?=\band\b)",RegexOptions.Compiled);
        findCOMMAexp = new Regex(@"(\w+\s*)+[,]\s*(\w+\s*)",RegexOptions.Compiled);
        findAmpersandExp = new Regex(@"(\w+\s*)+[&]\s*(\w+\s*)",RegexOptions.Compiled);
    }

    public override void PostExecute()
    {
        base.PostExecute();
    }

    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {        
        Row.CompressedPublisher = compressPublisher(Row.F018Publisher);
    }

    public String compressPublisher(String str)
    {

        Match match;

        if (str.Contains("/"))
        {
            return str.Substring(0, str.IndexOf(('/')));
        }
        else if ((match = findANDExp.Match(str)).Success)
        {
            return match.ToString();
        }
        else if ((match = findCOMMAexp.Match(str)).Success)
        {
            return Regex.Replace(str, ",", "");
        }
        else
        {
            return str;
        }
    }
}

The 3 Regex objects are defined in the main class, initialized in the PreExecute() , and used in a method called by the ProcessInputRow . I have a database source that pulls in a single varchar(45) string, defined as F018Publisher. I stopped this task after 10 mins, while trying to parse 9k entries. What is going wrong?

Thanks.

I wrapped this into a C# commandline app and passed ABCDEFGHIJKLMOPQRSTUVWXYZ01234567890123456789 as a parameter to compressPublisher and it never returned from this check else if ((match = findANDExp.Match(str)).Success)

Same comment posted to twitter as well

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM