Example #1
0
        private static void TstEFSadvanceToAndBackToMultiples(long[] values, long maxValue, long minAdvanceMultiple)
        {
            EliasFanoEncoder efEncoder = MakeEncoder(values, EliasFanoEncoder.DEFAULT_INDEX_INTERVAL);

            for (long m = minAdvanceMultiple; m <= maxValue; m += 1)
            {
                TstDecodeAdvanceToMultiples(values, efEncoder.GetDecoder(), m);
                TstDecodeBackToMultiples(values, efEncoder.GetDecoder(), m);
            }
        }
Example #2
0
        public virtual void TestIndexAdvanceToFirst()
        {
            long indexInterval = 2;

            long[]           twoLongs   = new long[] { 0, 2 };
            long[]           indexLongs = new long[] { 3 }; // high bits 1001
            EliasFanoEncoder efEncVI    = TstEFVI(twoLongs, indexInterval, indexLongs);

            Assert.AreEqual(0, efEncVI.GetDecoder().AdvanceToValue(0));
        }
Example #3
0
        public virtual void TestExample2NoIndex1() // Figure 2 from Vigna 2012 paper, no index, test broadword selection.
        {
            long indexInterval = 16;

            long[]           values     = new long[] { 5, 8, 8, 15, 32 }; // two low bits, high values 1,2,2,3,8.
            long[]           indexLongs = new long[0];                    // high bits 0b 0001 0000 0101 1010
            EliasFanoEncoder efEncVI    = TstEFVI(values, indexInterval, indexLongs);
            EliasFanoDecoder efDecVI    = efEncVI.GetDecoder();

            Assert.AreEqual(32, efDecVI.AdvanceToValue(22), "advance 22");
        }
Example #4
0
        public virtual void TestExample2b() // Figure 2 from Vigna 2012 paper
        {
            long indexInterval = 4;

            long[]           values     = new long[] { 5, 8, 8, 15, 32 }; // two low bits, high values 1,2,2,3,8.
            long[]           indexLongs = new long[] { 8 + 12 * 16 };     // high bits 0b 0001 0000 0101 1010
            EliasFanoEncoder efEncVI    = TstEFVI(values, indexInterval, indexLongs);
            EliasFanoDecoder efDecVI    = efEncVI.GetDecoder();

            Assert.AreEqual(5, efDecVI.NextValue(), "initial next");
            Assert.AreEqual(32, efDecVI.AdvanceToValue(22), "advance 22");
        }
Example #5
0
        public virtual void TestTwoIndexEntries()
        {
            long indexInterval = 2;

            long[]           twoLongs   = new long[] { 0, 1, 2, 3, 4, 5 };
            long[]           indexLongs = new long[] { 4 + 8 * 16 }; // high bits 0b10101010101
            EliasFanoEncoder efEncVI    = TstEFVI(twoLongs, indexInterval, indexLongs);
            EliasFanoDecoder efDecVI    = efEncVI.GetDecoder();

            Assert.AreEqual(0, efDecVI.AdvanceToValue(0), "advance 0");
            Assert.AreEqual(5, efDecVI.AdvanceToValue(5), "advance 5");
            Assert.AreEqual(EliasFanoDecoder.NO_MORE_VALUES, efDecVI.AdvanceToValue(5), "advance 6");
        }
Example #6
0
 private static void TstDecodeAll(EliasFanoEncoder efEncoder, long[] values)
 {
     TstDecodeAllNext(values, efEncoder.GetDecoder());
     TstDecodeAllPrev(values, efEncoder.GetDecoder());
     TstDecodeAllAdvanceToExpected(values, efEncoder.GetDecoder());
 }