예제 #1
0
        /// <summary>
        /// Populates the OutputColumn class with all the required information to generate Hash's.
        /// </summary>
        /// <param name="bufferManager">The buffermanager that is affected by this</param>
        /// <param name="output">The output to find the column in</param>
        /// <param name="input">The input where all the data comes from</param>
        /// <param name="outputColumnIndex">The Column Index of the output column.</param>
        public void AddColumnInformation(IDTSBufferManager bufferManager, IDTSOutput output, IDTSInput input, int outputColumnIndex)
        {
            if (bufferManager == null)
            {
                throw new ArgumentNullException("bufferManager");
            }

            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (output == null)
            {
                throw new ArgumentNullException("output");
            }

            IDTSOutputColumn outputColumn = output.OutputColumnCollection[outputColumnIndex];

            string[] inputLineageIDList;
            inputLineageIDList  = outputColumn.CustomPropertyCollection[Utility.InputColumnLineagePropName].Value.ToString().Split(',');
            this.outputHashType = (MultipleHash.HashTypeEnumerator)outputColumn.CustomPropertyCollection[Utility.HashTypePropName].Value;
            this.outputDataType = (MultipleHash.OutputTypeEnumerator)outputColumn.CustomPropertyCollection[Utility.OutputColumnOutputTypePropName].Value;

            switch (this.outputHashType)
            {
            case MultipleHash.HashTypeEnumerator.None:
                break;

            case MultipleHash.HashTypeEnumerator.MD5:
                this.hashMD5 = MD5.Create();
                break;

            case MultipleHash.HashTypeEnumerator.RipeMD160:
                this.hashRipeMD160 = RIPEMD160.Create();
                break;

            case MultipleHash.HashTypeEnumerator.SHA1:
                this.hashSHA1 = SHA1.Create();
                break;

            case MultipleHash.HashTypeEnumerator.SHA256:
                this.hashSHA256 = SHA256.Create();
                break;

            case MultipleHash.HashTypeEnumerator.SHA384:
                this.hashSHA384 = SHA384.Create();
                break;

            case MultipleHash.HashTypeEnumerator.SHA512:
                this.hashSHA512 = SHA512.Create();
                break;

            case MultipleHash.HashTypeEnumerator.CRC32:
                this.hashCRC32 = CRC32.Create();
                break;

            case MultipleHash.HashTypeEnumerator.CRC32C:
                this.hashCRC32C = CRC32C.Create();
                break;

            case MultipleHash.HashTypeEnumerator.FNV1a32:
                this.hashFNV1a32 = FNV1a32.Create();
                break;

            case MultipleHash.HashTypeEnumerator.FNV1a64:
                this.hashFNV1a64 = FNV1a64.Create();
                break;

            case MultipleHash.HashTypeEnumerator.MurmurHash3a:
                //ToDo: Call the MurmurHash
                this.hashMurmur3a = Murmur3a.Create();
                break;

            case MultipleHash.HashTypeEnumerator.xxHash:
                // todo: call the xxHash
                this.hashxxHash = xxHash.Create();
                break;

            default:
                break;
            }

            // Store all the input column ID's for the column's to be Hashed
            int inputColumnLineageID;

            foreach (string inputLineageID in inputLineageIDList)
            {
                int columnId = System.Convert.ToInt32(inputLineageID.Substring(1));
                Microsoft.SqlServer.Dts.Pipeline.Wrapper.DTP_BUFFCOL columnData = new Microsoft.SqlServer.Dts.Pipeline.Wrapper.DTP_BUFFCOL();
                inputColumnLineageID = bufferManager.FindColumnByLineageID(input.Buffer, columnId);  // Strip the # from the ID

                bufferManager.GetColumnInfo(input.Buffer, inputColumnLineageID, ref columnData);
                MHashColumnInformation inputColumn = new MHashColumnInformation(inputColumnLineageID, columnData.DataType);
                this.inputColumnDetails.Add(inputColumn);
            }

            // Store the Column ID for the Output Column
            this.outputColumnID = bufferManager.FindColumnByLineageID(input.Buffer, outputColumn.LineageID);
        }
예제 #2
0
        /// <summary>
        /// Configures the output column to the correct data type and length.
        /// </summary>
        /// <param name="propertyValue">The type of output that is to be produced</param>
        /// <param name="outputColumn">The column to configure</param>
        public static void SetOutputColumnDataType(MultipleHash.HashTypeEnumerator propertyValue, MultipleHash.OutputTypeEnumerator dataTypeValue, IDTSOutputColumn outputColumn)
        {
            switch (dataTypeValue)
            {
            case MultipleHash.OutputTypeEnumerator.HexString:
                switch (propertyValue)
                {
                case MultipleHash.HashTypeEnumerator.None:
                case MultipleHash.HashTypeEnumerator.MD5:
                case MultipleHash.HashTypeEnumerator.MurmurHash3a:
                    outputColumn.SetDataTypeProperties(DataType.DT_STR, 34, 0, 0, 1252);
                    break;

                case MultipleHash.HashTypeEnumerator.RipeMD160:
                case MultipleHash.HashTypeEnumerator.SHA1:
                    outputColumn.SetDataTypeProperties(DataType.DT_STR, 42, 0, 0, 1252);
                    break;

                case MultipleHash.HashTypeEnumerator.SHA256:
                    outputColumn.SetDataTypeProperties(DataType.DT_STR, 66, 0, 0, 1252);
                    break;

                case MultipleHash.HashTypeEnumerator.SHA384:
                    outputColumn.SetDataTypeProperties(DataType.DT_STR, 98, 0, 0, 1252);
                    break;

                case MultipleHash.HashTypeEnumerator.SHA512:
                    outputColumn.SetDataTypeProperties(DataType.DT_STR, 130, 0, 0, 1252);
                    break;

                case MultipleHash.HashTypeEnumerator.CRC32:
                case MultipleHash.HashTypeEnumerator.CRC32C:
                case MultipleHash.HashTypeEnumerator.FNV1a32:
                    outputColumn.SetDataTypeProperties(DataType.DT_STR, 10, 0, 0, 1252);
                    break;

                case MultipleHash.HashTypeEnumerator.FNV1a64:
                case MultipleHash.HashTypeEnumerator.xxHash:
                    outputColumn.SetDataTypeProperties(DataType.DT_STR, 18, 0, 0, 1252);
                    break;
                }
                break;

            case MultipleHash.OutputTypeEnumerator.Base64String:
                switch (propertyValue)
                {
                case MultipleHash.HashTypeEnumerator.None:
                case MultipleHash.HashTypeEnumerator.MD5:
                case MultipleHash.HashTypeEnumerator.MurmurHash3a:
                    outputColumn.SetDataTypeProperties(DataType.DT_STR, 24, 0, 0, 1252);
                    break;

                case MultipleHash.HashTypeEnumerator.RipeMD160:
                case MultipleHash.HashTypeEnumerator.SHA1:
                    outputColumn.SetDataTypeProperties(DataType.DT_STR, 28, 0, 0, 1252);
                    break;

                case MultipleHash.HashTypeEnumerator.SHA256:
                    outputColumn.SetDataTypeProperties(DataType.DT_STR, 44, 0, 0, 1252);
                    break;

                case MultipleHash.HashTypeEnumerator.SHA384:
                    outputColumn.SetDataTypeProperties(DataType.DT_STR, 64, 0, 0, 1252);
                    break;

                case MultipleHash.HashTypeEnumerator.SHA512:
                    outputColumn.SetDataTypeProperties(DataType.DT_STR, 88, 0, 0, 1252);
                    break;

                case MultipleHash.HashTypeEnumerator.CRC32:
                case MultipleHash.HashTypeEnumerator.CRC32C:
                case MultipleHash.HashTypeEnumerator.FNV1a32:
                    outputColumn.SetDataTypeProperties(DataType.DT_STR, 8, 0, 0, 1252);
                    break;

                case MultipleHash.HashTypeEnumerator.FNV1a64:
                case MultipleHash.HashTypeEnumerator.xxHash:
                    outputColumn.SetDataTypeProperties(DataType.DT_STR, 12, 0, 0, 1252);
                    break;
                }
                break;

            case MultipleHash.OutputTypeEnumerator.Binary:
            default:
                switch (propertyValue)
                {
                case MultipleHash.HashTypeEnumerator.None:
                case MultipleHash.HashTypeEnumerator.MD5:
                case MultipleHash.HashTypeEnumerator.MurmurHash3a:
                    outputColumn.SetDataTypeProperties(DataType.DT_BYTES, 16, 0, 0, 0);
                    break;

                case MultipleHash.HashTypeEnumerator.RipeMD160:
                case MultipleHash.HashTypeEnumerator.SHA1:
                    outputColumn.SetDataTypeProperties(DataType.DT_BYTES, 20, 0, 0, 0);
                    break;

                case MultipleHash.HashTypeEnumerator.SHA256:
                    outputColumn.SetDataTypeProperties(DataType.DT_BYTES, 32, 0, 0, 0);
                    break;

                case MultipleHash.HashTypeEnumerator.SHA384:
                    outputColumn.SetDataTypeProperties(DataType.DT_BYTES, 48, 0, 0, 0);
                    break;

                case MultipleHash.HashTypeEnumerator.SHA512:
                    outputColumn.SetDataTypeProperties(DataType.DT_BYTES, 64, 0, 0, 0);
                    break;

                case MultipleHash.HashTypeEnumerator.CRC32:
                case MultipleHash.HashTypeEnumerator.CRC32C:
                case MultipleHash.HashTypeEnumerator.FNV1a32:
                    outputColumn.SetDataTypeProperties(DataType.DT_BYTES, 4, 0, 0, 0);
                    break;

                case MultipleHash.HashTypeEnumerator.FNV1a64:
                case MultipleHash.HashTypeEnumerator.xxHash:
                    outputColumn.SetDataTypeProperties(DataType.DT_BYTES, 8, 0, 0, 0);
                    break;
                }
                break;
            }
        }