use of org.neo4j.kernel.api.procedure.SystemProcedure in project neo4j by neo4j.
the class BuiltInProcedures method schemaStatements.
@Deprecated(since = "4.2.0", forRemoval = true)
@SystemProcedure
@Description("List all statements for creating and dropping existing indexes and constraints. " + "Note that only index types introduced before Neo4j 4.3 are included.")
@Procedure(name = "db.schemaStatements", mode = READ, deprecatedBy = "SHOW INDEXES YIELD * command and SHOW CONSTRAINTS YIELD * command")
public Stream<SchemaStatementResult> schemaStatements() throws ProcedureException {
if (callContext.isSystemDatabase()) {
return Stream.empty();
}
SchemaReadCore schemaRead = kernelTransaction.schemaRead().snapshot();
final TokenRead tokenRead = kernelTransaction.tokenRead();
return SchemaStatementProcedure.createSchemaStatementResults(schemaRead, tokenRead).stream();
}
use of org.neo4j.kernel.api.procedure.SystemProcedure in project neo4j by neo4j.
the class BuiltInProcedures method listRelationshipTypes.
@SystemProcedure
@Description("List all available relationship types in the database.")
@Procedure(name = "db.relationshipTypes", mode = READ)
public Stream<RelationshipTypeResult> listRelationshipTypes() {
if (callContext.isSystemDatabase()) {
return Stream.empty();
}
AccessMode mode = kernelTransaction.securityContext().mode();
TokenRead tokenRead = kernelTransaction.tokenRead();
List<RelationshipTypeResult> relTypesInUse;
try (KernelTransaction.Revertable ignore = kernelTransaction.overrideWith(SecurityContext.AUTH_DISABLED)) {
// Get all relTypes that are in use as seen by a super user
relTypesInUse = stream(RELATIONSHIP_TYPES.inUse(kernelTransaction)).filter(type -> mode.allowsTraverseRelType(tokenRead.relationshipType(type.name()))).map(RelationshipTypeResult::new).collect(Collectors.toList());
}
return relTypesInUse.stream();
}
use of org.neo4j.kernel.api.procedure.SystemProcedure in project neo4j by neo4j.
the class BuiltInProcedures method listIndexes.
@Deprecated(since = "4.2.0", forRemoval = true)
@SystemProcedure
@Description("List all indexes in the database.")
@Procedure(name = "db.indexes", mode = READ, deprecatedBy = "SHOW INDEXES command")
public Stream<IndexResult> listIndexes() {
if (callContext.isSystemDatabase()) {
return Stream.empty();
}
TokenRead tokenRead = kernelTransaction.tokenRead();
IndexingService indexingService = resolver.resolveDependency(IndexingService.class);
SchemaReadCore schemaRead = kernelTransaction.schemaRead().snapshot();
List<IndexDescriptor> indexes = asList(schemaRead.indexesGetAll());
List<IndexResult> result = new ArrayList<>();
for (IndexDescriptor index : indexes) {
IndexResult indexResult;
indexResult = asIndexResult(tokenRead, schemaRead, index);
result.add(indexResult);
}
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 FulltextProcedures method queryFulltextForRelationships.
@SystemProcedure
@Description("Query the given full-text index. Returns the matching relationships, 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.queryRelationships", mode = READ)
public Stream<RelationshipOutput> queryFulltextForRelationships(@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 != RELATIONSHIP) {
throw new IllegalArgumentException("The '" + name + "' index (" + indexReference + ") is an index on " + entityType + ", so it cannot be queried for relationships.");
}
RelationshipValueIndexCursor cursor = tx.cursors().allocateRelationshipValueIndexCursor(tx.cursorContext(), tx.memoryTracker());
IndexReadSession indexReadSession = tx.dataRead().indexReadSession(indexReference);
IndexQueryConstraints constraints = queryConstraints(options);
tx.dataRead().relationshipIndexSeek(indexReadSession, cursor, constraints, PropertyIndexQuery.fulltextSearch(query));
Spliterator<RelationshipOutput> spliterator = new SpliteratorAdaptor<>() {
@Override
public boolean tryAdvance(Consumer<? super RelationshipOutput> action) {
while (cursor.next()) {
long relationshipReference = cursor.relationshipReference();
float score = cursor.score();
RelationshipOutput relationshipOutput = RelationshipOutput.forExistingEntityOrNull(transaction, relationshipReference, score);
if (relationshipOutput != null) {
action.accept(relationshipOutput);
return true;
}
}
cursor.close();
return false;
}
};
return StreamSupport.stream(spliterator, false).onClose(cursor::close);
}
use of org.neo4j.kernel.api.procedure.SystemProcedure in project neo4j by neo4j.
the class ProcedureCompiler method compileProcedure.
private CallableProcedure compileProcedure(Class<?> procDefinition, Method method, String warning, boolean fullAccess, QualifiedName procName) throws ProcedureException {
List<FieldSignature> inputSignature = inputSignatureDeterminer.signatureFor(method);
List<FieldSignature> outputSignature = outputSignatureCompiler.fieldSignatures(method);
String description = description(method);
Procedure procedure = method.getAnnotation(Procedure.class);
Mode mode = procedure.mode();
boolean admin = method.isAnnotationPresent(Admin.class);
boolean systemProcedure = method.isAnnotationPresent(SystemProcedure.class);
boolean allowExpiredCredentials = systemProcedure ? method.getAnnotation(SystemProcedure.class).allowExpiredCredentials() : false;
boolean internal = method.isAnnotationPresent(Internal.class);
String deprecated = deprecated(method, procedure::deprecatedBy, "Use of @Procedure(deprecatedBy) without @Deprecated in " + procName);
List<FieldSetter> setters = allFieldInjections.setters(procDefinition);
if (!fullAccess && !config.fullAccessFor(procName.toString())) {
try {
setters = safeFieldInjections.setters(procDefinition);
} catch (ComponentInjectionException e) {
description = describeAndLogLoadFailure(procName);
ProcedureSignature signature = new ProcedureSignature(procName, inputSignature, outputSignature, Mode.DEFAULT, admin, null, new String[0], description, warning, procedure.eager(), false, systemProcedure, internal, allowExpiredCredentials);
return new FailedLoadProcedure(signature);
}
}
ProcedureSignature signature = new ProcedureSignature(procName, inputSignature, outputSignature, mode, admin, deprecated, config.rolesFor(procName.toString()), description, warning, procedure.eager(), false, systemProcedure, internal, allowExpiredCredentials);
return ProcedureCompilation.compileProcedure(signature, setters, method);
}
Aggregations