Beispiel #1
0
 public override void Write(BinaryStreamBase stream)
 {
     stream.Write(CollectedTime);
     stream.Write(TableId);
     stream.Write(DataLength);
     stream.Write(Data, 0, Data.Length);
 }
Beispiel #2
0
 public override void Write(BinaryStreamBase stream)
 {
     stream.Write(Timestamp);
     stream.Write(PointID);
     stream.Write(TableId);
     stream.Write(CollectedTime);
 }
Beispiel #3
0
 /// <summary>
 /// Writes this data to the <see cref="stream"/>.
 /// </summary>
 /// <param name="stream">the stream to write data to</param>
 public void Save(BinaryStreamBase stream)
 {
     stream.Write((byte)0);
     stream.Write(Timeout.Ticks);
     stream.Write(MaxReturnedCount);
     stream.Write(MaxScanCount);
     stream.Write(MaxSeekCount);
 }
Beispiel #4
0
 public override void Save(BinaryStreamBase stream)
 {
     stream.Write((byte)1); //Stored as array of uint[]
     stream.Write(m_maxValue);
     stream.Write(m_points.Count);
     foreach (uint x in m_points)
     {
         stream.Write(x);
     }
 }
Beispiel #5
0
 public override void Save(BinaryStreamBase stream)
 {
     stream.Write((byte)1); //Stored as array of uint[]
     stream.Write(MaxValue);
     stream.Write(m_points.SetCount);
     foreach (int x in m_points.GetAllSetBits())
     {
         stream.Write((uint)x);
     }
 }
Beispiel #6
0
 /// <summary>
 /// Writes the end of the stream symbol to the <see cref="stream"/>.
 /// </summary>
 /// <param name="stream">the stream to write to</param>
 public override void WriteEndOfStream(BinaryStreamBase stream)
 {
     if (m_encoding.ContainsEndOfStreamSymbol)
     {
         stream.Write(m_encoding.EndOfStreamSymbol);
     }
     else
     {
         stream.Write((byte)0);
     }
 }
Beispiel #7
0
 public void Save(BinaryStreamBase stream)
 {
     stream.Write((byte)1);
     stream.Write(DatabaseName);
     stream.Write(KeyTypeID);
     stream.Write(ValueTypeID);
     stream.Write(SupportedStreamingModes.Count);
     foreach (EncodingDefinition encoding in SupportedStreamingModes)
     {
         encoding.Save(stream);
     }
 }
 /// <summary>
 /// Serializes the <see cref="EncodingDefinition"/> to the provided <see cref="stream"/>
 /// </summary>
 /// <param name="stream">the stream to write to</param>
 public void Save(BinaryStreamBase stream)
 {
     if (IsKeyValueEncoded)
     {
         stream.Write((byte)1);
         stream.Write(KeyValueEncodingMethod);
     }
     else
     {
         stream.Write((byte)2);
         stream.Write(KeyEncodingMethod);
         stream.Write(ValueEncodingMethod);
     }
 }
        private static void SelfTest()
        {
            UnmanagedMemoryStream ms1 = new UnmanagedMemoryStream();
            BinaryStreamBase      ms  = ms1.CreateBinaryStream();
            Random rand = new Random();
            int    seed = rand.Next();

            rand = new Random(seed);
            byte[] data = new byte[255];
            rand.NextBytes(data);

            while (ms.Position < 1000000)
            {
                ms.Write(data, 0, rand.Next(256));
            }

            byte[] data2 = new byte[255];
            rand = new Random(seed);
            rand.NextBytes(data2);
            ms.Position = 0;
            Compare(data, data2, 255);
            while (ms.Position < 1000000)
            {
                int length = rand.Next(256);
                ms.ReadAll(data2, 0, length);
                Compare(data, data2, length);
            }
            ms.Dispose();
            ms1.Dispose();
        }
Beispiel #10
0
        public unsafe override void Encode(BinaryStreamBase stream, HistorianKey prevKey, HistorianValue prevValue, HistorianKey key, HistorianValue value)
        {
            byte *ptr    = stackalloc byte[MaxCompressionSize];
            int   length = Encode(ptr, prevKey, prevValue, key, value);

            stream.Write(ptr, length);
        }
Beispiel #11
0
 /// <summary>
 /// Encodes the current key/value to the stream.
 /// </summary>
 /// <param name="stream">the stream to write to</param>
 /// <param name="currentKey">the key to write</param>
 /// <param name="currentValue">the value to write</param>
 public override void Encode(BinaryStreamBase stream, TKey currentKey, TValue currentValue)
 {
     if (!m_encoding.ContainsEndOfStreamSymbol)
     {
         stream.Write((byte)1);
     }
     m_encoding.Encode(stream, m_prevKey, m_prevValue, currentKey, currentValue);
     currentKey.CopyTo(m_prevKey);
     currentValue.CopyTo(m_prevValue);
 }
        /// <summary>
        /// Writes the first page of the SortedTree as long as the <see cref="IsDirty"/> flag is set.
        /// After returning, the IsDirty flag is cleared.
        /// </summary>
        public void SaveHeader(BinaryStreamBase stream)
        {
            if (!IsDirty)
            {
                return;
            }
            long oldPosotion = stream.Position;

            stream.Position = 0;
            stream.Write((byte)1);
            stream.Write(BlockSize);
            TreeNodeType.Save(stream);
            stream.Write(LastAllocatedBlock);
            stream.Write(RootNodeIndexAddress); //Root Index
            stream.Write(RootNodeLevel);        //Root Index

            stream.Position = oldPosotion;
            m_isDirty       = false;
        }
Beispiel #13
0
 public unsafe override void Encode(BinaryStreamBase stream, AmiKey prevKey, AmiValue prevValue, AmiKey key, AmiValue value)
 {
     stream.Write(key.Timestamp);
     stream.Write(key.PointID);
     stream.Write(value.CollectedTime);
     stream.Write(value.TableId);
     stream.Write(value.DataLength);
     stream.Write(value.Data, 0, value.DataLength);
 }
 /// <summary>
 /// Serializes the filter to a stream
 /// </summary>
 /// <param name="stream">the stream to write to</param>
 public override void Save(BinaryStreamBase stream)
 {
     stream.Write((byte)2); //Stored with interval data
     stream.Write(m_start);
     stream.Write(m_stop);
     stream.Write(m_mainInterval);
     stream.Write(m_subInterval);
     stream.Write(m_tolerance);
 }
Beispiel #15
0
 public override void Write(BinaryStreamBase stream)
 {
     stream.Write(Timestamp);
     stream.Write(PointID);
     stream.Write(EntryNumber);
 }
Beispiel #16
0
 public override void Write(BinaryStreamBase stream)
 {
     stream.Write(Value);
 }
        public unsafe override void Encode(BinaryStreamBase stream, HistorianKey prevKey, HistorianValue prevValue, HistorianKey currentKey, HistorianValue currentValue)
        {
            if (currentKey.Timestamp == prevKey.Timestamp &&
                ((currentKey.PointID ^ prevKey.PointID) < 64) &&
                currentKey.EntryNumber == 0 &&
                currentValue.Value1 <= uint.MaxValue && //must be a 32-bit value
                currentValue.Value2 == 0 &&
                currentValue.Value3 == 0)
            {
                if (currentValue.Value1 == 0)
                {
                    stream.Write((byte)((currentKey.PointID ^ prevKey.PointID)));
                }
                else
                {
                    stream.Write((byte)((currentKey.PointID ^ prevKey.PointID) | 64));
                    stream.Write((uint)currentValue.Value1);
                }
                return;
            }

            byte code = 128;

            if (currentKey.Timestamp != prevKey.Timestamp)
            {
                code |= 64;
            }

            if (currentKey.EntryNumber != 0)
            {
                code |= 32;
            }

            if (currentValue.Value1 > uint.MaxValue)
            {
                code |= 16;
            }
            else if (currentValue.Value1 > 0)
            {
                code |= 8;
            }

            if (currentValue.Value2 != 0)
            {
                code |= 4;
            }

            if (currentValue.Value3 > uint.MaxValue)
            {
                code |= 2;
            }
            else if (currentValue.Value3 > 0)
            {
                code |= 1;
            }

            stream.Write(code);

            if (currentKey.Timestamp != prevKey.Timestamp)
            {
                stream.Write7Bit(currentKey.Timestamp ^ prevKey.Timestamp);
            }

            stream.Write7Bit(currentKey.PointID ^ prevKey.PointID);

            if (currentKey.EntryNumber != 0)
            {
                stream.Write7Bit(currentKey.EntryNumber);
            }

            if (currentValue.Value1 > uint.MaxValue)
            {
                stream.Write(currentValue.Value1);
            }
            else if (currentValue.Value1 > 0)
            {
                stream.Write((uint)currentValue.Value1);
            }

            if (currentValue.Value2 != 0)
            {
                stream.Write(currentValue.Value2);
            }

            if (currentValue.Value3 > uint.MaxValue)
            {
                stream.Write(currentValue.Value3);
            }
            else if (currentValue.Value3 > 0)
            {
                stream.Write((uint)currentValue.Value3);
            }
        }
Beispiel #18
0
 /// <summary>
 /// Serializes the filter to a stream
 /// </summary>
 /// <param name="stream">the stream to write to</param>
 public override void Save(BinaryStreamBase stream)
 {
     stream.Write(m_keyToFind.Timestamp);
     stream.Write(m_keyToFind.PointID);
 }
Beispiel #19
0
 /// <summary>
 /// Serializes the filter to a stream
 /// </summary>
 /// <param name="stream">the stream to write to</param>
 public override void Save(BinaryStreamBase stream)
 {
     stream.Write((byte)1); //stored as start/stop
     stream.Write(m_start);
     stream.Write(m_stop);
 }