use of org.neo4j.procedure.Description in project neo4j-apoc-procedures by neo4j-contrib.
the class Graphs method fromCypher.
@Description("apoc.graph.fromCypher('statement',{params},'name',{properties}) - creates a virtual graph object for later processing")
@Procedure
public Stream<VirtualGraph> fromCypher(@Name("statement") String statement, @Name("params") Map<String, Object> params, @Name("name") String name, @Name("properties") Map<String, Object> properties) {
params = params == null ? Collections.emptyMap() : params;
Set<Node> nodes = new HashSet<>(1000);
Set<Relationship> rels = new HashSet<>(1000);
Map<String, Object> props = new HashMap<>(properties);
db.execute(Cypher.withParamMapping(statement, params.keySet()), params).stream().forEach(row -> {
row.forEach((k, v) -> {
if (!extract(v, nodes, rels)) {
props.put(k, v);
}
});
});
return Stream.of(new VirtualGraph(name, nodes, rels, props));
}
use of org.neo4j.procedure.Description in project neo4j-apoc-procedures by neo4j-contrib.
the class Examples method movies.
@Procedure(mode = Mode.WRITE)
@Description("apoc.example.movies() | Creates the sample movies graph")
public Stream<ProgressInfo> movies() {
long start = System.currentTimeMillis();
String file = "movies.cypher";
Result result = db.execute(Util.readResourceFile(file));
QueryStatistics stats = result.getQueryStatistics();
ProgressInfo progress = new ProgressInfo(file, "example movie database from themoviedb.org", "cypher").update(stats.getNodesCreated(), stats.getRelationshipsCreated(), stats.getPropertiesSet()).done(start);
result.close();
return Stream.of(progress);
}
use of org.neo4j.procedure.Description in project neo4j by neo4j.
the class BuiltInDbmsProcedures method listConfig.
@Admin
@SystemProcedure
@Description("List the currently active config of Neo4j.")
@Procedure(name = "dbms.listConfig", mode = DBMS)
public Stream<ConfigResult> listConfig(@Name(value = "searchString", defaultValue = "") String searchString) {
String lowerCasedSearchString = searchString.toLowerCase();
List<ConfigResult> results = new ArrayList<>();
Config config = graph.getDependencyResolver().resolveDependency(Config.class);
config.getValues().forEach((setting, value) -> {
if (!setting.internal() && setting.name().toLowerCase().contains(lowerCasedSearchString)) {
results.add(new ConfigResult(setting, value));
}
});
return results.stream().sorted(Comparator.comparing(c -> c.name));
}
use of org.neo4j.procedure.Description in project neo4j by neo4j.
the class BuiltInDbmsProcedures method listTransactions.
@SystemProcedure
@Description("List all transactions currently executing at this instance that are visible to the user.")
@Procedure(name = "dbms.listTransactions", mode = DBMS)
public Stream<TransactionStatusResult> listTransactions() throws InvalidArgumentsException {
ZoneId zoneId = getConfiguredTimeZone();
List<TransactionStatusResult> result = new ArrayList<>();
for (DatabaseContext databaseContext : getDatabaseManager().registeredDatabases().values()) {
if (databaseContext.database().isStarted()) {
DatabaseScope dbScope = new DatabaseScope(databaseContext.database().getNamedDatabaseId().name());
Map<KernelTransactionHandle, Optional<QuerySnapshot>> handleQuerySnapshotsMap = new HashMap<>();
for (KernelTransactionHandle tx : getExecutingTransactions(databaseContext)) {
String username = tx.subject().username();
var action = new AdminActionOnResource(SHOW_TRANSACTION, dbScope, new UserSegment(username));
if (isSelfOrAllows(username, action)) {
handleQuerySnapshotsMap.put(tx, tx.executingQuery().map(ExecutingQuery::snapshot));
}
}
TransactionDependenciesResolver transactionBlockerResolvers = new TransactionDependenciesResolver(handleQuerySnapshotsMap);
for (KernelTransactionHandle tx : handleQuerySnapshotsMap.keySet()) {
result.add(new TransactionStatusResult(databaseContext.databaseFacade().databaseName(), tx, transactionBlockerResolvers, handleQuerySnapshotsMap, zoneId));
}
}
}
return result.stream();
}
use of org.neo4j.procedure.Description in project neo4j by neo4j.
the class BuiltInDbmsProcedures method clearAllQueryCaches.
@Admin
@SystemProcedure
@Description("Clears all query caches.")
@Procedure(name = "db.clearQueryCaches", mode = DBMS)
public Stream<StringResult> clearAllQueryCaches() {
QueryExecutionEngine queryExecutionEngine = graph.getDependencyResolver().resolveDependency(QueryExecutionEngine.class);
// this query itself does not count
long numberOfClearedQueries = queryExecutionEngine.clearQueryCaches() - 1;
String result = numberOfClearedQueries == 0 ? "Query cache already empty." : "Query caches successfully cleared of " + numberOfClearedQueries + " queries.";
log.info("Called db.clearQueryCaches(): " + result);
return Stream.of(new StringResult(result));
}
Aggregations