コード例 #1
0
        public WebJobsScriptHostService(IOptionsMonitor <ScriptApplicationHostOptions> applicationHostOptions, IScriptHostBuilder scriptHostBuilder, ILoggerFactory loggerFactory,
                                        IScriptWebHostEnvironment scriptWebHostEnvironment, IEnvironment environment,
                                        HostPerformanceManager hostPerformanceManager, IOptions <HostHealthMonitorOptions> healthMonitorOptions,
                                        IMetricsLogger metricsLogger, IApplicationLifetime applicationLifetime, IConfiguration config, IScriptEventManager eventManager)
        {
            ArgumentNullException.ThrowIfNull(loggerFactory);

            // This will no-op if already initialized.
            InitializeApplicationInsightsRequestTracking();

            _applicationLifetime = applicationLifetime;
            RegisterApplicationLifetimeEvents();

            _metricsLogger            = metricsLogger;
            _applicationHostOptions   = applicationHostOptions ?? throw new ArgumentNullException(nameof(applicationHostOptions));
            _scriptWebHostEnvironment = scriptWebHostEnvironment ?? throw new ArgumentNullException(nameof(scriptWebHostEnvironment));
            _scriptHostBuilder        = scriptHostBuilder ?? throw new ArgumentNullException(nameof(scriptHostBuilder));
            _environment          = environment ?? throw new ArgumentNullException(nameof(environment));
            _performanceManager   = hostPerformanceManager ?? throw new ArgumentNullException(nameof(hostPerformanceManager));
            _healthMonitorOptions = healthMonitorOptions ?? throw new ArgumentNullException(nameof(healthMonitorOptions));
            _logger       = loggerFactory.CreateLogger(ScriptConstants.LogCategoryHostGeneral);
            _config       = config ?? throw new ArgumentNullException(nameof(config));
            _eventManager = eventManager;

            _hostStarted = _hostStartedSource.Task;

            State = ScriptHostState.Default;

            if (ShouldMonitorHostHealth)
            {
                _healthCheckWindow    = new SlidingWindow <bool>(_healthMonitorOptions.Value.HealthCheckWindow);
                _hostHealthCheckTimer = new Timer(OnHostHealthCheckTimer, null, TimeSpan.Zero, _healthMonitorOptions.Value.HealthCheckInterval);
            }
        }
コード例 #2
0
 public void ReadMore()
 {
     Debug.Log(gameObject.name.Replace("Btn", ""));
     CanvasManager.instance.SetCurrentCanvas(CanvasManager.instance.canvasDictionary[gameObject.name.Replace("Btn", "")]);
     SlidingWindow.Open();
     TrackingManager.instance.ToggleArrows(false);
 }
コード例 #3
0
        public async Task AddEvent_RemovesExpiredItems()
        {
            var window = new SlidingWindow <MyItem>(TimeSpan.FromSeconds(1));

            for (int i = 0; i < 5; i++)
            {
                window.AddEvent(new MyItem {
                    Data = i
                });
                await Task.Delay(100);
            }

            var eventsField = window.GetType().GetField("_events", BindingFlags.Instance | BindingFlags.NonPublic);
            var events      = (List <SlidingWindow <MyItem> .Event>)eventsField.GetValue(window);

            Assert.Equal(5, events.Count);

            // now let the items expire
            await Task.Delay(1000);

            // add a new event that shouldn't be expired
            var evt = new MyItem {
                Data = 8
            };

            window.AddEvent(evt);

            Assert.Equal(1, events.Count);
        }
コード例 #4
0
        public async Task AddEvent_RemovesExpiredItems()
        {
            var           window = new SlidingWindow <MyItem>(TimeSpan.FromSeconds(1));
            StringBuilder log    = new StringBuilder();

            for (int i = 0; i < 5; i++)
            {
                window.AddEvent(new MyItem {
                    Data = i
                });
                log.AppendLine($"{DateTime.UtcNow.ToString("HH:mm:ss.FFFZ")}: Added item: {i}");
                Thread.Sleep(50);
            }

            var eventsField = window.GetType().GetField("_events", BindingFlags.Instance | BindingFlags.NonPublic);
            var events      = (List <SlidingWindow <MyItem> .Event>)eventsField.GetValue(window);
            int count       = events.Count;

            Assert.True(count == 5, $"{DateTime.UtcNow} | Expected 5. Actual {count}.{Environment.NewLine}{log.ToString()}");

            // now let the items expire
            await Task.Delay(1000);

            // add a new event that shouldn't be expired
            var evt = new MyItem {
                Data = 8
            };

            window.AddEvent(evt);

            Assert.Equal(1, events.Count);
        }
コード例 #5
0
ファイル: SlidingWindowTests.cs プロジェクト: przpl/CryptZip
        public void LookAheadEmpty_Nothing_NotEmpty()
        {
            MemoryStream  stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 });
            SlidingWindow window = new SlidingWindow(stream, 3, 2, 4);

            Assert.IsFalse(window.LookAheadEmpty);
        }
コード例 #6
0
        public TransmissionStrategy(ReliableMessagingVersion reliableMessagingVersion, TimeSpan initRtt,
                                    int maxWindowSize, bool requestAcks, UniqueId id)
        {
            if (initRtt < TimeSpan.Zero)
            {
                if (DiagnosticUtility.ShouldTrace(TraceEventType.Warning))
                {
                    TraceUtility.TraceEvent(TraceEventType.Warning, TraceCode.WsrmNegativeElapsedTimeDetected,
                                            SR.TraceCodeWsrmNegativeElapsedTimeDetected, this);
                }

                initRtt = ReliableMessagingConstants.UnknownInitiationTime;
            }

            if (maxWindowSize <= 0)
            {
                throw Fx.AssertAndThrow("Argument maxWindow size must be positive.");
            }

            _id                       = id;
            _maxWindowSize            = _lossWindowSize = maxWindowSize;
            _meanRtt                  = Math.Min((long)initRtt.TotalMilliseconds, Constants.MaxMeanRtt >> Constants.TimeMultiplier) << Constants.TimeMultiplier;
            _serrRtt                  = _meanRtt >> 1;
            _window                   = new SlidingWindow(maxWindowSize);
            _slowStartThreshold       = maxWindowSize;
            _timeout                  = Math.Max(((200 << Constants.TimeMultiplier) * 2) + _meanRtt, _meanRtt + (_serrRtt << Constants.ChebychevFactor));
            QuotaRemaining            = int.MaxValue;
            _retryTimer               = new IOThreadTimer(new Func <object, Task>(OnRetryElapsed), null, true);
            _requestAcks              = requestAcks;
            _reliableMessagingVersion = reliableMessagingVersion;
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: mattorus/CodingPatterns
        static void Main(string[] args)
        {
            Console.WriteLine("----------------------START ALGORITHM TESTS----------------------");

            SelectionSort.RunTests();
            InsertionSort.RunTests();
            Factorial.RunTests();
            Palindrome.RunTests();
            Recursion.RunTests();
            MergeSort.RunTests();
            QuickSort.RunTests();
            BreadthFirstSearch.RunTests();

            Console.WriteLine("----------------------END ALGORITHM TESTS----------------------");
            Console.WriteLine("----------------------START PATTERN TESTS----------------------");

            BFS.RunTests();
            DFS.RunTests();
            SlidingWindow.RunTests();
            TwoPointers.RunTests();

            FastSlowPointers.RunTests();
            MergeIntervals.RunTests();

            Console.WriteLine("----------------------END PATTERN TESTS----------------------");
        }
コード例 #8
0
        public void TestAckSeqNormal()
        {
            SlidingWindow <SeqTest> window = new SlidingWindow <SeqTest>(10, () => new SeqTest());


            SeqTest seqItem = window.GetNextAvailable();

            Assert.AreEqual(1, window.Count);
            Assert.IsNotNull(seqItem);
            Assert.AreEqual(0, seqItem.Seq);

            window.AckSeq(seqItem.Seq);
            Assert.AreEqual(0, window.Count);

            seqItem = window.GetNextAvailable();

            Assert.IsNotNull(seqItem);
            Assert.AreEqual(1, seqItem.Seq);

            window.AckSeq(seqItem.Seq);

            Assert.AreEqual(0, window.Count);

            window.GetNextAvailable();
            window.GetNextAvailable();
            window.GetNextAvailable();
            seqItem = window.GetNextAvailable();

            Assert.AreEqual(4, window.Count);
            Assert.AreEqual(5, seqItem.Seq);

            window.AckSeq(seqItem.Seq);

            Assert.AreEqual(0, window.Count);
        }
コード例 #9
0
        public WebJobsScriptHostService(IOptionsMonitor <ScriptApplicationHostOptions> applicationHostOptions, IScriptHostBuilder scriptHostBuilder, ILoggerFactory loggerFactory, IServiceProvider rootServiceProvider,
                                        IServiceScopeFactory rootScopeFactory, IScriptWebHostEnvironment scriptWebHostEnvironment, IEnvironment environment,
                                        HostPerformanceManager hostPerformanceManager, IOptions <HostHealthMonitorOptions> healthMonitorOptions)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            _applicationHostOptions   = applicationHostOptions ?? throw new ArgumentNullException(nameof(applicationHostOptions));
            _scriptWebHostEnvironment = scriptWebHostEnvironment ?? throw new ArgumentNullException(nameof(scriptWebHostEnvironment));
            _rootServiceProvider      = rootServiceProvider;
            _scriptHostBuilder        = scriptHostBuilder ?? throw new ArgumentNullException(nameof(scriptHostBuilder));
            _environment          = environment ?? throw new ArgumentNullException(nameof(environment));
            _performanceManager   = hostPerformanceManager ?? throw new ArgumentNullException(nameof(hostPerformanceManager));
            _healthMonitorOptions = healthMonitorOptions ?? throw new ArgumentNullException(nameof(healthMonitorOptions));
            _logger = loggerFactory.CreateLogger(ScriptConstants.LogCategoryHostGeneral);

            State = ScriptHostState.Default;

            if (ShouldMonitorHostHealth)
            {
                _healthCheckWindow    = new SlidingWindow <bool>(_healthMonitorOptions.Value.HealthCheckWindow);
                _hostHealthCheckTimer = new Timer(OnHostHealthCheckTimer, null, TimeSpan.Zero, _healthMonitorOptions.Value.HealthCheckInterval);
            }
        }
コード例 #10
0
    public void DisableObjects(Vuforia.VuMarkTarget vumarkTargetTracked)
    {
        previousGameObject  = detectedGameObject;
        previousTabsManager = myTabsManagerRef;
        bool isAnimationDone = true;

        //checks if all the animations on the detected object were done.
        foreach (Animator anim in detectedGameObject.GetComponentsInChildren <Animator>())
        {
            isAnimationDone = isAnimationDone && anim.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1;
            Debug.Log("<color='red'> animator time </color>" + anim.name + " " + anim.GetCurrentAnimatorStateInfo(0).IsName("main") + ": " + anim.GetCurrentAnimatorStateInfo(0).normalizedTime);
        }

        if (isAnimationDone)
        {
            curState = TrackingState.Waiting;
        }
        else
        {
            curState = TrackingState.Lost;
        }
        if (messenger != null && !SlidingWindow.IsOpen())
        {
            messenger.ShowMessage("Please aim your camera at our poster");
        }


        detectedGameObject.SetActive(false);

        ToggleArrows(false);
    }
コード例 #11
0
        public async Task GetEvents_RemovesExpiredItems()
        {
            var window = new SlidingWindow <MyItem>(TimeSpan.FromSeconds(1));

            for (int i = 0; i < 5; i++)
            {
                window.AddEvent(new MyItem {
                    Data = i
                });
                await Task.Delay(100);
            }

            var evts = window.GetEvents().ToArray();

            Assert.Equal(5, evts.Length);
            for (int i = 0; i < 5; i++)
            {
                Assert.Equal(i, evts[i].Data);
            }

            // now let the items expire
            await Task.Delay(1000);

            // add a new event that shouldn't be expired
            var evt = new MyItem {
                Data = 7
            };

            window.AddEvent(evt);

            evts = window.GetEvents().ToArray();
            Assert.Equal(1, evts.Length);
            Assert.Same(evt, evts[0]);
        }
コード例 #12
0
 static void Main(string[] args)
 {
     foreach (var list in SlidingWindow <int> .Generate(new int[] { 1, 2, 3, 4, 5 }, 2, 5))
     {
         Console.WriteLine(string.Join(" & ", list));
     }
 }
コード例 #13
0
        public void TestSlidingWindow()
        {
            DateTime start = DateTime.UtcNow;

            SlidingWindow window = new SlidingWindow(TimeSpan.FromSeconds(30));

            window.AddDataPoint(start);
            Assert.Equal(1, window.Count);

            window.AddDataPoint(start);
            window.AddDataPoint(start);

            window.AddDataPoint(start + TimeSpan.FromSeconds(10));
            window.AddDataPoint(start + TimeSpan.FromSeconds(15));
            window.AddDataPoint(start + TimeSpan.FromSeconds(20));
            window.AddDataPoint(start + TimeSpan.FromSeconds(20.5));
            window.AddDataPoint(start + TimeSpan.FromSeconds(25));

            Assert.Equal(8, window.Count);

            window.AddDataPoint(start + TimeSpan.FromSeconds(42));
            Assert.Equal(5, window.Count);

            window.AddDataPoint(start + TimeSpan.FromSeconds(52));
            Assert.Equal(3, window.Count);

            window.AddDataPoint(start + TimeSpan.FromSeconds(100));
            Assert.Equal(1, window.Count);

            window.Clear();
            Assert.Equal(0, window.Count);
        }
コード例 #14
0
        public void Test1()
        {
            var numbers = new[] { 100, 200, 300, 400 };
            var result  = SlidingWindow.Slide(numbers, 2).Max(w => w.Sum());

            Assert.Equal(700, result);
        }
コード例 #15
0
ファイル: SnippetFu.cs プロジェクト: universsky/beagrep
        public SnippetReader(TextReader line_reader, string[] query_terms, bool full_text, int context_length, int snippet_length)
        {
            this.line_reader          = line_reader;
            this.found_snippet_length = 0;
            this.full_text            = full_text;
            this.context_length       = (context_length > 0 ? context_length : context_length_default);
            this.snippet_length       = (snippet_length > 0 ? snippet_length : snippet_length_default);

            if (query_terms == null)
            {
                return;
            }

            this.sliding_window = new SlidingWindow(this.context_length);

            // remove stop words from query_terms
            query_terms_list = new ArrayList(query_terms.Length);
            foreach (string term in query_terms)
            {
                if (LuceneCommon.IsStopWord(term))
                {
                    continue;
                }
                query_terms_list.Add(term);
            }
            //Console.WriteLine ("Creating snippet reader");
        }
コード例 #16
0
        public Myo(string mqttURL, int windowSize, int overlap)
        {
            MqttUrl  = mqttURL;
            Features = new IFeature[]
            {
                new HjorthParameters(8, 9, 10),
                new StandardDeviation(8, 9, 10),
                new Mean(8, 9, 10),
                new Max(8, 9, 10),
                new Min(8, 9, 10),
                new Percentile(5, 8, 9, 10),
                new Percentile(10, 8, 9, 10),
                new Percentile(25, 8, 9, 10),
                new Percentile(50, 8, 9, 10),
                new Percentile(75, 8, 9, 10),
                new Percentile(90, 8, 9, 10),
                new Percentile(95, 8, 9, 10),
                new ZeroCrossing(8, 9, 10),
                new MeanCrossing(8, 9, 10),
                new Entropy(8, 9, 10),
                new Correlation(9, 10),
                new Correlation(9, 11),
                new Correlation(10, 11),

                new HjorthParameters(11, 12, 13),
                new StandardDeviation(11, 12, 13),
                new Mean(11, 12, 13),
                new Max(11, 12, 13),
                new Min(11, 12, 13),
                new Percentile(5, 11, 12, 13),
                new Percentile(10, 11, 12, 13),
                new Percentile(25, 11, 12, 13),
                new Percentile(50, 11, 12, 13),
                new Percentile(75, 11, 12, 13),
                new Percentile(90, 11, 12, 13),
                new Percentile(95, 11, 12, 13),
                new ZeroCrossing(11, 12, 13),
                new MeanCrossing(11, 12, 13),
                new Entropy(11, 12, 13),

                new StandardDeviation(0, 1, 2, 3, 4, 5, 6, 7),
                new Mean(0, 1, 2, 3, 4, 5, 6, 7),
                new Max(0, 1, 2, 3, 4, 5, 6, 7),
                new Min(0, 1, 2, 3, 4, 5, 6, 7),
                new Percentile(5, 0, 1, 2, 3, 4, 5, 6, 7),
                new Percentile(10, 0, 1, 2, 3, 4, 5, 6, 7),
                new Percentile(25, 0, 1, 2, 3, 4, 5, 6, 7),
                new Percentile(50, 0, 1, 2, 3, 4, 5, 6, 7),
                new Percentile(75, 0, 1, 2, 3, 4, 5, 6, 7),
                new Percentile(90, 0, 1, 2, 3, 4, 5, 6, 7),
                new Percentile(95, 0, 1, 2, 3, 4, 5, 6, 7),

                new SumLargerThan(25, 0, 1, 2, 3, 4, 5, 6, 7),
                new SumLargerThan(50, 0, 1, 2, 3, 4, 5, 6, 7),
                new SumLargerThan(100, 0, 1, 2, 3, 4, 5, 6, 7)
            };

            Window = new SlidingWindow <double[]>(windowSize, overlap);
        }
コード例 #17
0
ファイル: SlidingWindowTests.cs プロジェクト: przpl/CryptZip
        public void LookAheadEmpty_SlidesAllBytes_Empty()
        {
            MemoryStream  stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 });
            SlidingWindow window = new SlidingWindow(stream, 3, 2, 4);

            window.Slide(8);
            Assert.IsTrue(window.LookAheadEmpty);
        }
コード例 #18
0
        internal UnreliableChannel(byte channelId, Connection connection, SocketConfig config)
        {
            this.channelId  = channelId;
            this.connection = connection;
            this.config     = config;

            _incomingAckedPackets = new SlidingWindow <bool>(config.ReliabilityWindowSize, true, sizeof(ushort));
        }
コード例 #19
0
ファイル: SlidingWindowTests.cs プロジェクト: przpl/CryptZip
        public void Constructor_SixBytes_Initialized()
        {
            MemoryStream  stream = new MemoryStream(new byte[] { 0, 1, 2, 3, 4, 5 });
            SlidingWindow window = new SlidingWindow(stream, 4, 3, 4);
            var           bytes  = window.Bytes;

            CollectionAssert.AreEqual(new [] { 0, 1, 2, 0, 0, 0, 0 }, bytes);
        }
コード例 #20
0
        public void IsExpired_ReturnsExpectedValue(int t, bool expected)
        {
            var window = TimeSpan.FromMinutes(15);
            var evt    = new SlidingWindow <MyItem> .Event();

            evt.TimeStamp = (DateTime.UtcNow - TimeSpan.FromMinutes(t)).Ticks;
            Assert.Equal(expected, SlidingWindow <MyItem> .IsExpired(evt, window));
        }
コード例 #21
0
        public void SlideNotAtEndWhenInBeginningOfFile()
        {
            var path = TestContext.CurrentContext.TestDirectory + "../../../res/testfile1";
            var file = new DataFile(path);
            var sw   = new SlidingWindow(file.GetAllBytes());

            Assert.IsFalse(sw.AtEnd());
        }
コード例 #22
0
ファイル: SignalTool.cs プロジェクト: retrospy/RetroSpy
        public static void SetPCMouseProperties(float x, float y, int xRaw, int yRaw, ControllerStateBuilder state, float maxCircleSize = 1.0f)
        {
            if (!windows.ContainsKey("PC_"))
            {
                windows["PC_"] = new SlidingWindow();
            }

            SetMouseProperties(x, y, xRaw, yRaw, state, maxCircleSize, windows["PC_"], "PC_");
        }
コード例 #23
0
 public MovementRecognizer(float sensitivity = DEFAULT_SENISIVITY, float repeat = DEFAULT_REPEAT)
 {
     this.Sensitivity = sensitivity;
     this.Repeat = repeat;
     
     OutputFriendlyName = MOVEMENT_OUTPUT_FRIENDLY_NAME;
     window = new SlidingWindow(50);
     lastMovement = DateTime.UtcNow;
 }
コード例 #24
0
        public void MaxSum()
        {
            int[]         arr           = { 1, 4, 2, 10, 2, 3, 1, 0, 20 };
            int           k             = 4;
            int           n             = arr.Length;
            SlidingWindow SlidingWindow = new SlidingWindow();

            SlidingWindow.maxSum(arr, n, k);
        }
コード例 #25
0
        internal UnreliableSequencedChannel(byte channelId, Connection connection, SocketConfig config, MemoryManager memoryManager)
        {
            this.channelId     = channelId;
            this.connection    = connection;
            this.memoryManager = memoryManager;
            this.config        = config;

            _incomingAckedPackets = new SlidingWindow <bool>(config.ReliabilityWindowSize);
        }
コード例 #26
0
        public void SetPositionThrowsExceptionWhenWindowMovedBackwards()
        {
            var points                = CreateTestPoints();
            var windowSize            = 1;
            var windowPositioningType = WindowPositioningType.CenteredAtPosition;
            var sut = new SlidingWindow <Point2D>(points, p => p.X, windowSize, windowPositioningType);

            Assert.That(() => sut.SetPosition(2), Throws.Nothing);
            Assert.That(() => sut.SetPosition(1), Throws.InvalidOperationException);
        }
コード例 #27
0
        public Binary(string mqttURL, int windowSize, int overlap)
        {
            MqttUrl  = mqttURL;
            Features = new IFeature[]
            {
                new FusionFramework.Features.TimeDomain.Mean()
            };

            Window = new SlidingWindow(windowSize, overlap);
        }
コード例 #28
0
        public Accelerometer(string mqttURL, int windowSize, int overlap)
        {
            MqttUrl  = mqttURL;
            Features = new IFeature[]
            {
                new FusionFramework.Features.TimeDomain.Mean()
            };

            Window = new SlidingWindow <double[]>(windowSize, overlap);
        }
コード例 #29
0
        public void ThrowsExceptionIfWindowNotSet()
        {
            var points                = CreateTestPoints();
            var windowSize            = 1;
            var windowPositioningType = WindowPositioningType.CenteredAtPosition;
            var sut = new SlidingWindow <Point2D>(points, p => p.X, windowSize, windowPositioningType);

            // No call to .SetPosition!
            Assert.That(() => sut.Count(), Throws.InvalidOperationException);
        }
コード例 #30
0
ファイル: SlidingWindowTests.cs プロジェクト: przpl/CryptZip
        public void NextToken_AtBegining_Found()
        {
            MemoryStream  stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 1, 2, 5, 4, 6, 7, 1, 9, 10, 7, 11, 4 });
            SlidingWindow window = new SlidingWindow(stream, 32, 16, 4);
            Token         token  = window.NextToken();

            Assert.AreEqual(0, token.Offset);
            Assert.AreEqual(0, token.Length);
            Assert.AreEqual(1, token.Byte);
        }
コード例 #31
0
ファイル: SlidingWindowTests.cs プロジェクト: przpl/CryptZip
        public void Slide_SlidesSixTimes_Slided()
        {
            MemoryStream  stream = new MemoryStream(new byte[] { 0, 1, 2, 3, 4, 5 });
            SlidingWindow window = new SlidingWindow(stream, 4, 3, 4);

            window.Slide(6);
            var bytes = window.Bytes;

            CollectionAssert.AreEqual(new [] { 0, 1, 2, 3, 4, 5, 0 }, bytes);
        }
 public TransmissionStrategy(ReliableMessagingVersion reliableMessagingVersion, TimeSpan initRtt, int maxWindowSize, bool requestAcks, UniqueId id)
 {
     if (initRtt < TimeSpan.Zero)
     {
         throw Fx.AssertAndThrow("Argument initRtt cannot be negative.");
     }
     if (maxWindowSize <= 0)
     {
         throw Fx.AssertAndThrow("Argument maxWindow size must be positive.");
     }
     this.id = id;
     this.maxWindowSize = this.lossWindowSize = maxWindowSize;
     this.meanRtt = Math.Min((long) initRtt.TotalMilliseconds, 0x55555555555555L) << 7;
     this.serrRtt = this.meanRtt >> 1;
     this.window = new SlidingWindow(maxWindowSize);
     this.slowStartThreshold = maxWindowSize;
     this.timeout = Math.Max((long) (0xc800L + this.meanRtt), (long) (this.meanRtt + (this.serrRtt << 2)));
     this.quotaRemaining = 0x7fffffff;
     this.retryTimer = new IOThreadTimer(new Action<object>(this.OnRetryElapsed), null, true);
     this.requestAcks = requestAcks;
     this.reliableMessagingVersion = reliableMessagingVersion;
 }
コード例 #33
0
ファイル: SnippetFu.cs プロジェクト: ArsenShnurkov/beagle-1
		public SnippetReader (TextReader line_reader, string[] query_terms, bool full_text, int context_length, int snippet_length)
		{
			this.line_reader = line_reader;
			this.found_snippet_length = 0;
			this.full_text = full_text;
			this.context_length = (context_length > 0 ? context_length : context_length_default);
			this.snippet_length = (snippet_length > 0 ? snippet_length : snippet_length_default);

			if (query_terms == null)
				return;

			this.sliding_window = new SlidingWindow (this.context_length);

			// remove stop words from query_terms
			query_terms_list = new ArrayList (query_terms.Length);
			foreach (string term in query_terms) {
				if (LuceneCommon.IsStopWord (term))
					continue;
				query_terms_list.Add (term);
			}
			//Console.WriteLine ("Creating snippet reader");
		}
コード例 #34
0
            /// <summary>
            /// Iterates over all maximum intervals from the 
            /// collection that are lower than or equal to epsilon.
            /// </summary>
            /// <param name="sortedNumbers">Sorted collection whose
            /// modes are to be calculated.</param>
            /// <param name="epsilon">Maximum size of the intervals.</param>
            /// <returns></returns>
            internal static IEnumerable<Interval> Intervals(
                IEnumerable<double> sortedNumbers,double epsilon)
            {
                SlidingWindow window = new SlidingWindow(sortedNumbers);

                window.MoveStart();
                window.MoveEnd();

                // No element contained?
                if (window.EndReached)
                    yield break;

                Interval lastInterval = window.Interval;

                // While the end is not reached ...
                while (!window.EndReached)
                {
                    // Move upper end as long as possible
                    while (!window.EndReached && window.Width <= epsilon)
                    {
                        // Save the last interval anyway
                        lastInterval = window.Interval;
                        window.MoveEnd();
                    }

                    // Return the last interval smaller than or equal to epsilon
                    yield return lastInterval;

                    // Move lower bounds until we reach epsilon again
                    while (!window.EndReached && window.Width > epsilon)
                    {
                        window.MoveStart();
                    }
                }
            }
コード例 #35
0
        public TransmissionStrategy(ReliableMessagingVersion reliableMessagingVersion, TimeSpan initRtt,
            int maxWindowSize, bool requestAcks, UniqueId id)
        {
            if (initRtt < TimeSpan.Zero)
            {
                if (DiagnosticUtility.ShouldTrace(TraceEventType.Warning))
                {
                    TraceUtility.TraceEvent(TraceEventType.Warning, TraceCode.WsrmNegativeElapsedTimeDetected,
                    SR.GetString(SR.TraceCodeWsrmNegativeElapsedTimeDetected), this);
                }

                initRtt = ReliableMessagingConstants.UnknownInitiationTime;
            }

            if (maxWindowSize <= 0)
            {
                throw Fx.AssertAndThrow("Argument maxWindow size must be positive.");
            }

            this.id = id;
            this.maxWindowSize = this.lossWindowSize = maxWindowSize;
            this.meanRtt = Math.Min((long)initRtt.TotalMilliseconds, Constants.MaxMeanRtt >> Constants.TimeMultiplier) << Constants.TimeMultiplier;
            this.serrRtt = this.meanRtt >> 1;
            this.window = new SlidingWindow(maxWindowSize);
            this.slowStartThreshold = maxWindowSize;
            this.timeout = Math.Max(((200 << Constants.TimeMultiplier) * 2) + this.meanRtt, this.meanRtt + (this.serrRtt << Constants.ChebychevFactor));
            this.quotaRemaining = Int32.MaxValue;
            this.retryTimer = new IOThreadTimer(new Action<object>(OnRetryElapsed), null, true);
            this.requestAcks = requestAcks;
            this.reliableMessagingVersion = reliableMessagingVersion;
        }