protected override byte[] HashFinal() { h1 ^= length; h2 ^= length; h1 += h2; h2 += h1; h1 = Murmur3a.MixFinal(h1); h2 = Murmur3a.MixFinal(h2); h1 += h2; h2 += h1; var hash = new byte[Murmur3a.READ_SIZE]; Array.Copy(BitConverter.GetBytes(h1), 0, hash, 0, 8); Array.Copy(BitConverter.GetBytes(h2), 0, hash, 8, 8); return(hash); }
/// <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); }