Esempio n. 1
0
        public static void BeforeClass()
        {
            Random random = Random();

            INTS              = new int[COUNT];
            LONGS             = new long[COUNT];
            RANDOM_TEST_BYTES = new byte[COUNT * (5 + 4 + 9 + 8)];
            ByteArrayDataOutput bdo = new ByteArrayDataOutput(RANDOM_TEST_BYTES);

            for (int i = 0; i < COUNT; i++)
            {
                int i1 = INTS[i] = random.Next();
                bdo.WriteVInt(i1);
                bdo.WriteInt(i1);

                long l1;
                if (Rarely())
                {
                    // a long with lots of zeroes at the end
                    l1 = LONGS[i] = TestUtil.NextLong(random, 0, int.MaxValue) << 32;
                }
                else
                {
                    l1 = LONGS[i] = TestUtil.NextLong(random, 0, long.MaxValue);
                }
                bdo.WriteVLong(l1);
                bdo.WriteLong(l1);
            }
        }
            // encodes count values to buffer
            internal virtual void EncodeValues(int count)
            {
                @out.Reset((byte[])(Array)Buffer);
                long lastOrd = 0;

                for (int i = 0; i < count; i++)
                {
                    Ords.MoveNext();
                    long ord = Ords.Current;
                    @out.WriteVLong(ord - lastOrd);
                    lastOrd = ord;
                }
            }