Пример #1
0
 protected override void Cleanup(Mapper.Context context)
 {
     if (checksumCounter != null)
     {
         checksumCounter.Increment(total.GetLow8());
     }
 }
Пример #2
0
        /// <summary>
        /// Generate an ascii record suitable for all sort benchmarks including
        /// PennySort.
        /// </summary>
        internal static void GenerateAsciiRecord(byte[] recBuf, Unsigned16 rand, Unsigned16
                                                 recordNumber)
        {
            /* generate the 10-byte ascii key using mostly the high 64 bits.
             */
            long temp = rand.GetHigh8();

            if (temp < 0)
            {
                // use biginteger to avoid the negative sign problem
                BigInteger bigTemp = MakeBigInteger(temp);
                recBuf[0] = unchecked ((byte)((byte)(' ') + (bigTemp.Mod(NinetyFive))));
                temp      = bigTemp.Divide(NinetyFive);
            }
            else
            {
                recBuf[0] = unchecked ((byte)((byte)(' ') + (temp % 95)));
                temp     /= 95;
            }
            for (int i = 1; i < 8; ++i)
            {
                recBuf[i] = unchecked ((byte)((byte)(' ') + (temp % 95)));
                temp     /= 95;
            }
            temp = rand.GetLow8();
            if (temp < 0)
            {
                BigInteger bigTemp = MakeBigInteger(temp);
                recBuf[8] = unchecked ((byte)((byte)(' ') + (bigTemp.Mod(NinetyFive))));
                temp      = bigTemp.Divide(NinetyFive);
            }
            else
            {
                recBuf[8] = unchecked ((byte)((byte)(' ') + (temp % 95)));
                temp     /= 95;
            }
            recBuf[9] = unchecked ((byte)((byte)(' ') + (temp % 95)));
            /* add 2 bytes of "break" */
            recBuf[10] = (byte)(' ');
            recBuf[11] = (byte)(' ');

            /* convert the 128-bit record number to 32 bits of ascii hexadecimal
             * as the next 32 bytes of the record.
             */
            for (int i_1 = 0; i_1 < 32; i_1++)
            {
                recBuf[12 + i_1] = unchecked ((byte)recordNumber.GetHexDigit(i_1));
            }
            /* add 2 bytes of "break" data */
            recBuf[44] = (byte)(' ');
            recBuf[45] = (byte)(' ');
            /* add 52 bytes of filler based on low 48 bits of random number */
            for (int i_2 = 0; i_2 < 13; ++i_2)
            {
                recBuf[46 + i_2 * 4] = recBuf[47 + i_2 * 4] = recBuf[48 + i_2 * 4] = recBuf[49 +
                                                                                            i_2 * 4] = unchecked ((byte)rand.GetHexDigit(19 + i_2));
            }
            /* add 2 bytes of "break" data */
            recBuf[98] = (byte)('\r');
            /* nice for Windows */
            recBuf[99] = (byte)('\n');
        }