コード例 #1
0
        public static void PrintSpectrum(StringBuilder builder, StageExecution execution, int width, DetailLevel additionalStatsLevel)
        {
            long[] values = values(execution);
            long   total  = total(values);

            // reduce the width with the known extra characters we know we'll print in and around the spectrum
            width -= 2 + PROGRESS_WIDTH;

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.helpers.collection.Pair<Step<?>,float> bottleNeck = execution.stepsOrderedBy(org.neo4j.unsafe.impl.batchimport.stats.Keys.avg_processing_time, false).iterator().next();
            Pair <Step <object>, float> bottleNeck = execution.StepsOrderedBy(Keys.avg_processing_time, false).GetEnumerator().next();
            QuantizedProjection         projection = new QuantizedProjection(total, width);
            long lastDoneBatches = 0;
            int  stepIndex       = 0;
            bool hasProgressed   = false;

            builder.Append('[');
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (Step<?> step : execution.steps())
            foreach (Step <object> step in execution.Steps())
            {
                StepStats stats = step.Stats();
                if (!projection.Next(values[stepIndex]))
                {
                    break;                              // odd though
                }
                long stepWidth = total == 0 && stepIndex == 0 ? width : projection.Step();
                if (stepWidth > 0)
                {
                    if (hasProgressed)
                    {
                        stepWidth--;
                        builder.Append('|');
                    }
                    bool   isBottleNeck   = bottleNeck.First() == step;
                    string name           = (isBottleNeck ? "*" : "") + stats.ToString(additionalStatsLevel) + (step.Processors(0) > 1 ? "(" + step.Processors(0) + ")" : "");
                    int    charIndex      = 0;                      // negative value "delays" the text, i.e. pushes it to the right
                    char   backgroundChar = step.Processors(0) > 1 ? '=' : '-';
                    for (int i = 0; i < stepWidth; i++, charIndex++)
                    {
                        char ch = backgroundChar;
                        if (charIndex >= 0 && charIndex < name.Length && charIndex < stepWidth)
                        {
                            ch = name[charIndex];
                        }
                        builder.Append(ch);
                    }
                    hasProgressed = true;
                }
                lastDoneBatches = stats.Stat(Keys.done_batches).asLong();
                stepIndex++;
            }

            long progress = lastDoneBatches * execution.Config.batchSize();

            builder.Append("]").Append(FitInProgress(progress));
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldProjectSteps()
        public virtual void ShouldProjectSteps()
        {
            // GIVEN
            QuantizedProjection projection = new QuantizedProjection(9, 7);

            // WHEN/THEN
            assertTrue(projection.Next(3));
            assertEquals(2, projection.Step());

            assertTrue(projection.Next(3));
            assertEquals(3, projection.Step());

            assertTrue(projection.Next(3));
            assertEquals(2, projection.Step());

            assertFalse(projection.Next(1));
        }