Ejemplo n.º 1
0
    public LogEvent ReadLogEvent(ExtendedBinaryReader reader)
    {
        var evt = new LogEvent
        {
            TransactionId        = GetTextById(reader.Read7BitEncodedInt()),
            Text                 = reader.ReadString(),
            Severity             = (LogSeverity)reader.ReadByte(),
            ProcessInvocationUID = reader.ReadNullableInt32()
        };

        var argCount = reader.Read7BitEncodedInt();

        if (argCount > 0)
        {
            evt.Arguments = new KeyValuePair <string, object> [argCount];
            for (var i = 0; i < argCount; i++)
            {
                var key   = GetTextById(reader.Read7BitEncodedInt());
                var value = reader.ReadObject();
                evt.Arguments[i] = new KeyValuePair <string, object>(key, value);
            }
        }

        return(evt);
    }
Ejemplo n.º 2
0
 public static RowOwnerChangedEvent ReadRowOwnerChangedEvent(ExtendedBinaryReader reader)
 {
     return(new RowOwnerChangedEvent
     {
         RowUid = reader.Read7BitEncodedInt(),
         PreviousProcessInvocationUid = reader.Read7BitEncodedInt(),
         NewProcessInvocationUid = reader.ReadNullableInt32()
     });
 }
Ejemplo n.º 3
0
    public SinkStartedEvent ReadSinkStartedEvent(ExtendedBinaryReader reader)
    {
        var evt = new SinkStartedEvent
        {
            UID      = reader.Read7BitEncodedInt(),
            Location = GetTextById(reader.Read7BitEncodedInt()),
            Path     = GetTextById(reader.Read7BitEncodedInt()),
        };

        return(evt);
    }
Ejemplo n.º 4
0
        public Type ReadType(ExtendedBinaryReader reader)
        {
            int count       = reader.Read7BitEncodedInt();
            var identifiers = new int[count];

            for (var i = 0; i < count; i++)
            {
                identifiers[i] = reader.Read7BitEncodedInt();
            }

            var queue = new Queue <int>(identifiers);

            return(DecodeTypeRecursive(queue));
        }
Ejemplo n.º 5
0
 public static ProcessInvocationStartEvent ReadProcessInvocationStartEvent(ExtendedBinaryReader reader)
 {
     return(new ProcessInvocationStartEvent
     {
         InvocationUID = reader.Read7BitEncodedInt(),
         InstanceUID = reader.Read7BitEncodedInt(),
         InvocationCounter = reader.Read7BitEncodedInt(),
         Type = reader.ReadString(),
         Kind = reader.ReadNullableString(),
         Name = reader.ReadString(),
         Topic = reader.ReadNullableString(),
         CallerInvocationUID = reader.ReadNullableInt32()
     });
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Reads a list of nodes from the underlying stream, where the number of
        /// nodes is determined by the LEB128 encoded integer prefix.
        /// </summary>
        /// <param name="reader">Reader used for reading from the underlying stream.</param>
        public override void ReadValue(ExtendedBinaryReader reader)
        {
            var count = reader.Read7BitEncodedInt();

            for (var i = 0; i < count; i++)
            {
                var type = (BsfType)reader.ReadByte();

                if (type == BsfType.Null)
                {
                    _list.Add(null);
                }
                else
                {
                    if (ElementType == BsfType.Null)
                    {
                        ElementType = type;
                    }

                    if (type != ElementType)
                    {
                        throw new InvalidOperationException($"List contains elements of both type '{ElementType}' and '{type}");
                    }

                    var node = Create(ElementType);
                    node.ReadValue(reader);
                    _list.Add(node);
                }
            }
        }
        public sealed override void Read(ExtendedBinaryReader reader)
        {
            SubscribeToEndRead();
            var commandCount = reader.Read7BitEncodedInt();

            for (var i = 0; i < commandCount; i++)
            {
                var action = (NotifyCollectionChangedAction)reader.ReadByte();
                switch (action)
                {
                case NotifyCollectionChangedAction.Add:
                    _sourceCommands.Add(new SourceAddCommand(reader, _itemSerializer));
                    break;

                case NotifyCollectionChangedAction.Replace:
                    _sourceCommands.Add(new SourceReplaceCommand(reader, _itemSerializer));
                    break;

                case NotifyCollectionChangedAction.Reset:
                    _sourceCommands.Add(new SourceClearCommand(reader, _itemSerializer));
                    break;

                case NotifyCollectionChangedAction.Remove:
                    _sourceCommands.Add(new SourceRemoveCommand(reader, _itemSerializer));
                    break;
                }
            }
        }
        private void ReadSourceCommands(ExtendedBinaryReader reader)
        {
            int count = reader.Read7BitEncodedInt();

            for (var i = 0; i < count; i++)
            {
                var action = (NotifyCollectionChangedAction)reader.ReadByte();
                switch (action)
                {
                case NotifyCollectionChangedAction.Add:
                    _sourceCommands.Add(new SourceAddCommand(reader, _keySerializer, _valueSerializer));
                    break;

                case NotifyCollectionChangedAction.Replace:
                    _sourceCommands.Add(new SourceReplaceCommand(reader, _keySerializer, _valueSerializer));
                    break;

                case NotifyCollectionChangedAction.Reset:
                    _sourceCommands.Add(new SourceClearCommand(reader, _keySerializer, _valueSerializer));
                    break;

                case NotifyCollectionChangedAction.Remove:
                    _sourceCommands.Add(new SourceRemoveCommand(reader, _keySerializer));
                    break;
                }
            }
        }
Ejemplo n.º 9
0
        private void ReadHeaders()
        {
            if (reader.PeekChar() == -1)
            {
                // Empty dataset
                FieldNames = new string[0];
                RawTypes   = new ClickHouseType[0];
                return;
            }
            var count = reader.Read7BitEncodedInt();

            FieldNames = new string[count];
            RawTypes   = new ClickHouseType[count];
            CurrentRow = new object[count];

            for (var i = 0; i < count; i++)
            {
                FieldNames[i] = reader.ReadString();
            }

            for (var i = 0; i < count; i++)
            {
                var chType = reader.ReadString();
                RawTypes[i] = TypeConverter.ParseClickHouseType(chType);
            }
        }
Ejemplo n.º 10
0
    public IoCommandStartEvent ReadIoCommandStartEvent(ExtendedBinaryReader reader)
    {
        var evt = new IoCommandStartEvent
        {
            Uid = reader.Read7BitEncodedInt(),
            ProcessInvocationUid = reader.Read7BitEncodedInt(),
            Kind           = (IoCommandKind)reader.ReadByte(),
            Location       = GetTextById(reader.Read7BitEncodedInt()),
            Path           = GetTextById(reader.Read7BitEncodedInt()),
            TimeoutSeconds = reader.ReadNullableInt32(),
            Command        = reader.ReadNullableString(),
            TransactionId  = GetTextById(reader.Read7BitEncodedInt()),
        };

        var argCount = reader.Read7BitEncodedInt();

        if (argCount > 0)
        {
            evt.Arguments = new KeyValuePair <string, object> [argCount];
            for (var i = 0; i < argCount; i++)
            {
                var name  = GetTextById(reader.Read7BitEncodedInt());
                var value = reader.ReadObject();
                evt.Arguments[i] = new KeyValuePair <string, object>(name, value);
            }
        }

        return(evt);
    }
Ejemplo n.º 11
0
 public static ProcessInvocationEndEvent ReadProcessInvocationEndEvent(ExtendedBinaryReader reader)
 {
     return(new ProcessInvocationEndEvent
     {
         InvocationUID = reader.Read7BitEncodedInt(),
         ElapsedMilliseconds = reader.ReadInt64(),
         NetTimeMilliseconds = reader.ReadNullableInt64(),
     });
 }
Ejemplo n.º 12
0
        public void Read(ExtendedBinaryReader reader)
        {
            int count = reader.Read7BitEncodedInt();

            for (int i = 0; i < count; i++)
            {
                string assemblyQualifiedName = reader.ReadString();
                var    type = Type.GetType(assemblyQualifiedName);
                RegisterDefaultType(type);
            }
        }
Ejemplo n.º 13
0
    public static IoCommandEndEvent ReadIoCommandEndEvent(ExtendedBinaryReader reader)
    {
        var evt = new IoCommandEndEvent
        {
            Uid = reader.Read7BitEncodedInt(),
            AffectedDataCount = reader.ReadNullableInt32(),
            ErrorMessage      = reader.ReadNullableString(),
        };

        return(evt);
    }
Ejemplo n.º 14
0
        public override object Read(ExtendedBinaryReader reader)
        {
            var length = reader.Read7BitEncodedInt();
            var data   = MakeArray(length);

            for (var i = 0; i < length; i++)
            {
                data.SetValue(ClearDBNull(UnderlyingType.Read(reader)), i);
            }
            return(data);
        }
            public SourceClearCommand(ExtendedBinaryReader reader, ISerializer itemDeserializer)
            {
                var count = reader.Read7BitEncodedInt();

                for (var i = 0; i < count; i++)
                {
                    itemDeserializer.Read(reader, synchronizedValue =>
                    {
                        _items.Add((TItem)synchronizedValue);
                    });
                }
            }
Ejemplo n.º 16
0
    public RowCreatedEvent ReadRowCreatedEvent(ExtendedBinaryReader reader)
    {
        var evt = new RowCreatedEvent
        {
            ProcessInvocationUid = reader.Read7BitEncodedInt(),
            RowUid = reader.Read7BitEncodedInt()
        };

        var columnCount = reader.Read7BitEncodedInt();

        if (columnCount > 0)
        {
            evt.Values = new KeyValuePair <string, object> [columnCount];
            for (var i = 0; i < columnCount; i++)
            {
                var column = GetTextById(reader.Read7BitEncodedInt());
                var value  = reader.ReadObject();
                evt.Values[i] = new KeyValuePair <string, object>(column, value);
            }
        }

        return(evt);
    }
Ejemplo n.º 17
0
            public SourceClearCommand(ExtendedBinaryReader reader, ISerializer keyDeserializer,
                                      ISerializer valueDeserializer)
            {
                var count = reader.Read7BitEncodedInt();

                for (var i = 0; i < count; i++)
                {
                    var keyValuePair = new BoxedKeyValuePair();

                    keyDeserializer.Read(reader, synchronizationCallback => { keyValuePair.Key = (TKey)synchronizationCallback; });
                    valueDeserializer.Read(reader, synchronizationCallback => { keyValuePair.Value = (TValue)synchronizationCallback; });

                    _keyValuePairs.Add(keyValuePair);
                }
            }
            public SourceClearCommand(ExtendedBinaryReader reader, IFieldSerializer keyDeserializer,
                                      IFieldSerializer valueDeserializer)
            {
                int count = reader.Read7BitEncodedInt();

                for (var i = 0; i < count; i++)
                {
                    var keyValuePair = new BoxedKeyValuePair();

                    keyDeserializer.Deserialize(reader, fixup => { keyValuePair.Key = (TKey)fixup; });

                    valueDeserializer.Deserialize(reader, fixup => { keyValuePair.Value = (TValue)fixup; });

                    _keyValuePairs.Add(keyValuePair);
                }
            }
        private void ReadHeaders()
        {
            var count = reader.Read7BitEncodedInt();

            FieldNames = new string[count];
            RawTypes   = new ClickHouseType[count];
            CurrentRow = new object[count];

            for (var i = 0; i < count; i++)
            {
                FieldNames[i] = reader.ReadString();
            }

            for (var i = 0; i < count; i++)
            {
                var chType = reader.ReadString();
                RawTypes[i] = TypeConverter.ParseClickHouseType(chType);
            }
        }
Ejemplo n.º 20
0
        public void Read(ExtendedBinaryReader reader, Action <object> synchronizationCallback)
        {
            var referenceId = reader.Read7BitEncodedInt();

            _referenceResolver.ResolveReference(referenceId, synchronizationCallback);
        }
Ejemplo n.º 21
0
        public void Deserialize(ExtendedBinaryReader reader, Action <object> valueFixup)
        {
            int referenceId = reader.Read7BitEncodedInt();

            _referenceResolver.ResolveReference(referenceId, valueFixup);
        }