Flattens the graph 'ActivityStreams' structure. If there are multiple nodes for a stream with different expiration timestamp then the lates expiration timestamp will be captured.
Exemplo n.º 1
0
        /// <summary>
        /// FanIn
        /// </summary>
        public IEnumerable<Activity> Load(ActivityStream stream, ActivityStreamOptions feedOptions)
        {
            // At this point we have all the streams with their timestamp
            Dictionary<byte[], long> streamsToLoad = new StreamCrawler(streamStore).StreamsToLoad(stream, feedOptions.Paging.Timestamp);
            Dictionary<string, DateTime> debug = streamsToLoad.ToDictionary(key => Encoding.UTF8.GetString(key.Key), val => DateTime.FromFileTimeUtc(val.Value));

            feedOptions = feedOptions ?? ActivityStreamOptions.Default;

            var snapshot = GetSnapshot(streamsToLoad, feedOptions);

            SortedSet<Activity> buffer = new SortedSet<Activity>(Activity.ComparerDesc);

            //  Init
            foreach (var str in streamsToLoad)
            {
                var streamId = str.Key;
                FetchNextActivity(snapshot, streamId, buffer);
            }

            while (buffer.Count > 0)
            {
                Activity nextActivity = buffer.First();
                buffer.Remove(nextActivity);
                yield return nextActivity;

                FetchNextActivity(snapshot, nextActivity.StreamId, buffer);
            }
        }
        /// <summary>
        /// FanIn
        /// </summary>
        public IEnumerable <Activity> Load(ActivityStream stream, ActivityStreamOptions feedOptions)
        {
            // At this point we have all the streams with their timestamp
            Dictionary <byte[], long>     streamsToLoad = new StreamCrawler(streamStore).StreamsToLoad(stream, feedOptions.Paging.Timestamp);
            Dictionary <string, DateTime> debug         = streamsToLoad.ToDictionary(key => Encoding.UTF8.GetString(key.Key), val => DateTime.FromFileTimeUtc(val.Value));

            feedOptions = feedOptions ?? ActivityStreamOptions.Default;

            var snapshot = GetSnapshot(streamsToLoad, feedOptions);

            SortedSet <Activity> buffer = new SortedSet <Activity>(Activity.ComparerDesc);

            //  Init
            foreach (var str in streamsToLoad)
            {
                var streamId = str.Key;
                FetchNextActivity(snapshot, streamId, buffer);
            }

            while (buffer.Count > 0)
            {
                Activity nextActivity = buffer.First();
                buffer.Remove(nextActivity);
                yield return(nextActivity);

                FetchNextActivity(snapshot, nextActivity.StreamId, buffer);
            }
        }