use of org.neo4j.kernel.api.procedure.SystemProcedure in project neo4j by neo4j.
the class BuiltInDbmsProcedures method listConnections.
@SystemProcedure
@Description("List all accepted network connections at this instance that are visible to the user.")
@Procedure(name = "dbms.listConnections", mode = DBMS)
public Stream<ListConnectionResult> listConnections() {
NetworkConnectionTracker connectionTracker = getConnectionTracker();
ZoneId timeZone = getConfiguredTimeZone();
return connectionTracker.activeConnections().stream().filter(connection -> isAdminOrSelf(connection.username())).map(connection -> new ListConnectionResult(connection, timeZone));
}
use of org.neo4j.kernel.api.procedure.SystemProcedure in project neo4j by neo4j.
the class BuiltInDbmsProcedures method listFunctions.
@Deprecated(since = "4.3.0", forRemoval = true)
@SystemProcedure
@Description("List all functions in the DBMS.")
@Procedure(name = "dbms.functions", mode = DBMS, deprecatedBy = "SHOW FUNCTIONS command")
public Stream<FunctionResult> listFunctions() {
DependencyResolver resolver = graph.getDependencyResolver();
QueryExecutionEngine queryExecutionEngine = resolver.resolveDependency(QueryExecutionEngine.class);
List<FunctionInformation> providedLanguageFunctions = queryExecutionEngine.getProvidedLanguageFunctions();
var globalProcedures = resolver.resolveDependency(GlobalProcedures.class);
// gets you all functions provided by the query language
Stream<FunctionResult> languageFunctions = providedLanguageFunctions.stream().map(FunctionResult::new);
// gets you all non-aggregating functions that are registered in the db (incl. those from libs like apoc)
Stream<FunctionResult> loadedFunctions = globalProcedures.getAllNonAggregatingFunctions().map(f -> new FunctionResult(f, false));
// gets you all aggregation functions that are registered in the db (incl. those from libs like apoc)
Stream<FunctionResult> loadedAggregationFunctions = globalProcedures.getAllAggregatingFunctions().map(f -> new FunctionResult(f, true));
return Stream.concat(Stream.concat(languageFunctions, loadedFunctions), loadedAggregationFunctions).sorted(Comparator.comparing(a -> a.name));
}
use of org.neo4j.kernel.api.procedure.SystemProcedure in project neo4j by neo4j.
the class BuiltInProcedures method listConstraints.
@Deprecated(since = "4.2.0", forRemoval = true)
@SystemProcedure
@Description("List all constraints in the database.")
@Procedure(name = "db.constraints", mode = READ, deprecatedBy = "SHOW CONSTRAINTS command")
public Stream<ConstraintResult> listConstraints() {
if (callContext.isSystemDatabase()) {
return Stream.empty();
}
SchemaReadCore schemaRead = kernelTransaction.schemaRead().snapshot();
List<ConstraintResult> result = new ArrayList<>();
final List<ConstraintDescriptor> constraintDescriptors = asList(schemaRead.constraintsGetAll());
for (ConstraintDescriptor constraint : constraintDescriptors) {
String description = ConstraintsProcedureUtil.prettyPrint(constraint, kernelTransaction.tokenRead());
String details = constraint.userDescription(kernelTransaction.tokenRead());
result.add(new ConstraintResult(constraint.getName(), description, details));
}
result.sort(Comparator.comparing(r -> r.name));
return result.stream();
}
use of org.neo4j.kernel.api.procedure.SystemProcedure in project neo4j by neo4j.
the class BuiltInProcedures method listLabels.
@SystemProcedure
@Description("List all available labels in the database.")
@Procedure(name = "db.labels", mode = READ)
public Stream<LabelResult> listLabels() {
if (callContext.isSystemDatabase()) {
return Stream.empty();
}
AccessMode mode = kernelTransaction.securityContext().mode();
TokenRead tokenRead = kernelTransaction.tokenRead();
List<LabelResult> labelsInUse;
try (KernelTransaction.Revertable ignore = kernelTransaction.overrideWith(SecurityContext.AUTH_DISABLED)) {
// Get all labels that are in use as seen by a super user
labelsInUse = stream(LABELS.inUse(kernelTransaction)).filter(label -> mode.allowsTraverseNode(tokenRead.nodeLabel(label.name()))).map(LabelResult::new).collect(Collectors.toList());
}
return labelsInUse.stream();
}
use of org.neo4j.kernel.api.procedure.SystemProcedure in project neo4j by neo4j.
the class FulltextProcedures method queryFulltextForNodes.
@SystemProcedure
@Description("Query the given full-text index. Returns the matching nodes, and their Lucene query score, ordered by score. " + "Valid keys for the options map are: 'skip' to skip the top N results; 'limit' to limit the number of results returned.")
@Procedure(name = "db.index.fulltext.queryNodes", mode = READ)
public Stream<NodeOutput> queryFulltextForNodes(@Name("indexName") String name, @Name("queryString") String query, @Name(value = "options", defaultValue = "{}") Map<String, Object> options) throws Exception {
if (callContext.isSystemDatabase()) {
return Stream.empty();
}
IndexDescriptor indexReference = getValidIndex(name);
awaitOnline(indexReference);
EntityType entityType = indexReference.schema().entityType();
if (entityType != NODE) {
throw new IllegalArgumentException("The '" + name + "' index (" + indexReference + ") is an index on " + entityType + ", so it cannot be queried for nodes.");
}
NodeValueIndexCursor cursor = tx.cursors().allocateNodeValueIndexCursor(tx.cursorContext(), tx.memoryTracker());
IndexReadSession indexSession = tx.dataRead().indexReadSession(indexReference);
IndexQueryConstraints constraints = queryConstraints(options);
tx.dataRead().nodeIndexSeek(indexSession, cursor, constraints, PropertyIndexQuery.fulltextSearch(query));
Spliterator<NodeOutput> spliterator = new SpliteratorAdaptor<>() {
@Override
public boolean tryAdvance(Consumer<? super NodeOutput> action) {
while (cursor.next()) {
long nodeReference = cursor.nodeReference();
float score = cursor.score();
NodeOutput nodeOutput = NodeOutput.forExistingEntityOrNull(transaction, nodeReference, score);
if (nodeOutput != null) {
action.accept(nodeOutput);
return true;
}
}
cursor.close();
return false;
}
};
Stream<NodeOutput> stream = StreamSupport.stream(spliterator, false);
return stream.onClose(cursor::close);
}
Aggregations