Example #1
0
 // int run_len = 0;
 public DiffSetRL2_64()
 {
     this.Samples = new List<long> ();
     this.Offsets = new List<long> ();
     this.Stream = new BitStream32 ();
     this.Coder = new EliasDelta64 ();
 }
Example #2
0
 public static BitmapFromList64 GetDiffSet64(short b, IIEncoder64 coder = null)
 {
     return delegate (IList<long> L, long n) {
         var rs = new DiffSet64 ();
         rs.Build (L, n, b, coder);
         return rs;
     };
 }
Example #3
0
 /// <summary>
 /// Saves "coder" to the binary file "Output"
 /// </summary>
 public static void Save(BinaryWriter Output, IIEncoder64 coder)
 {
     var type = coder.GetType ();
     byte idType = 255;
     for (byte i = 0; i < Catalog.Count; i++) {
         if (type == Catalog [i]) {
             idType = i;
             break;
         }
     }
     if (idType == 255) {
         var s = String.Format ("Type {0} is not a recognized IIEncoder64, please add it to " +
             "IntegerEncoderGenericIO.Catalog", type);
         throw new ArgumentException (s);
     }
     Output.Write (idType);
     coder.Save (Output);
 }
Example #4
0
 public override void Load(BinaryReader Input)
 {
     // var POS = R.BaseStream.Position;
     this.N = Input.ReadInt64 ();
     this.M = Input.ReadInt32 ();
     this.B = Input.ReadInt16 ();
     this.Coder = IEncoder64GenericIO.Load (Input);
     int num_samples = this.M / this.B;
     /*if (num_samples > PLAIN_SAMPLES_THRESHOLD) {
         {
             var sa = new SArray64 ();
             sa.Load (Input);
             this.Samples = new SortedListRS64 (sa);
         }
         {
             var sa = new SArray ();
             sa.Load (Input);
             this.Offsets = new SortedListSArray (sa);
         }
     } else {*/
     this.Samples = new List<long>( num_samples );
     this.Offsets = new List<long>( num_samples );
     PrimitiveIO<long>.LoadVector (Input, num_samples, this.Samples);
     PrimitiveIO<long>.LoadVector (Input, num_samples, this.Offsets);
     //}
     // POS = R.BaseStream.Position - POS;
     // Console.WriteLine("=======*******=======>> POS: {0}", POS);
     this.Stream = new BitStream32 ();
     this.Stream.Load (Input);
     //Console.WriteLine ("xxxxxx  load samples.count {0}. N: {1}, M: {2}, B: {3}, BitCount: {4}",
     //	this.Samples.Count, this.N, this.M, this.B, this.Stream.CountBits);
 }
Example #5
0
        /// <summary>
        ///  build methods
        /// </summary>
        public void Build(IEnumerable<long> orderedList, long n, short b, IIEncoder64 coder = null)
        {
            this.N = n;
            this.B = b;
            this.M = 0;
            if (coder == null) {
                coder = new EliasDelta64 ();
            }
            this.Coder = coder;
            long prev = -1;
            var ctx = new BitStreamCtxRL ();

            foreach (var current in orderedList) {
                if (current == 0) {
                    prev = AccStart;
                }
                this.M++;
                long diff = current - prev;
                //Console.WriteLine ("DIFF {0}, num: {1}, current: {2}", diff, this.M, current);
                if (diff == 1) {
                    ++ctx.run_len;
                } else {
                    this.Commit (ctx);
                    // Console.WriteLine ("%%%%%% diff: {0}, prev: {1}, curr: {2}", diff, prev, current);
                    Coder.Encode (this.Stream, diff);
                }
                if ((this.M % this.B) == 0) {
                    this.Commit (ctx);
                    this.Samples.Add (current);
                    this.Offsets.Add (this.Stream.CountBits);
                }
                if (current >= this.N) {
                    this.N = current + 1;
                }
                prev = current;
            }
            this.Commit (ctx);
            /*for (int i = 0; i < this.Samples.Count; i++) {
                Console.WriteLine ("-- i: {0}, samples: {1}, offset: {2}", i, Samples[i], Offsets[i]);
            }*/
        }
Example #6
0
 public void Build(IList<long> orderedList, short b, IIEncoder64 coder = null)
 {
     long n = 0;
     if (orderedList.Count > 0) {
         n = orderedList[orderedList.Count - 1] + 1;
     }
     this.Build (orderedList, n, b, coder);
 }
Example #7
0
 public static SequenceBuilder GetSeqXLB_DiffSetRL64(short t = 16, short b = 127, IIEncoder64 coder = null)
 {
     if (coder == null) {
         coder = new EliasDelta64 ();
     }
     return GetSeqXLB (t, BitmapBuilders.GetDiffSetRL64 (b, coder));
 }
Example #8
0
 public override void Load(BinaryReader Input)
 {
     this.N = Input.ReadInt64 ();
     this.M = Input.ReadInt32 ();
     this.B = Input.ReadInt16 ();
     this.Coder = IEncoder64GenericIO.Load (Input);
     int num_samples = this.M / this.B;
     /*			if (num_samples > 32) {
         {
             var sa = new SArray64 ();
             sa.Load (Input);
             this.Samples = new SortedListRS64 (sa);
         }
         {
             var sa = new SArray ();
             sa.Load (Input);
             this.Offsets = new SortedListSArray (sa);
         }
     } else {*/
         this.Samples = new long[ num_samples ];
         this.Offsets = new long[ num_samples ];
         PrimitiveIO<long>.ReadFromFile (Input, num_samples, this.Samples);
         PrimitiveIO<long>.ReadFromFile (Input, num_samples, this.Offsets);
     //			}
     this.Stream = new BitStream32 ();
     this.Stream.Load (Input);
 }
Example #9
0
 /// <summary>
 ///  build methods
 /// </summary>
 public void Build(IEnumerable<long> orderedList, long n, short b, IIEncoder64 coder = null)
 {
     this.N = n;
     this.B = b;
     this.M = 0;
     if (coder == null) {
         coder = new EliasDelta64 ();
     }
     this.Coder = coder;
     long prev = -1;
     foreach (var current in orderedList) {
         try {
             this.Add (current, prev);
             prev = current;
         } catch (Exception e) {
             Console.WriteLine (e.ToString ());
             Console.WriteLine (e.StackTrace);
             throw e;
         }
     }
     this.Commit ();
 }