Exemplo n.º 1
0
        private static void TstDecodeAdvanceToMultiples(long[] values, EliasFanoDecoder efd, long m)
        {
            // test advancing to multiples of m
            Debug.Assert(m > 0);
            long previousValue = -1L;
            long index         = 0;
            long mm            = m;

            efd.ToBeforeSequence();
            foreach (long expValue in values)
            {
                // mm > previousValue
                if (expValue >= mm)
                {
                    long advanceValue = efd.AdvanceToValue(mm);
                    Assert.IsFalse(EliasFanoDecoder.NO_MORE_VALUES == advanceValue, "advanceValue at end too early");
                    Assert.AreEqual(expValue, advanceValue);
                    Assert.AreEqual(index, efd.CurrentIndex());
                    previousValue = expValue;
                    do
                    {
                        mm += m;
                    } while (mm <= previousValue);
                }
                index++;
            }
            long advanceValue_ = efd.AdvanceToValue(mm);

            Assert.AreEqual(EliasFanoDecoder.NO_MORE_VALUES, advanceValue_);
        }
Exemplo n.º 2
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.Decoder;

            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");
        }
Exemplo n.º 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.Decoder;

            Assert.AreEqual(32, efDecVI.AdvanceToValue(22), "advance 22");
        }
Exemplo n.º 4
0
        public virtual void TestExample2a() // 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.Decoder;

            Assert.AreEqual(32, efDecVI.AdvanceToValue(22), "advance 22");
        }
Exemplo n.º 5
0
 private static void TstDecodeAllAdvanceToExpected(long[] values, EliasFanoDecoder efd)
 {
     efd.ToBeforeSequence();
     long previousValue = -1L;
     long index = 0;
     foreach (long expValue in values)
     {
         if (expValue > previousValue)
         {
             long advanceValue = efd.AdvanceToValue(expValue);
             Assert.IsFalse(EliasFanoDecoder.NO_MORE_VALUES == advanceValue, "advanceValue at end too early");
             Assert.AreEqual(expValue, advanceValue);
             Assert.AreEqual(index, efd.CurrentIndex());
             previousValue = expValue;
         }
         index++;
     }
     long advanceValue_ = efd.AdvanceToValue(previousValue + 1);
     Assert.AreEqual(EliasFanoDecoder.NO_MORE_VALUES, advanceValue_, "at end");
 }
Exemplo n.º 6
0
        private static void TstDecodeAllAdvanceToExpected(long[] values, EliasFanoDecoder efd)
        {
            efd.ToBeforeSequence();
            long previousValue = -1L;
            long index         = 0;

            foreach (long expValue in values)
            {
                if (expValue > previousValue)
                {
                    long advanceValue = efd.AdvanceToValue(expValue);
                    Assert.IsFalse(EliasFanoDecoder.NO_MORE_VALUES == advanceValue, "advanceValue at end too early");
                    Assert.AreEqual(expValue, advanceValue);
                    Assert.AreEqual(index, efd.CurrentIndex());
                    previousValue = expValue;
                }
                index++;
            }
            long advanceValue_ = efd.AdvanceToValue(previousValue + 1);

            Assert.AreEqual(EliasFanoDecoder.NO_MORE_VALUES, advanceValue_, "at end");
        }
Exemplo n.º 7
0
 public override int Advance(int target)
 {
     return(SetCurDocID(efDecoder.AdvanceToValue(target)));
 }
Exemplo n.º 8
0
 private static void TstDecodeAdvanceToMultiples(long[] values, EliasFanoDecoder efd, long m)
 {
     // test advancing to multiples of m
     Debug.Assert(m > 0);
     long previousValue = -1L;
     long index = 0;
     long mm = m;
     efd.ToBeforeSequence();
     foreach (long expValue in values)
     {
         // mm > previousValue
         if (expValue >= mm)
         {
             long advanceValue = efd.AdvanceToValue(mm);
             Assert.IsFalse(EliasFanoDecoder.NO_MORE_VALUES == advanceValue, "advanceValue at end too early");
             Assert.AreEqual(expValue, advanceValue);
             Assert.AreEqual(index, efd.CurrentIndex());
             previousValue = expValue;
             do
             {
                 mm += m;
             } while (mm <= previousValue);
         }
         index++;
     }
     long advanceValue_ = efd.AdvanceToValue(mm);
     Assert.AreEqual(EliasFanoDecoder.NO_MORE_VALUES, advanceValue_);
 }