本文整理了Java中org.neo4j.graphdb.Result.hasNext
方法的一些代码示例,展示了Result.hasNext
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Result.hasNext
方法的具体详情如下:
包路径:org.neo4j.graphdb.Result
类名称:Result
方法名:hasNext
[英]Denotes there being more rows available in this result. These rows must either be consumed, by invoking #next(), or the result has to be #close().
[中]表示此结果中有更多行可用。必须通过调用#next()来使用这些行,或者结果必须是#close()。
代码示例来源:origin: neo4j/neo4j
public void consume()
{
while ( originalResult.hasNext() )
{
queryResult.add( originalResult.next() );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void executeCountStoreQueryWithSingleRetry()
{
Result result = database.execute( "MATCH (n:toRetry) RETURN count(n)" );
assertEquals( 1, testCursorContext.getAdditionalAttempts() );
while ( result.hasNext() )
{
assertEquals( 1L, result.next().get( "count(n)" ) );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
@SuppressWarnings( "unchecked" )
public void shouldNotIncludePlanUnlessAskedFor() throws Exception
{
// Given
Result result = mock( Result.class );
when( result.hasNext() ).thenReturn( false );
when( result.columns() ).thenReturn( new ArrayList<>() );
// When
Map<String, Object> serialized = serializeToStringThenParseAsToMap( new CypherResultRepresentation( result,
/*includeStats=*/false, false ) );
// Then
assertFalse( "Didn't expect to see a plan here", serialized.containsKey( "plan" ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldProduceWellFormedJsonEvenIfResultIteratorThrowsExceptionOnNext() throws Exception
mockAccept( executionResult );
when( executionResult.columns() ).thenReturn( new ArrayList<>( data.keySet() ) );
when( executionResult.hasNext() ).thenReturn( true, true, false );
when( executionResult.next() ).thenReturn( data ).thenThrow( new RuntimeException( "Stuff went wrong!" ) );
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
@Test
public void testCliquesFromEmptyGraphShouldBeEmpty()
{
Result result = db.execute( "CALL apoc.algo.cliques(0)" );
while(result.hasNext())
{
fail("An empty graph should not result in any cliques");
}
}
代码示例来源:origin: neo4j/neo4j
static void assertQueryFindsIds( GraphDatabaseService db, boolean queryNodes, String index, String query, long... ids )
{
try ( Transaction tx = db.beginTx() )
{
String queryCall = queryNodes ? QUERY_NODES : QUERY_RELS;
Result result = db.execute( format( queryCall, index, query ) );
int num = 0;
Double score = Double.MAX_VALUE;
while ( result.hasNext() )
{
Map entry = result.next();
Long nextId = ((Entity) entry.get( queryNodes ? NODE : RELATIONSHIP )).getId();
Double nextScore = (Double) entry.get( SCORE );
assertThat( nextScore, lessThanOrEqualTo( score ) );
score = nextScore;
if ( num < ids.length )
{
assertEquals( format( "Result returned id %d, expected %d", nextId, ids[num] ), ids[num], nextId.longValue() );
}
else
{
fail( format( "Result returned id %d, which is beyond the number of ids (%d) that were expected.", nextId, ids.length ) );
}
num++;
}
assertEquals( "Number of results differ from expected", ids.length, num );
tx.success();
}
}
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
public void killPeriodicQueryAsync() {
new Thread(() -> {
int retries = 10;
try {
while (retries-- > 0 && !db.execute(KILL_PERIODIC_QUERY).hasNext()) {
Thread.sleep(10);
}
} catch (InterruptedException e) {
// ignore
}
}).start();
}
代码示例来源:origin: neo4j/neo4j
@Test
public void executeQueryWithSingleRetry()
{
Result result = database.execute( "MATCH (n) RETURN n.c" );
assertEquals( 1, testCursorContext.getAdditionalAttempts() );
while ( result.hasNext() )
{
assertEquals( "d", result.next().get( "n.c" ) );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldProduceWellFormedJsonEvenIfResultIteratorThrowsExceptionOnHasNext() throws Exception
mockAccept( executionResult );
when( executionResult.columns() ).thenReturn( new ArrayList<>( data.keySet() ) );
when( executionResult.hasNext() ).thenReturn( true ).thenThrow(
new RuntimeException( "Stuff went wrong!" ) );
when( executionResult.next() ).thenReturn( data );
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
@Test(timeout=9000)
public void testWithTimeout() {
Result result = db.execute("CALL apoc.cypher.runTimeboxed('CALL apoc.util.sleep(10000)', null, {timeout})", singletonMap("timeout", 100));
assertFalse(result.hasNext());
}
代码示例来源:origin: neo4j/neo4j
@Test
@SuppressWarnings( "unchecked" )
public void shouldSerializeProfilingResult() throws Exception
when( result.hasNext() ).thenReturn( false );
when( result.columns() ).thenReturn( new ArrayList<>() );
when( result.getExecutionPlanDescription() ).thenReturn( plan );
代码示例来源:origin: neo4j/neo4j
try ( Transaction tx = db.beginTx() )
Result result = db.execute( format( queryCall, index, query ) );
Double score = Double.MAX_VALUE;
while ( result.hasNext() )
Map entry = result.next();
long nextId = ((Entity) entry.get( queryNodes ? NODE : RELATIONSHIP )).getId();
Double nextScore = (Double) entry.get( SCORE );
代码示例来源:origin: neo4j/neo4j
private void executeDistantFriendsCountQuery( int userId )
{
Map<String,Object> params = singletonMap( "userId", (long) randomInt( userId ) );
try ( Result result = db.execute(
"MATCH (user:User { userId: {userId} } ) -[:FRIEND]- () -[:FRIEND]- (distantFriend) " +
"RETURN COUNT(distinct distantFriend)", params ) )
{
while ( result.hasNext() )
{
result.next();
}
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void executeLabelScanQueryWithSingleRetry()
{
Result result = database.execute( "MATCH (n:toRetry) RETURN n.c" );
assertEquals( 1, testCursorContext.getAdditionalAttempts() );
while ( result.hasNext() )
{
assertEquals( "d", result.next().get( "n.c" ) );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void mustBeAbleToListAvailableAnalyzers()
while ( result.hasNext() )
Map<String,Object> row = result.next();
Object description = row.get( "description" );
if ( !row.containsKey( "description" ) || !(description instanceof String) || ((String) description).trim().isEmpty() )
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
@Test(timeout=9000)
public void shouldTooLongTimeboxBeNotHarmful() {
Result result = db.execute("CALL apoc.cypher.runTimeboxed('CALL apoc.util.sleep(10)', null, {timeout})", singletonMap("timeout", 10000));
assertFalse(result.hasNext());
}
代码示例来源:origin: neo4j/neo4j
@Test
public void entitiesMustBeRemovedFromFulltextIndexWhenPropertyValuesChangeAwayFromText()
assertFalse( result.hasNext() );
result.close();
tx.success();
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
private long executeNumericResultStatement(@Name("statement") String statement, @Name("params") Map<String, Object> parameters) {
long sum = 0;
try (Result result = db.execute(statement, parameters)) {
while (result.hasNext()) {
Collection<Object> row = result.next().values();
for (Object value : row) {
if (value instanceof Number) {
sum += ((Number)value).longValue();
}
}
}
}
return sum;
}
代码示例来源:origin: neo4j/neo4j
private static void mockAccept( Result mock )
{
doAnswer( invocation ->
{
Result result = (Result) invocation.getMock();
Result.ResultVisitor visitor = invocation.getArgument( 0 );
while ( result.hasNext() )
{
visitor.visit( new MapRow( result.next() ) );
}
return null;
} ).when( mock )
.accept( (Result.ResultVisitor<RuntimeException>) any( Result.ResultVisitor.class ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void eagerResultContainsAllData()
{
Result result = database.execute( "MATCH (n) RETURN n.c" );
assertEquals( 1, testCursorContext.getAdditionalAttempts() );
int rows = 0;
while ( result.hasNext() )
{
result.next();
rows++;
}
assertEquals( 2, rows );
}
内容来源于网络,如有侵权,请联系作者删除!