Beispiel #1
0
        public override void Reduce(ByteSlice key, RandomAccessEntries values, RandomAccessOutput output)
        {
            // Value to string and trim spaces.
            for (int i = 0; i != values.Length; i++)
            {
                lbuf.Clear();
                values[i].Value.AppendTo(lbuf);

                string str = Entry.BytesToAscii(lbuf);
                str = str.Trim();

                lbuf.Clear();
                Entry.AsciiToBytesAppend(str, lbuf);

                output.Add(key, ByteSlice.Create(lbuf, 0, lbuf.Count));
            }

            // First 4 bytes of value to integer and increment.
            for (int i = 0; i != values.Length; i++)
            {
                lbuf.Clear();
                for (int bi = 0; bi != 4; bi++)
                {
                    lbuf.Add(values[i].Value[bi]);
                }

                int x = Entry.BytesToInt(lbuf);
                x++;

                lbuf.Clear();
                Entry.ToBytesAppend(x, lbuf);

                output.Add(key, ByteSlice.Create(lbuf));
            }
        }