use of apoc.result.RowResult in project neo4j-apoc-procedures by neo4j-contrib.
the class Bolt method load.
@Procedure()
@Description("apoc.bolt.load(url-or-key, statement, params, config) - access to other databases via bolt for read")
public Stream<RowResult> load(@Name("url") String url, @Name("statement") String statement, @Name(value = "params", defaultValue = "{}") Map<String, Object> params, @Name(value = "config", defaultValue = "{}") Map<String, Object> config) throws URISyntaxException {
if (params == null)
params = Collections.emptyMap();
if (config == null)
config = Collections.emptyMap();
boolean virtual = (boolean) config.getOrDefault("virtual", false);
boolean addStatistics = (boolean) config.getOrDefault("statistics", false);
boolean readOnly = (boolean) config.getOrDefault("readOnly", true);
Config driverConfig = toDriverConfig(config.getOrDefault("driverConfig", map()));
UriResolver uri = new UriResolver(url, "bolt");
uri.initialize();
try (Driver driver = GraphDatabase.driver(uri.getConfiguredUri(), uri.getToken(), driverConfig);
Session session = driver.session()) {
if (addStatistics)
return Stream.of(new RowResult(toMap(runStatement(statement, session, params, readOnly).summary().counters())));
else
return getRowResultStream(virtual, session, params, statement, readOnly);
} catch (Exception e) {
throw new RuntimeException("It's not possible to create a connection due to: " + e.getMessage());
}
}
Aggregations