Beispiel #1
0
 public override void Read(BinaryStreamBase stream)
 {
     CollectedTime = stream.ReadUInt64();
     TableId       = stream.ReadInt32();
     DataLength    = stream.ReadUInt8();
     stream.Read(Data, 0, Data.Length);
 }
Beispiel #2
0
        /// <summary>
        /// Loads a <see cref="DatabaseInfo"/> from stream.
        /// </summary>
        /// <param name="stream"></param>
        public DatabaseInfo(BinaryStreamBase stream)
        {
            byte version = stream.ReadUInt8();

            switch (version)
            {
            case 1:
                DatabaseName = stream.ReadString();
                KeyTypeID    = stream.ReadGuid();
                ValueTypeID  = stream.ReadGuid();
                int count = stream.ReadInt32();
                EncodingDefinition[] definitions = new EncodingDefinition[count];
                for (int x = 0; x < count; x++)
                {
                    definitions[x] = new EncodingDefinition(stream);
                }
                SupportedStreamingModes = new ReadOnlyCollection <EncodingDefinition>(definitions);
                KeyType   = Library.GetSortedTreeType(KeyTypeID);
                ValueType = Library.GetSortedTreeType(ValueTypeID);
                break;

            default:
                throw new VersionNotFoundException("Unknown version code.");
            }
        }
Beispiel #3
0
 public override void Read(BinaryStreamBase stream)
 {
     Timestamp     = stream.ReadUInt64();
     PointID       = stream.ReadUInt64();
     TableId       = stream.ReadInt32();
     CollectedTime = stream.ReadUInt64();
 }
        /// <summary>
        /// Loads the header.
        /// </summary>
        public void LoadHeader(BinaryStreamBase stream)
        {
            stream.Position = 0;
            byte version = stream.ReadUInt8();

            if (version == 109)
            {
                stream.Position = 0;
                if (EncodingDefinition.FixedSizeCombinedEncoding != new EncodingDefinition(stream.ReadGuid()))
                {
                    throw new Exception("Header Corrupt");
                }
                if (TreeNodeType != new EncodingDefinition(stream.ReadGuid()))
                {
                    throw new Exception("Header Corrupt");
                }
                if (BlockSize != stream.ReadInt32())
                {
                    throw new Exception("Header Corrupt");
                }
                if (stream.ReadUInt8() != 0)
                {
                    throw new Exception("Header Corrupt");
                }
                LastAllocatedBlock   = stream.ReadUInt32();
                RootNodeIndexAddress = stream.ReadUInt32();
                RootNodeLevel        = stream.ReadUInt8();
            }
            else if (version == 1)
            {
                if (BlockSize != stream.ReadInt32())
                {
                    throw new Exception("Header Corrupt");
                }
                if (TreeNodeType != new EncodingDefinition(stream))
                {
                    throw new Exception("Header Corrupt");
                }
                LastAllocatedBlock   = stream.ReadUInt32();
                RootNodeIndexAddress = stream.ReadUInt32();
                RootNodeLevel        = stream.ReadUInt8();
            }
            else
            {
                throw new VersionNotFoundException();
            }
        }
Beispiel #5
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>
        /// Reads the header data.
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="treeNodeType"></param>
        /// <param name="blockSize"></param>
        internal static void ReadHeader(BinaryStreamBase stream, out EncodingDefinition treeNodeType, out int blockSize)
        {
            stream.Position = 0;
            byte version = stream.ReadUInt8();

            if (version == 109)
            {
                stream.Position = 0;
                stream.ReadGuid();
                treeNodeType = new EncodingDefinition(stream.ReadGuid());
                blockSize    = stream.ReadInt32();
            }
            else if (version == 1)
            {
                blockSize    = stream.ReadInt32();
                treeNodeType = new EncodingDefinition(stream);
            }
            else
            {
                throw new VersionNotFoundException();
            }
        }
Beispiel #7
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 #8
0
 public override void Read(BinaryStreamBase stream)
 {
     Value = stream.ReadInt32();
 }