本文整理了Java中org.neo4j.graphdb.Result.resultAsString
方法的一些代码示例,展示了Result.resultAsString
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Result.resultAsString
方法的具体详情如下:
包路径:org.neo4j.graphdb.Result
类名称:Result
方法名:resultAsString
[英]Provides a textual representation of the query result.
The execution result represented by this object will be consumed in its entirety after this method is called. Calling any of the other iterating methods on it should not be expected to return any results.
[中]提供查询结果的文本表示形式。
调用此方法后,此对象表示的执行结果将全部使用。对其调用任何其他迭代方法都不会返回任何结果。
代码示例来源:origin: neo4j/neo4j
private Future executeInThread( final String query )
{
return executorService.submit( () -> db.execute( query ).resultAsString() );
}
}
代码示例来源:origin: neo4j/neo4j
private Future executeInThread( final String query )
{
return executorService.submit( () -> db.execute( query ).resultAsString() );
}
}
代码示例来源:origin: neo4j/neo4j
@Override
public String listTransactions()
{
String res;
try ( Transaction tx = graphDatabaseAPI.beginTx() )
{
res = graphDatabaseAPI.execute( "CALL dbms.listTransactions()" ).resultAsString();
tx.success();
}
catch ( QueryExecutionException e )
{
res = "dbms.listTransactions() is not available";
}
return res;
}
代码示例来源:origin: neo4j/neo4j
private void executeInThread( final String query, Map<String,Object> params )
{
executorService.execute( () ->
{
try
{
db.execute( query, params ).resultAsString();
}
catch ( Exception e )
{
hasFailed.set( true );
}
} );
}
}
代码示例来源:origin: neo4j/neo4j
@Override
public Pair<String, String> evaluate( String script )
{
if ( StringUtils.EMPTY.equals( script.trim() ) )
{
return Pair.of( StringUtils.EMPTY, null );
}
String resultString;
try
{
TransactionalContext tc = cypherExecutor.createTransactionContext( script, emptyMap(), request );
ExecutionEngine engine = cypherExecutor.getExecutionEngine();
Result result = engine.executeQuery( script, emptyMap(), tc );
resultString = result.resultAsString();
}
catch ( SyntaxException error )
{
resultString = error.getMessage();
}
catch ( Exception exception )
{
log.error( "Unknown error executing cypher query", exception );
resultString = "Error: " + exception.getClass().getSimpleName() + " - " + exception.getMessage();
}
return Pair.of( resultString, null );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void eagerResultToString()
{
Result result = database.execute( "MATCH (n) RETURN n.c, n.d" );
assertEquals( 1, testCursorContext.getAdditionalAttempts() );
String resultString = result.resultAsString();
assertTrue( resultString.contains( "n.c, n.d" ) );
assertTrue( resultString.contains( "d, a" ) );
assertTrue( resultString.contains( "y, k" ) );
}
代码示例来源:origin: neo4j/neo4j
private static void addNode( GraphDatabaseService db )
{
if ( USE_CYPHER )
{
Result result = db.execute( "create (:Person {name: 'Sneaky Steve'})" );
System.out.println( result.resultAsString() );
}
else
{
try ( Transaction tx = db.beginTx() )
{
db.createNode( label( "Person" ) ).setProperty( "name", "Sneaky Steve" );
tx.success();
}
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void eagerResultWriteAsStringToStream()
{
Result result = database.execute( "MATCH (n) RETURN n.c" );
assertEquals( 1, testCursorContext.getAdditionalAttempts() );
assertEquals( result.resultAsString(), printToStream( result ) );
}
代码示例来源: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-contrib/neo4j-apoc-procedures
@Test
@Ignore
public void overrideSingleCallStatement() throws Exception {
db.execute("call apoc.custom.asProcedure('answer','RETURN 42 as answer')");
TestUtil.testCall(db, "call custom.answer() yield row return row", (row) -> assertEquals(42L, ((Map)row.get("row")).get("answer")));
String clearCaches = db.execute("call dbms.clearQueryCaches()").resultAsString();
System.out.println(clearCaches);
db.execute("call apoc.custom.asProcedure('answer','RETURN 43 as answer')");
TestUtil.testCall(db, "call custom.answer() yield row return row", (row) -> assertEquals(43L, ((Map)row.get("row")).get("answer")));
}
@Test
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
@Test
public void testFilterIntoCollection() {
testResult(db, "call apoc.load.xml('file:src/test/resources/xml/books.xml') yield value as catalog\n" +
" UNWIND catalog._children as book\n" +
" RETURN book.id, [attr IN book._children WHERE attr._type IN ['author','title'] | [attr._type, attr._text]] as pairs"
, result -> {
assertEquals("+----------------------------------------------------------------------------------------------------------------+\n" +
"| book.id | pairs |\n" +
"+----------------------------------------------------------------------------------------------------------------+\n" +
"| \"bk101\" | [[\"author\",\"Gambardella, Matthew\"],[\"author\",\"Arciniegas, Fabio\"],[\"title\",\"XML Developer's Guide\"]] |\n" +
"| \"bk102\" | [[\"author\",\"Ralls, Kim\"],[\"title\",\"Midnight Rain\"]] |\n" +
"| \"bk103\" | [[\"author\",\"Corets, Eva\"],[\"title\",\"Maeve Ascendant\"]] |\n" +
"| \"bk104\" | [[\"author\",\"Corets, Eva\"],[\"title\",\"Oberon's Legacy\"]] |\n" +
"| \"bk105\" | [[\"author\",\"Corets, Eva\"],[\"title\",\"The Sundered Grail\"]] |\n" +
"| \"bk106\" | [[\"author\",\"Randall, Cynthia\"],[\"title\",\"Lover Birds\"]] |\n" +
"| \"bk107\" | [[\"author\",\"Thurman, Paula\"],[\"title\",\"Splish Splash\"]] |\n" +
"| \"bk108\" | [[\"author\",\"Knorr, Stefan\"],[\"title\",\"Creepy Crawlies\"]] |\n" +
"| \"bk109\" | [[\"author\",\"Kress, Peter\"],[\"title\",\"Paradox Lost\"]] |\n" +
"| \"bk110\" | [[\"author\",\"O'Brien, Tim\"],[\"title\",\"Microsoft .NET: The Programming Bible\"]] |\n" +
"| \"bk111\" | [[\"author\",\"O'Brien, Tim\"],[\"title\",\"MSXML3: A Comprehensive Guide\"]] |\n" +
"| \"bk112\" | [[\"author\",\"Galos, Mike\"],[\"title\",\"Visual Studio 7: A Comprehensive Guide\"]] |\n" +
"+----------------------------------------------------------------------------------------------------------------+\n" +
"12 rows\n", result.resultAsString());
});
}
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
@Test
public void testSubmitStatement() throws Exception {
String callList = "CALL apoc.periodic.list()";
// force pre-caching the queryplan
System.out.println("call list" + db.execute(callList).resultAsString());
assertFalse(db.execute(callList).hasNext());
testCall(db, "CALL apoc.periodic.submit('foo','create (:Foo)')",
(row) -> {
assertEquals("foo", row.get("name"));
assertEquals(false, row.get("done"));
assertEquals(false, row.get("cancelled"));
assertEquals(0L, row.get("delay"));
assertEquals(0L, row.get("rate"));
});
long count = tryReadCount(50, "MATCH (:Foo) RETURN COUNT(*) AS count", 1L);
assertThat(String.format("Expected %d, got %d ", 1L, count), count, equalTo(1L));
testCall(db, callList, (r) -> assertEquals(true, r.get("done")));
}
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
@Test
public void testReturnCollectionElements() {
testResult(db, "call apoc.load.xml('file:src/test/resources/xml/books.xml') yield value as catalog\n"+
"UNWIND catalog._children as book\n" +
"WITH book.id as id, [attr IN book._children WHERE attr._type IN ['author','title'] | attr._text] as pairs\n" +
"RETURN id, pairs[0] as author, pairs[1] as title"
, result -> {
assertEquals("+-----------------------------------------------------------------------------+\n" +
"| id | author | title |\n" +
"+-----------------------------------------------------------------------------+\n" +
"| \"bk101\" | \"Gambardella, Matthew\" | \"Arciniegas, Fabio\" |\n" +
"| \"bk102\" | \"Ralls, Kim\" | \"Midnight Rain\" |\n" +
"| \"bk103\" | \"Corets, Eva\" | \"Maeve Ascendant\" |\n" +
"| \"bk104\" | \"Corets, Eva\" | \"Oberon's Legacy\" |\n" +
"| \"bk105\" | \"Corets, Eva\" | \"The Sundered Grail\" |\n" +
"| \"bk106\" | \"Randall, Cynthia\" | \"Lover Birds\" |\n" +
"| \"bk107\" | \"Thurman, Paula\" | \"Splish Splash\" |\n" +
"| \"bk108\" | \"Knorr, Stefan\" | \"Creepy Crawlies\" |\n" +
"| \"bk109\" | \"Kress, Peter\" | \"Paradox Lost\" |\n" +
"| \"bk110\" | \"O'Brien, Tim\" | \"Microsoft .NET: The Programming Bible\" |\n" +
"| \"bk111\" | \"O'Brien, Tim\" | \"MSXML3: A Comprehensive Guide\" |\n" +
"| \"bk112\" | \"Galos, Mike\" | \"Visual Studio 7: A Comprehensive Guide\" |\n" +
"+-----------------------------------------------------------------------------+\n" +
"12 rows\n", result.resultAsString());
});
}
代码示例来源:origin: org.neo4j/neo4j-dbms
@Override
public String listTransactions()
{
String res;
try ( Transaction tx = graphDatabaseAPI.beginTx() )
{
res = graphDatabaseAPI.execute( "CALL dbms.listTransactions()" ).resultAsString();
tx.success();
}
catch ( QueryExecutionException e )
{
res = "dbms.listTransactions() is not available";
}
return res;
}
代码示例来源:origin: SciGraph/SciGraph
return cypherUtil.execute(replacedStartCurie).resultAsString();
代码示例来源:origin: org.neo4j.app/neo4j-server
@Override
public Pair<String, String> evaluate( String script )
{
if ( StringUtils.EMPTY.equals( script.trim() ) )
{
return Pair.of( StringUtils.EMPTY, null );
}
String resultString;
try
{
TransactionalContext tc = cypherExecutor.createTransactionContext( script, emptyMap(), request );
ExecutionEngine engine = cypherExecutor.getExecutionEngine();
Result result = engine.executeQuery( script, emptyMap(), tc );
resultString = result.resultAsString();
}
catch ( SyntaxException error )
{
resultString = error.getMessage();
}
catch ( Exception exception )
{
log.error( "Unknown error executing cypher query", exception );
resultString = "Error: " + exception.getClass().getSimpleName() + " - " + exception.getMessage();
}
return Pair.of( resultString, null );
}
}
代码示例来源:origin: org.neo4j.doc/neo4j-cypher-docs
@Test
public void testColumnAreInTheRightOrder() throws Exception
{
createTenNodes();
String q = "match (one), (two), (three), (four), (five), (six), (seven), (eight), (nine), (ten) " +
"where id(one) = 1 and id(two) = 2 and id(three) = 3 and id(four) = 4 and id(five) = 5 " +
"and id(six) = 6 and id(seven) = 7 and id(eight) = 8 and id(nine) = 9 and id(ten) = 10 " +
"return one, two, three, four, five, six, seven, eight, nine, ten";
Result result = db.execute( q );
assertThat( result.resultAsString(), matchesPattern( "one.*two.*three.*four.*five.*six.*seven.*eight.*nine.*ten" ) );
}
代码示例来源:origin: org.neo4j.doc/neo4j-cypher-docs
fw.append( "\nResulting in:\n\n" );
fw.append( AsciiDocGenerator.dumpToSeparateFileWithType( new File( DOCS_TARGET ), "intro.result",
createQueryResultSnippet( graphdb.execute( query ).resultAsString() ) ) );
fw.append( "\nResulting in:\n\n" );
fw.append( AsciiDocGenerator.dumpToSeparateFileWithType( new File( DOCS_TARGET ), "intro.result",
createQueryResultSnippet( graphdb.execute( query ).resultAsString() ) ) );
fw.close();
代码示例来源:origin: org.neo4j.examples/neo4j-examples
gen.get().addSnippet( "query1", createCypherSnippet( query ) );
String result = db.execute( query )
.resultAsString();
assertTrue( result.contains("File1") );
gen.get()
gen.get().addSnippet( "query2", createCypherSnippet( query ) );
result = db.execute( query )
.resultAsString();
assertTrue( result.contains("File1") );
assertTrue( result.contains("User1") );
gen.get().addSnippet( "query3", createCypherSnippet( query ) );
result = db.execute( query )
.resultAsString();
assertTrue( result.contains("File1") );
assertTrue( result.contains("File2") );
代码示例来源:origin: org.neo4j.doc/neo4j-cypher-docs
resultString = db.execute( "match (n {name: 'my node'}) return n, n.name" ).resultAsString();
内容来源于网络,如有侵权,请联系作者删除!