Beispiel #1
0
 public override void Read(BinaryStreamBase stream)
 {
     Timestamp     = stream.ReadUInt64();
     PointID       = stream.ReadUInt64();
     TableId       = stream.ReadInt32();
     CollectedTime = stream.ReadUInt64();
 }
Beispiel #2
0
 /// <summary>
 /// Creates a filter by reading from the stream.
 /// </summary>
 /// <param name="stream">the stream to read from</param>
 public SeekToKey(BinaryStreamBase stream)
     : this()
 {
     m_keyToFind.Timestamp = stream.ReadUInt64();
     m_keyToFind.PointID   = stream.ReadUInt64();
     m_keyToFind.CopyTo(StartOfRange);
     m_keyToFind.CopyTo(EndOfRange);
 }
Beispiel #3
0
 /// <summary>
 /// Creates a filter by reading from the stream.
 /// </summary>
 /// <param name="stream">the stream to read from</param>
 public FixedRange(BinaryStreamBase stream)
     : this()
 {
     m_start = stream.ReadUInt64();
     m_stop  = stream.ReadUInt64();
     StartOfRange.SetMin();
     StartOfRange.Timestamp = m_start;
     EndOfRange.SetMax();
     EndOfRange.Timestamp = m_stop;
 }
Beispiel #4
0
 public unsafe override void Decode(BinaryStreamBase stream, AmiKey prevKey, AmiValue prevValue, AmiKey key, AmiValue value, out bool isEndOfStream)
 {
     isEndOfStream       = false;
     key.Timestamp       = stream.ReadUInt64();
     key.PointID         = stream.ReadUInt64();
     value.CollectedTime = stream.ReadUInt64();
     value.TableId       = stream.ReadInt32();
     value.DataLength    = stream.ReadUInt8();
     stream.Read(value.Data, 0, value.DataLength);
 }
            /// <summary>
            /// Creates a filter by reading from the stream.
            /// </summary>
            /// <param name="stream">the stream to read from</param>
            public IntervalRanges(BinaryStreamBase stream)
                : this()
            {
                ulong start        = stream.ReadUInt64();
                ulong stop         = stream.ReadUInt64();
                ulong mainInterval = stream.ReadUInt64();
                ulong subInterval  = stream.ReadUInt64();
                ulong tolerance    = stream.ReadUInt64();

                Initialize(start, stop, mainInterval, subInterval, tolerance);
            }
Beispiel #6
0
 public override void Read(BinaryStreamBase stream)
 {
     CollectedTime = stream.ReadUInt64();
     TableId       = stream.ReadInt32();
     DataLength    = stream.ReadUInt8();
     stream.Read(Data, 0, Data.Length);
 }
Beispiel #7
0
 /// <summary>
 /// Creates a new filter backed by a <see cref="BitArray"/>.
 /// </summary>
 /// <param name="stream">The the stream to load from.</param>
 /// <param name="pointCount">the number of points in the stream.</param>
 /// <param name="maxValue">the maximum value stored in the bit array. Cannot be larger than int.MaxValue-1</param>
 public ULongHashSet(BinaryStreamBase stream, int pointCount, ulong maxValue)
 {
     m_maxValue = maxValue;
     m_points   = new HashSet <ulong>();
     while (pointCount > 0)
     {
         m_points.Add(stream.ReadUInt64());
         pointCount--;
     }
 }
Beispiel #8
0
        private static MatchFilterBase <TKey, TValue> CreateFromStream <TKey, TValue>(BinaryStreamBase stream)
            where TKey : TimestampPointIDBase <TKey>, new()
        {
            MatchFilterBase <TKey, TValue> filter;
            byte  version = stream.ReadUInt8();
            ulong maxValue;
            int   count;

            switch (version)
            {
            case 0:
                return(null);

            case 1:
                maxValue = stream.ReadUInt64();
                count    = stream.ReadInt32();
                if (maxValue < 8 * 1024 * 64)     //64KB of space, 524288
                {
                    filter = new BitArrayFilter <TKey, TValue>(stream, count, maxValue);
                }
                else
                {
                    filter = new UIntHashSet <TKey, TValue>(stream, count, maxValue);
                }
                break;

            case 2:
                maxValue = stream.ReadUInt64();
                count    = stream.ReadInt32();
                filter   = new ULongHashSet <TKey, TValue>(stream, count, maxValue);
                break;

            default:
                throw new VersionNotFoundException("Unknown Version");
            }
            return(filter);
        }
Beispiel #9
0
        public unsafe override void Decode(BinaryStreamBase stream, HistorianKey prevKey, HistorianValue prevValue, HistorianKey key, HistorianValue value, out bool isEndOfStream)
        {
            isEndOfStream = false;
            uint code = stream.ReadUInt8();
            byte b1;
            byte b2;
            byte b3;

            //Compression Stages:
            //  Stage 1: Big Positive Float.
            //  Stage 2: Big Negative Float.
            //  Stage 3: Zero
            //  Stage 4: 32 bit
            //  Stage 5: Catch all

            if (code < 0x80)
            {
                b1 = stream.ReadUInt8();
                b2 = stream.ReadUInt8();
                b3 = stream.ReadUInt8();

                //If stage 1 (50% success)
                key.Timestamp   = prevKey.Timestamp;
                key.PointID     = prevKey.PointID + 1 + ((code >> 4) & 0x7);
                key.EntryNumber = 0;
                value.Value1    = (4u << 28) | (code & 0xF) << 24 | (uint)b1 << 16 | (uint)b2 << 8 | (uint)b3 << 0;
                value.Value2    = 0;
                value.Value3    = 0;
                return;
            }
            if (code < 0xC0)
            {
                b1 = stream.ReadUInt8();
                b2 = stream.ReadUInt8();
                b3 = stream.ReadUInt8();

                //If stage 2 (16% success)
                key.Timestamp   = prevKey.Timestamp;
                key.PointID     = prevKey.PointID + 1 + ((code >> 4) & 0x3);
                key.EntryNumber = 0;
                value.Value1    = (12u << 28) | (code & 0xF) << 24 | (uint)b1 << 16 | (uint)b2 << 8 | (uint)b3 << 0;
                value.Value2    = 0;
                value.Value3    = 0;
                return;
            }
            if (code < 0xD0)
            {
                //If stage 3 (28% success)
                key.Timestamp   = prevKey.Timestamp;
                key.PointID     = prevKey.PointID + 1 + (code & 0xF);
                key.EntryNumber = 0;
                value.Value1    = 0;
                value.Value2    = 0;
                value.Value3    = 0;
                return;
            }
            if (code < 0xE0)
            {
                //If stage 4 (3% success)
                key.Timestamp   = prevKey.Timestamp;
                key.PointID     = prevKey.PointID + 1 + (code & 0xF);
                key.EntryNumber = 0;
                value.Value1    = stream.ReadUInt32();
                value.Value2    = 0;
                value.Value3    = 0;
                return;
            }

            //Stage 5: 2%
            //Stage 5: Catch All
            if ((code & 16) != 0) //T is set
            {
                key.Timestamp = prevKey.Timestamp + stream.Read7BitUInt64();
                key.PointID   = stream.Read7BitUInt64();
            }
            else
            {
                key.Timestamp = prevKey.Timestamp;
                key.PointID   = prevKey.PointID + stream.Read7BitUInt64();
            }


            if ((code & 8) != 0) //E is set)
            {
                key.EntryNumber = stream.Read7BitUInt64();
            }
            else
            {
                key.EntryNumber = 0;
            }

            if ((code & 4) != 0) //V1 is set)
            {
                value.Value1 = stream.ReadUInt64();
            }
            else
            {
                value.Value1 = stream.ReadUInt32();
            }

            if ((code & 2) != 0) //V2 is set)
            {
                value.Value2 = stream.Read7BitUInt64();
            }
            else
            {
                value.Value2 = 0;
            }

            if ((code & 1) != 0) //V3 is set)
            {
                value.Value3 = stream.Read7BitUInt64();
            }
            else
            {
                value.Value3 = 0;
            }
        }
Beispiel #10
0
 public override void Read(BinaryStreamBase stream)
 {
     Timestamp   = stream.ReadUInt64();
     PointID     = stream.ReadUInt64();
     EntryNumber = stream.ReadUInt64();
 }
        public override void Decode(BinaryStreamBase stream, HistorianKey prevKey, HistorianValue prevValue, HistorianKey key, HistorianValue value, out bool isEndOfStream)
        {
            isEndOfStream = false;
            byte code = stream.ReadUInt8();

            if (code == 255)
            {
                isEndOfStream = true;
                return;
            }

            if (code < 128)
            {
                if (code < 64)
                {
                    key.Timestamp   = prevKey.Timestamp;
                    key.PointID     = prevKey.PointID ^ code;
                    key.EntryNumber = 0;
                    value.Value1    = 0;
                    value.Value2    = 0;
                    value.Value3    = 0;
                }
                else
                {
                    key.Timestamp   = prevKey.Timestamp;
                    key.PointID     = prevKey.PointID ^ code ^ 64;
                    key.EntryNumber = 0;
                    value.Value1    = stream.ReadUInt32();
                    value.Value2    = 0;
                    value.Value3    = 0;
                }

                return;
            }

            if ((code & 64) != 0) //T is set
            {
                key.Timestamp = prevKey.Timestamp ^ stream.Read7BitUInt64();
            }
            else
            {
                key.Timestamp = prevKey.Timestamp;
            }

            key.PointID = prevKey.PointID ^ stream.Read7BitUInt64();

            if ((code & 32) != 0) //E is set)
            {
                key.EntryNumber = stream.Read7BitUInt64();
            }
            else
            {
                key.EntryNumber = 0;
            }

            if ((code & 16) != 0) //V1 High is set)
            {
                value.Value1 = stream.ReadUInt64();
            }
            else if ((code & 8) != 0) //V1 low is set)
            {
                value.Value1 = stream.ReadUInt32();
            }
            else
            {
                value.Value1 = 0;
            }

            if ((code & 4) != 0) //V2 is set)
            {
                value.Value2 = stream.ReadUInt64();
            }
            else
            {
                value.Value2 = 0;
            }

            if ((code & 2) != 0) //V1 High is set)
            {
                value.Value3 = stream.ReadUInt64();
            }
            else if ((code & 1) != 0) //V1 low is set)
            {
                value.Value3 = stream.ReadUInt32();
            }
            else
            {
                value.Value3 = 0;
            }

            return;
        }
Beispiel #12
0
 public override void Read(BinaryStreamBase stream)
 {
     Value1 = stream.ReadUInt64();
     Value2 = stream.ReadUInt64();
     Value3 = stream.ReadUInt64();
 }