use of org.neo4j.collection.RawIterator in project neo4j by neo4j.
the class OperationsFacade method callProcedure.
private RawIterator<Object[], ProcedureException> callProcedure(QualifiedName name, Object[] input, final AccessMode override) throws ProcedureException {
statement.assertOpen();
final SecurityContext procedureSecurityContext = tx.securityContext().withMode(override);
final RawIterator<Object[], ProcedureException> procedureCall;
try (KernelTransaction.Revertable ignore = tx.overrideWith(procedureSecurityContext)) {
BasicContext ctx = new BasicContext();
ctx.put(Context.KERNEL_TRANSACTION, tx);
ctx.put(Context.THREAD, Thread.currentThread());
ctx.put(Context.SECURITY_CONTEXT, procedureSecurityContext);
procedureCall = procedures.callProcedure(ctx, name, input);
}
return new RawIterator<Object[], ProcedureException>() {
@Override
public boolean hasNext() throws ProcedureException {
try (KernelTransaction.Revertable ignore = tx.overrideWith(procedureSecurityContext)) {
return procedureCall.hasNext();
}
}
@Override
public Object[] next() throws ProcedureException {
try (KernelTransaction.Revertable ignore = tx.overrideWith(procedureSecurityContext)) {
return procedureCall.next();
}
}
};
}
use of org.neo4j.collection.RawIterator in project neo4j by neo4j.
the class BoltChannelAutoReadLimiterIT method installSleepProcedure.
private static void installSleepProcedure(GraphDatabaseService db) throws ProcedureException {
GraphDatabaseAPI dbApi = (GraphDatabaseAPI) db;
dbApi.getDependencyResolver().resolveDependency(GlobalProcedures.class).register(new CallableProcedure.BasicProcedure(procedureSignature("boltissue", "sleep").in("data", Neo4jTypes.NTString).out(ProcedureSignature.VOID).build()) {
@Override
public RawIterator<AnyValue[], ProcedureException> apply(Context context, AnyValue[] objects, ResourceTracker resourceTracker) throws ProcedureException {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
throw new ProcedureException(Status.General.UnknownError, e, "Interrupted");
}
return RawIterator.empty();
}
});
}
use of org.neo4j.collection.RawIterator in project neo4j by neo4j.
the class BuiltInDbmsProceduresIT method listCapabilities.
@Test
void listCapabilities() throws KernelException {
QualifiedName procedureName = procedureName("dbms", "listCapabilities");
int procedureId = procs().procedureGet(procedureName).id();
RawIterator<AnyValue[], ProcedureException> callResult = procs().procedureCallDbms(procedureId, new AnyValue[] {}, ProcedureCallContext.EMPTY);
List<AnyValue[]> capabilities = asList(callResult);
List<String> capabilityNames = capabilities.stream().map(c -> ((TextValue) c[0]).stringValue()).collect(Collectors.toList());
assertThat(capabilityNames).containsExactlyInAnyOrder(TestCapabilities.my_custom_capability.name().fullName(), TestCapabilities.my_dynamic_capability.name().fullName());
}
use of org.neo4j.collection.RawIterator in project neo4j by neo4j.
the class BuiltInDbmsProceduresIT method listCapabilitiesShouldNotReturnBlocked.
@Test
void listCapabilitiesShouldNotReturnBlocked() throws KernelException {
// set blocked capabilities
Config config = dependencyResolver.resolveDependency(Config.class);
config.set(CapabilitiesSettings.dbms_capabilities_blocked, List.of("my.**"));
QualifiedName procedureName = procedureName("dbms", "listCapabilities");
int procedureId = procs().procedureGet(procedureName).id();
RawIterator<AnyValue[], ProcedureException> callResult = procs().procedureCallDbms(procedureId, new AnyValue[] {}, ProcedureCallContext.EMPTY);
List<AnyValue[]> capabilities = asList(callResult);
List<String> capabilityNames = capabilities.stream().map(c -> ((TextValue) c[0]).stringValue()).collect(Collectors.toList());
assertThat(capabilityNames).doesNotContain(TestCapabilities.my_custom_capability.name().fullName());
}
use of org.neo4j.collection.RawIterator in project neo4j by neo4j.
the class CsvInputTest method shouldReportDuplicateSourceFileUsedAsBothNodeAndRelationshipSourceFile.
@Test
public void shouldReportDuplicateSourceFileUsedAsBothNodeAndRelationshipSourceFile() {
// given
String sourceDescription = "The single data source";
Supplier<CharReadable> nodeHeaderSource = () -> wrap(dataWithSourceDescription(":ID", "node source"), 3);
Supplier<CharReadable> relationshipHeaderSource = () -> wrap(dataWithSourceDescription(":START_ID,:END_ID,:TYPE", "relationship source"), 10);
Supplier<CharReadable> source = () -> wrap(dataWithSourceDescription("1,2,3", sourceDescription), 6);
Iterable<DataFactory> nodeData = datas(config -> new Data() {
@Override
public RawIterator<CharReadable, IOException> stream() {
return asRawIterator(iterator(nodeHeaderSource.get(), source.get()));
}
@Override
public Decorator decorator() {
return NO_DECORATOR;
}
});
Iterable<DataFactory> relationshipData = datas(config -> new Data() {
@Override
public RawIterator<CharReadable, IOException> stream() {
return asRawIterator(iterator(relationshipHeaderSource.get(), source.get()));
}
@Override
public Decorator decorator() {
return NO_DECORATOR;
}
});
CsvInput.Monitor monitor = mock(CsvInput.Monitor.class);
// when
new CsvInput(nodeData, defaultFormatNodeFileHeader(), relationshipData, defaultFormatRelationshipFileHeader(), IdType.INTEGER, COMMAS, monitor, INSTANCE);
// then
verify(monitor).duplicateSourceFile(sourceDescription);
}
Aggregations