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

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

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

Result.getNotifications介绍

[英]Provides notifications about the query producing this result.

Notifications can be warnings about problematic queries or other valuable information that can be presented in a client.
[中]提供有关生成此结果的查询的通知。
通知可以是关于有问题的查询的警告,也可以是客户机中可能出现的其他有价值的信息。

代码示例

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

@Override
public Iterable<Notification> getNotifications()
{
  return originalResult.getNotifications();
}

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

@Override
public Iterable<Notification> getNotifications()
{
  return originalResult.getNotifications();
}

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

@Test
public void version2_3ShouldWarnAboutBareNodes()
{
  Result res = db().execute("EXPLAIN CYPHER 2.3 MATCH n RETURN n");
  assert res.getNotifications().iterator().hasNext();
}

代码示例来源: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

protected void assertNotifications( String query, Matcher<Iterable<Notification>> matchesExpectation )
{
  try ( Result result = db().execute( query ) )
  {
    assertThat( result.getNotifications(), matchesExpectation );
  }
}

代码示例来源: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

@Test
public void eagerResultHaveNotifications()
{
  Result result = database.execute( " CYPHER planner=rule MATCH (n) RETURN n.c" );
  assertEquals( 1, testCursorContext.getAdditionalAttempts() );
  assertThat( Iterables.count( result.getNotifications() ), greaterThan( 0L ) );
}

代码示例来源: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 deprecatedRulePlanner()
{
  // when
  Result result = db().execute( "EXPLAIN CYPHER planner=rule RETURN 1" );
  // then
  assertThat( result.getNotifications(), containsItem( deprecatedRulePlanner ) );
  result.close();
}

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

@Test
public void deprecatedCompiledRuntime()
{
  // when
  Result result = db().execute( "EXPLAIN CYPHER runtime=compiled RETURN 1" );
  // then
  assertThat( result.getNotifications(), containsItem( deprecatedCompiledRuntime ) );
  result.close();
}

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

@Test
public void shouldNotifyWhenUsingCreateUniqueWhenCypherVersionIsDefault()
{
  // when
  Result result = db().execute( "MATCH (b) WITH b LIMIT 1 CREATE UNIQUE (b)-[:REL]->()" );
  // then
  assertThat( result.getNotifications(), containsItem( deprecatedCreateUnique ) );
  result.close();
}

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

Result result = safelyExecute( statement, hasPeriodicCommit, tc );
output.statementResult( result, statement.includeStats(), statement.resultDataContents() );
output.notifications( result.getNotifications() );

代码示例来源: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 shouldGiveCorrectPositionWhetherFromCacheOrNot()
  {
    // Given
    String cachedQuery = "MATCH (a:L1) RETURN a";
    String nonCachedQuery = "MATCH (a:L2) RETURN a";
    //make sure we cache the query
    GraphDatabaseAPI db = db();
    int limit = db.getDependencyResolver().resolveDependency( Config.class )
        .get( GraphDatabaseSettings.cypher_expression_recompilation_limit );
    for ( int i = 0; i < limit + 1; i++ )
    {
      db.execute( cachedQuery ).resultAsString();
    }

    // When
    Notification cachedNotification =
        Iterables.asList( db.execute( "EXPLAIN " + cachedQuery ).getNotifications() ).get( 0 );
    Notification nonCachedNotication =
        Iterables.asList( db.execute( "EXPLAIN " + nonCachedQuery ).getNotifications() ).get( 0 );

    // Then
    assertThat( cachedNotification.getPosition(), equalTo( new InputPosition( 17, 1, 18 ) ) );
    assertThat( nonCachedNotication.getPosition(), equalTo( new InputPosition( 17, 1, 18 ) ) );
  }
}

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

@Test
public void shouldNotifyWhenUsingCreateUniqueWhenCypherVersionIs3_5()
{
  // when
  Result result = db().execute( "CYPHER 3.5 MATCH (b) WITH b LIMIT 1 CREATE UNIQUE (b)-[:REL]->()" );
  InputPosition position = new InputPosition( 36, 1, 37 );
  // then
  assertThat( result.getNotifications(), containsItem( deprecatedCreateUnique ) );
  result.close();
}

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

@Override
public Iterable<Notification> getNotifications()
{
  return originalResult.getNotifications();
}

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

@Override
public Iterable<Notification> getNotifications()
{
  return originalResult.getNotifications();
}

相关文章