本文整理了Java中org.neo4j.graphdb.Result.close
方法的一些代码示例,展示了Result.close
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Result.close
方法的具体详情如下:
包路径:org.neo4j.graphdb.Result
类名称:Result
方法名:close
[英]Closes the result, freeing up any resources held by the result.
This is an idempotent operation, invoking it multiple times has the same effect as invoking it exactly once. It is thus safe (and even encouraged, for style and simplicity) to invoke this method even after consuming all rows in the result through the #next().
[中]关闭结果,释放结果所持有的所有资源。
这是一个幂等运算,多次调用它与只调用一次具有相同的效果。因此,即使在通过#next()消耗了结果中的所有行之后,也可以安全地调用此方法(为了风格和简单性,甚至鼓励这样做)。
代码示例来源:origin: neo4j/neo4j
private void createSimpleNodesIndex()
{
db.execute( format( NODE_CREATE, "nodes", array( LABEL.name() ), array( PROP ) ) ).close();
}
}
代码示例来源:origin: neo4j/neo4j
private void createSimpleRelationshipIndex()
{
db.execute( format( RELATIONSHIP_CREATE, "rels", array( REL.name() ), array( PROP ) ) ).close();
}
代码示例来源:origin: neo4j/neo4j
@Test
public void mustNotBeAbleToCreateTwoIndexesWithSameName()
{
db = createDatabase();
db.execute( format( NODE_CREATE, "node", array( "Label1", "Label2" ), array( "prop1", "prop2" ) ) ).close();
expectedException.expectMessage( "already exists" );
db.execute( format( NODE_CREATE, "node", array( "Label1", "Label2" ), array( "prop3", "prop4" ) ) ).close();
}
代码示例来源: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
private long nodesInDatabase()
{
Result r = graphdb().execute( "MATCH (n) RETURN count(n) AS c" );
Long nodes = (Long) r.columnAs( "c" ).next();
r.close();
return nodes;
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldCloseTransactionsWhenIteratingResults()
{
// Given an execution result that has been started but not exhausted
createNode();
createNode();
Result executionResult = db.execute( "CYPHER runtime=interpreted MATCH (n) RETURN n" );
executionResult.next();
assertThat( activeTransaction(), is( notNullValue() ) );
// When
executionResult.close();
// Then
assertThat( activeTransaction(), is( nullValue() ) );
}
代码示例来源: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 nodeIndexesMustHaveLabels()
{
db = createDatabase();
expectedException.expect( QueryExecutionException.class );
db.execute( format( NODE_CREATE, "nodeIndex", array(), array( PROP ) ) ).close();
}
代码示例来源:origin: neo4j/neo4j
@Test
public void nodeIndexesMustHaveProperties()
{
db = createDatabase();
expectedException.expect( QueryExecutionException.class );
db.execute( format( NODE_CREATE, "nodeIndex", array( "Label" ), array() ) ).close();
}
代码示例来源:origin: neo4j/neo4j
@Test
public void queryingIndexInTransactionItWasCreatedInMustThrow()
{
db = createDatabase();
try ( Transaction ignore = db.beginTx() )
{
createSimpleNodesIndex();
expectedException.expect( QueryExecutionException.class );
db.execute( format( QUERY_NODES, "nodes", "value" ) ).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 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
@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 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 queryingDroppedIndexForRelationshipsInDroppingTransactionMustThrow()
{
db = createDatabase();
try ( Transaction tx = db.beginTx() )
{
createSimpleRelationshipIndex();
tx.success();
}
awaitIndexesOnline();
try ( Transaction tx = db.beginTx() )
{
db.execute( format( DROP, "rels" ) ).close();
expectedException.expect( QueryExecutionException.class );
db.execute( format( QUERY_RELS, "rels", "blabla" ) );
}
}
代码示例来源: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: neo4j/neo4j
@Test
public void queryNodesMustThrowWhenQueryingRelationshipIndex()
{
db = createDatabase();
try ( Transaction tx = db.beginTx() )
{
createSimpleRelationshipIndex();
tx.success();
}
awaitIndexesOnline();
try ( Transaction tx = db.beginTx() )
{
expectedException.expect( Exception.class );
db.execute( format( QUERY_NODES, "rels", "bla bla" ) ).close();
tx.success();
}
}
内容来源于网络,如有侵权,请联系作者删除!