org.neo4j.graphdb.Result.getExecutionPlanDescription()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中org.neo4j.graphdb.Result.getExecutionPlanDescription方法的一些代码示例,展示了Result.getExecutionPlanDescription的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Result.getExecutionPlanDescription方法的具体详情如下:
包路径:org.neo4j.graphdb.Result
类名称:Result
方法名:getExecutionPlanDescription

Result.getExecutionPlanDescription介绍

[英]Returns a description of the query plan used to produce this result.

Retrieving a description of the execution plan that was executed is always possible, regardless of whether the query requested a plan or not. For implementing a client with the ability to present the plan to the user, it is useful to be able to tell if the query requested a description of the plan or not. For these purposes the QueryExecutionType#requestedExecutionPlanDescription()-method is used.

Being able to invoke this method, regardless of whether the user requested the plan or not is useful for purposes of debugging queries in applications.
[中]

代码示例

代码示例来源:origin: neo4j/neo4j

@Override
public ExecutionPlanDescription getExecutionPlanDescription()
{
  return originalResult.getExecutionPlanDescription();
}

代码示例来源:origin: neo4j/neo4j

@Override
public ExecutionPlanDescription executionPlanDescription()
{
  return originalResult.getExecutionPlanDescription();
}

代码示例来源:origin: neo4j/neo4j

private Function<Object, ExecutionPlanDescription> planProvider( final Result result )
{
  return from -> result.getExecutionPlanDescription();
}

代码示例来源:origin: neo4j/neo4j

private void assertNoIndexSeeks( Result result )
{
  assertThat( result.stream().count(), is( 1L ) );
  String planDescription = result.getExecutionPlanDescription().toString();
  assertThat( planDescription, containsString( "NodeByLabel" ) );
  assertThat( planDescription, not( containsString( "IndexSeek" ) ) );
}

代码示例来源:origin: neo4j/neo4j

@SafeVarargs
private static Result mockExecutionResult( ExecutionPlanDescription planDescription,
    Iterable<Notification> notifications, Map<String, Object>... rows )
{
  Set<String> keys = new TreeSet<>();
  for ( Map<String, Object> row : rows )
  {
    keys.addAll( row.keySet() );
  }
  Result executionResult = mock( Result.class );
  when( executionResult.columns() ).thenReturn( new ArrayList<>( keys ) );
  final Iterator<Map<String, Object>> inner = asList( rows ).iterator();
  when( executionResult.hasNext() ).thenAnswer( invocation -> inner.hasNext() );
  when( executionResult.next() ).thenAnswer( invocation -> inner.next() );
  when( executionResult.getQueryExecutionType() )
      .thenReturn( null != planDescription
             ? QueryExecutionType.profiled( QueryExecutionType.QueryType.READ_WRITE )
             : QueryExecutionType.query( QueryExecutionType.QueryType.READ_WRITE ) );
  if ( executionResult.getQueryExecutionType().requestedExecutionPlanDescription() )
  {
    when( executionResult.getExecutionPlanDescription() ).thenReturn( planDescription );
  }
  mockAccept( executionResult );
  when( executionResult.getNotifications() ).thenReturn( notifications );
  return executionResult;
}

代码示例来源:origin: neo4j/neo4j

when( result.hasNext() ).thenReturn( false );
when( result.columns() ).thenReturn( new ArrayList<>() );
when( result.getExecutionPlanDescription() ).thenReturn( plan );

代码示例来源:origin: neo4j/neo4j

void shouldNotNotifyInStream( String version, String query )
{
  // when
  Result result = db().execute( version + query );
  // then
  assertThat( Iterables.asList( result.getNotifications() ), empty() );
  Map<String,Object> arguments = result.getExecutionPlanDescription().getArguments();
  assertThat( arguments.get( "version" ), equalTo( version ) );
  result.close();
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldNotifyWhenUsingCypher3_1ForTheRulePlannerWhenCypherVersionIsTheDefault()
{
  // when
  Result result = db().execute( "CYPHER planner=rule RETURN 1" );
  InputPosition position = InputPosition.empty;
  // then
  assertThat( result.getNotifications(), containsItem( rulePlannerUnavailable ) );
  Map<String,Object> arguments = result.getExecutionPlanDescription().getArguments();
  assertThat( arguments.get( "version" ), equalTo( "CYPHER 3.1" ) );
  assertThat( arguments.get( "planner" ), equalTo( "RULE" ) );
  result.close();
}

代码示例来源:origin: neo4j/neo4j

void shouldNotifyInStream( String version, String query, InputPosition pos, NotificationCode code )
{
  //when
  Result result = db().execute( version + query );
  //then
  NotificationCode.Notification notification = code.notification( pos );
  assertThat( Iterables.asList( result.getNotifications() ), Matchers.hasItems( notification ) );
  Map<String,Object> arguments = result.getExecutionPlanDescription().getArguments();
  assertThat( arguments.get( "version" ), equalTo( version ) );
  result.close();
}

代码示例来源:origin: neo4j/neo4j

void shouldNotifyInStreamWithDetail( String version, String query, InputPosition pos, NotificationCode code,
                   NotificationDetail detail )
{
  //when
  Result result = db().execute( version + query );
  //then
  NotificationCode.Notification notification = code.notification( pos, detail );
  assertThat( Iterables.asList( result.getNotifications() ), Matchers.hasItems( notification ) );
  Map<String,Object> arguments = result.getExecutionPlanDescription().getArguments();
  assertThat( arguments.get( "version" ), equalTo( version ) );
  result.close();
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldNotifyWhenUsingCreateUniqueWhenCypherVersionIs3_5()
{
  // when
  Result result = db().execute( "EXPLAIN CYPHER 3.5 MATCH (b) WITH b LIMIT 1 CREATE UNIQUE (b)-[:REL]->()" );
  InputPosition position = new InputPosition( 44, 1, 45 );
  // then
  assertThat( result.getNotifications(), containsNotification( CREATE_UNIQUE_UNAVAILABLE_FALLBACK.notification( position ) ) );
  Map<String,Object> arguments = result.getExecutionPlanDescription().getArguments();
  assertThat( arguments.get( "version" ), equalTo( "CYPHER 3.1" ) );
  result.close();
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldNotifyWhenUsingCreateUniqueWhenCypherVersionIsDefault()
{
  // when
  Result result = db().execute( "EXPLAIN MATCH (b) WITH b LIMIT 1 CREATE UNIQUE (b)-[:REL]->()" );
  InputPosition position = new InputPosition( 33, 1, 34 );
  // then
  assertThat( result.getNotifications(),
      containsNotification( CREATE_UNIQUE_UNAVAILABLE_FALLBACK.notification( position ) ) );
  Map<String,Object> arguments = result.getExecutionPlanDescription().getArguments();
  assertThat( arguments.get( "version" ), equalTo( "CYPHER 3.1" ) );
  result.close();
}

代码示例来源:origin: neo4j/neo4j

@Test
public void eagerResultHaveExecutionPlan()
{
  Result result = database.execute( "profile MATCH (n) RETURN n.c" );
  assertEquals( 1, testCursorContext.getAdditionalAttempts() );
  assertEquals( 2, result.getExecutionPlanDescription().getProfilerStatistics().getRows() );
}

代码示例来源:origin: neo4j/neo4j

writeRootPlanDescription( result.getExecutionPlanDescription() );

代码示例来源:origin: org.neo4j/neo4j-cypher

@Override
public ExecutionPlanDescription executionPlanDescription()
{
  return originalResult.getExecutionPlanDescription();
}

代码示例来源:origin: org.neo4j/neo4j-cypher

@Override
public ExecutionPlanDescription getExecutionPlanDescription()
{
  return originalResult.getExecutionPlanDescription();
}

代码示例来源:origin: org.neo4j.app/neo4j-server

private Function<Object, ExecutionPlanDescription> planProvider( final Result result )
{
  return from -> result.getExecutionPlanDescription();
}

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

@Test
public void testRunFirstColumnBugCompiled() throws Exception {
  ResourceIterator<Node> it = db.execute("CREATE (m:Movie  {title:'MovieA'})<-[:ACTED_IN]-(p:Person {name:'PersonA'})-[:ACTED_IN]->(m2:Movie {title:'MovieB'}) RETURN m").columnAs("m");
  Node movie = it.next();
  it.close();
  String query = "WITH {m} AS m MATCH (m)<-[:ACTED_IN]-(:Person)-[:ACTED_IN]->(rec:Movie) RETURN rec LIMIT 10";
  System.out.println(db.execute("EXPLAIN "+query).getExecutionPlanDescription().toString());
  ResourceIterator<Node> rec = db.execute(query, map("m",movie)).columnAs("rec");
  assertEquals(1, rec.stream().count());
}
@Test

代码示例来源:origin: org.neo4j/neo4j-shell

private void printResult( Output out, Result result, long startTime ) throws RemoteException
{
  result.writeAsStringTo( new PrintWriter( new OutputAsWriter( out ) ) );
  out.println( (now() - startTime) + " ms" );
  if ( result.getQueryExecutionType().requestedExecutionPlanDescription() )
  {
    out.println();
    out.println( result.getExecutionPlanDescription().toString() );
  }
}

代码示例来源:origin: org.neo4j.doc/neo4j-cypher-docs

@Test
public void explain_returns_plan() throws Exception
{
  // START SNIPPET: explain_returns_plan
  Result result = db.execute( "EXPLAIN CREATE (user:User{name:{name}}) RETURN user" );
  assert result.getQueryExecutionType().isExplained();
  assert result.getQueryExecutionType().requestedExecutionPlanDescription();
  assert !result.hasNext();
  assert !result.getQueryStatistics().containsUpdates();
  assert result.columns().isEmpty();
  assert !result.getExecutionPlanDescription().hasProfilerStatistics();
  // END SNIPPET: explain_returns_plan
}

相关文章