Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void accept(final org.neo4j.bolt.runtime.BoltResult_Visitor visitor) throws Exception
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        public override void Accept(Org.Neo4j.Bolt.runtime.BoltResult_Visitor visitor)
        {
            long start = _clock.millis();

            @delegate.Accept(row =>
            {
                visitor.Visit(row);
                return(true);
            });
            AddRecordStreamingTime(visitor, _clock.millis() - start);
            QueryExecutionType qt = @delegate.ExecutionType();

            visitor.AddMetadata("type", Values.stringValue(QueryTypeCode(qt.QueryType())));

            if (@delegate.QueryStatistics().containsUpdates())
            {
                MapValue stats = QueryStats(@delegate.QueryStatistics());
                visitor.AddMetadata("stats", stats);
            }
            if (qt.RequestedExecutionPlanDescription())
            {
                ExecutionPlanDescription rootPlanTreeNode = @delegate.ExecutionPlanDescription();
                string metadataFieldName = rootPlanTreeNode.HasProfilerStatistics() ? "profile" : "plan";
                visitor.AddMetadata(metadataFieldName, ExecutionPlanConverter.Convert(rootPlanTreeNode));
            }

            IEnumerable <Notification> notifications = @delegate.Notifications;

            if (notifications.GetEnumerator().hasNext())
            {
                visitor.AddMetadata("notifications", NotificationConverter.Convert(notifications));
            }
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @SuppressWarnings("unchecked") public void shouldSerializeProfilingResult() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSerializeProfilingResult()
        {
            // Given
            string name = "Kalle";

            ExecutionPlanDescription plan      = GetMockDescription(name);
            ExecutionPlanDescription childPlan = GetMockDescription("child");

            when(plan.Children).thenReturn(asList(childPlan));
            when(plan.HasProfilerStatistics()).thenReturn(true);

            Org.Neo4j.Graphdb.ExecutionPlanDescription_ProfilerStatistics stats = mock(typeof(Org.Neo4j.Graphdb.ExecutionPlanDescription_ProfilerStatistics));
            when(stats.DbHits).thenReturn(13L);
            when(stats.Rows).thenReturn(25L);

            when(plan.ProfilerStatistics).thenReturn(stats);

            Result result = mock(typeof(Result));

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            when(result.HasNext()).thenReturn(false);
            when(result.Columns()).thenReturn(new List <>());
            when(result.ExecutionPlanDescription).thenReturn(plan);

            // When
            IDictionary <string, object> serialized = SerializeToStringThenParseAsToMap(new CypherResultRepresentation(result, false, true));

            // Then
            IDictionary <string, object> serializedPlan = (IDictionary <string, object>)serialized["plan"];

            assertThat(serializedPlan["name"], equalTo(name));
            assertThat(serializedPlan["rows"], @is(25));
            assertThat(serializedPlan["dbHits"], @is(13));

            IList <IDictionary <string, object> > children = (IList <IDictionary <string, object> >)serializedPlan["children"];

            assertThat(children.Count, @is(1));

            IDictionary <string, object> args = (IDictionary <string, object>)serializedPlan["args"];

            assertThat(args["argumentKey"], @is("argumentValue"));
        }
Beispiel #3
0
        protected internal override void Serialize(MappingSerializer mappingSerializer)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.ExecutionPlanDescription planDescription = getPlan();
            ExecutionPlanDescription planDescription = Plan;

            mappingSerializer.PutString("name", planDescription.Name);
            IDictionary <string, object> arguments          = planDescription.Arguments;
            MappingRepresentation        argsRepresentation = getMapRepresentation(arguments);

            mappingSerializer.PutMapping("args", argsRepresentation);

            if (planDescription.HasProfilerStatistics())
            {
                Org.Neo4j.Graphdb.ExecutionPlanDescription_ProfilerStatistics stats = planDescription.ProfilerStatistics;
                mappingSerializer.PutNumber("rows", stats.Rows);
                mappingSerializer.PutNumber("dbHits", stats.DbHits);
            }

            mappingSerializer.PutList("children", new ListRepresentation("children", new IterableWrapperAnonymousInnerClass(this, planDescription.Children)));
        }
        public static MapValue Convert(ExecutionPlanDescription plan)
        {
            bool            hasProfilerStatistics = plan.HasProfilerStatistics();
            int             size = hasProfilerStatistics ? 9 : 4;
            MapValueBuilder @out = new MapValueBuilder(size);

            @out.Add("operatorType", stringValue(plan.Name));
            @out.Add("args", ValueUtils.asMapValue(plan.Arguments));
            @out.Add("identifiers", ValueUtils.asListValue(plan.Identifiers));
            @out.Add("children", Children(plan));
            if (hasProfilerStatistics)
            {
                Org.Neo4j.Graphdb.ExecutionPlanDescription_ProfilerStatistics profile = plan.ProfilerStatistics;
                @out.Add("dbHits", longValue(profile.DbHits));
                @out.Add("pageCacheHits", longValue(profile.PageCacheHits));
                @out.Add("pageCacheMisses", longValue(profile.PageCacheMisses));
                @out.Add("pageCacheHitRatio", doubleValue(profile.PageCacheHitRatio));
                @out.Add("rows", longValue(profile.Rows));
            }
            return(@out.Build());
        }