public BinaryIngressStreamable(Stream binaryStream, int numMessages, IIngressScheduler scheduler, StreamProperties <TKey, TPayload> inputProperties, bool readPropertiesFromStream, QueryContainer container, string identifier)
            : base((inputProperties ?? StreamProperties <TKey, TPayload> .Default).SetQueryContainer(container))
        {
            if (readPropertiesFromStream)
            {
                var propSer = StreamableSerializer.Create <SerializedProperties>();
                var props   = propSer.Deserialize(binaryStream);
                this.properties = props.ToStreamProperties <TKey, TPayload>();
            }

            this.stream = binaryStream;
            if (this.stream.CanSeek)
            {
                this.streamStartPosition = binaryStream.Position;
            }
            this.numMessages           = numMessages;
            this.scheduler             = scheduler;
            this.container             = container;
            this.IngressSiteIdentifier = identifier ?? Guid.NewGuid().ToString();
            this.delayed = container != null;
            if (this.delayed)
            {
                container.RegisterIngressSite(identifier);
            }
        }
示例#2
0
 /// <summary>
 /// Deserialize from binary stream to streamable
 /// </summary>
 /// <typeparam name="TKey"></typeparam>
 /// <typeparam name="TPayload"></typeparam>
 /// <param name="binaryStream"></param>
 /// <param name="scheduler"></param>
 /// <param name="readPropertiesFromStream"></param>
 /// <param name="inputProperties"></param>
 /// <returns></returns>
 public static IIngressStreamable <TKey, TPayload> ToStreamable <TKey, TPayload>(
     this Stream binaryStream,
     IIngressScheduler scheduler   = null,
     bool readPropertiesFromStream = false,
     StreamProperties <TKey, TPayload> inputProperties = null)
 {
     return(new BinaryIngressStreamable <TKey, TPayload>(
                binaryStream,
                0,
                scheduler,
                inputProperties,
                readPropertiesFromStream,
                null,
                Guid.NewGuid().ToString()));
 }
示例#3
0
 /// <summary>
 /// Deserialize from binary stream to streamable
 /// </summary>
 /// <typeparam name="TPayload"></typeparam>
 /// <param name="fileName"></param>
 /// <param name="numMessages"></param>
 /// <param name="scheduler"></param>
 /// <param name="readPropertiesFromStream"></param>
 /// <param name="inputProperties"></param>
 /// <returns></returns>
 public static IIngressStreamable <Empty, TPayload> ToStreamableFromFile <TPayload>(
     this string fileName,
     int numMessages               = 0,
     IIngressScheduler scheduler   = null,
     bool readPropertiesFromStream = false,
     StreamProperties <Empty, TPayload> inputProperties = null)
 {
     return(new BinaryIngressStreamable <Empty, TPayload>(
                new FileStream(fileName, FileMode.Open),
                numMessages,
                scheduler,
                inputProperties,
                readPropertiesFromStream,
                null,
                Guid.NewGuid().ToString()));
 }
示例#4
0
 /// <summary>
 /// Deserialize from binary stream to streamable
 /// </summary>
 /// <typeparam name="TKey"></typeparam>
 /// <typeparam name="TPayload"></typeparam>
 /// <param name="binaryStream"></param>
 /// <param name="scheduler"></param>
 /// <param name="readPropertiesFromStream"></param>
 /// <param name="inputProperties"></param>
 /// <param name="container"></param>
 /// <param name="identifier"></param>
 /// <returns></returns>
 public static IIngressStreamable <TKey, TPayload> RegisterBinaryInput <TKey, TPayload>(
     this QueryContainer container,
     Stream binaryStream,
     IIngressScheduler scheduler   = null,
     bool readPropertiesFromStream = false,
     StreamProperties <TKey, TPayload> inputProperties = null,
     string identifier = null)
 {
     return(new BinaryIngressStreamable <TKey, TPayload>(
                binaryStream,
                0,
                scheduler,
                inputProperties,
                readPropertiesFromStream,
                container,
                identifier ?? Guid.NewGuid().ToString()));
 }
示例#5
0
 /// <summary>
 /// Deserialize from binary stream to streamable
 /// </summary>
 /// <typeparam name="TKey"></typeparam>
 /// <typeparam name="TPayload"></typeparam>
 /// <param name="fileName"></param>
 /// <param name="numMessages"></param>
 /// <param name="scheduler"></param>
 /// <param name="readPropertiesFromStream"></param>
 /// <param name="inputProperties"></param>
 /// <param name="container"></param>
 /// <param name="identifier"></param>
 /// <returns></returns>
 public static IIngressStreamable <TKey, TPayload> RegisterBinaryInputFromFile <TKey, TPayload>(
     this QueryContainer container,
     string fileName,
     int numMessages               = 0,
     IIngressScheduler scheduler   = null,
     bool readPropertiesFromStream = false,
     StreamProperties <TKey, TPayload> inputProperties = null,
     string identifier = null)
 {
     return(new BinaryIngressStreamable <TKey, TPayload>(
                new FileStream(fileName, FileMode.Open),
                numMessages,
                scheduler,
                inputProperties,
                readPropertiesFromStream,
                container,
                identifier ?? Guid.NewGuid().ToString()));
 }
示例#6
0
        public BinaryIngressReader(
            string identifier,
            Streamable <TKey, TPayload> streamable,
            IStreamObserver <TKey, TPayload> observer,
            int numMessages,
            Stream stream,
            IIngressScheduler scheduler,
            bool delayed)
            : base(identifier, streamable, observer)
        {
            this.pool        = MemoryManager.GetMemoryPool <TKey, TPayload>();
            this.numMessages = numMessages;
            this.stream      = stream;
            this.scheduler   = scheduler;

            if (!delayed)
            {
                this.subscription.Enable();
            }
        }
        /// <summary>
        /// Deserialize data from binary streams to a sharded streamable
        /// </summary>
        /// <typeparam name="TKey">Grouping key type for data in the query</typeparam>
        /// <typeparam name="TPayload">Event payload type for data in the query</typeparam>
        /// <param name="binaryStream">Streams from which to deserialize binary data to sharded streams</param>
        /// <param name="scheduler"></param>
        /// <param name="readPropertiesFromStream"></param>
        /// <param name="inputProperties"></param>
        /// <returns>A sharded streamable hydrated from the data in the binary streams</returns>
        public static IShardedStreamable <TKey, TPayload> FromBinaryStream <TKey, TPayload>(Stream[] binaryStream, IIngressScheduler scheduler = null, bool readPropertiesFromStream = false, StreamProperties <TKey, TPayload> inputProperties = null)
        {
            var streams = new BinaryIngressStreamable <TKey, TPayload> [binaryStream.Length];

            for (int i = 0; i < binaryStream.Length; i++)
            {
                streams[i] = new BinaryIngressStreamable <TKey, TPayload>(binaryStream[i], 0, scheduler, inputProperties, readPropertiesFromStream, null, null);
            }

            return(new ShardedStreamable <TKey, TPayload>(streams));
        }