org.neo4j.kernel.impl.proc.Procedures类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(95)

本文整理了Java中org.neo4j.kernel.impl.proc.Procedures类的一些代码示例,展示了Procedures类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Procedures类的具体详情如下:
包路径:org.neo4j.kernel.impl.proc.Procedures
类名称:Procedures

Procedures介绍

[英]This is the coordinating service for procedures in the database. It loads procedures from a specified directory at startup, but also allows programmatic registration of them - and then, of course, allows invoking procedures.
[中]这是数据库中程序的协调服务。它在启动时从指定目录加载过程,但也允许对它们进行编程注册——当然,还允许调用过程。

代码示例

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldFailCompileProcedureWithReadConflict() throws Throwable
{
  exception.expect( ProcedureException.class );
  exception.expectMessage( "Conflicting procedure annotation, cannot use PerformsWrites and mode" );
  procs.registerProcedure( ProcedureWithReadConflictAnnotation.class );
}

代码示例来源:origin: neo4j/neo4j

public static AutoCloseable setupDataCollector( Procedures procedures,
                          JobScheduler jobScheduler,
                          Kernel kernel,
                          Monitors monitors,
                          ValueMapper.JavaMapper valueMapper ) throws KernelException
  {
    Preconditions.checkState( kernel != null, "Kernel was null" );
    DataCollector dataCollector = new DataCollector( kernel, jobScheduler, monitors, valueMapper );
    procedures.registerComponent( DataCollector.class, ctx -> dataCollector, false );
    procedures.registerProcedure( DataCollectorProcedures.class );
    return dataCollector;
  }
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldNotAllowRegisteringConflictingName() throws Throwable
{
  // Given
  procs.register( procedure );
  // Expect
  exception.expect( ProcedureException.class );
  exception.expectMessage( "Unable to register procedure, because the name `org.myproc` is already in use." );
  // When
  procs.register( procedure );
}

代码示例来源:origin: neo4j/neo4j

@SuppressWarnings( "deprecation" )
  public void applyTo( Procedures procedures ) throws KernelException
  {
    for ( Class<?> cls : procs )
    {
      procedures.registerProcedure( cls );
    }

    for ( Class<?> cls : functions )
    {
      procedures.registerFunction( cls );
    }

    for ( Class<?> cls : aggregationFunctions )
    {
      procedures.registerAggregationFunction( cls );
    }
  }
}

代码示例来源:origin: neo4j/neo4j

public void registerProcedures( Procedures procedures, ProcedureConfig procedureConfig ) throws KernelException
{
  procedures.registerProcedure( org.neo4j.kernel.builtinprocs.BuiltInProcedures.class );
  procedures.registerProcedure( org.neo4j.kernel.builtinprocs.TokenProcedures.class );
  procedures.registerProcedure( org.neo4j.kernel.builtinprocs.BuiltInDbmsProcedures.class );
  procedures.registerBuiltInFunctions( org.neo4j.kernel.builtinprocs.BuiltInFunctions.class );
  registerTemporalFunctions( procedures, procedureConfig );
  registerEditionSpecificProcedures( procedures );
}

代码示例来源:origin: neo4j/neo4j

private static void installSleepProcedure( GraphDatabaseService db ) throws ProcedureException
{
  GraphDatabaseAPI dbApi = (GraphDatabaseAPI) db;
  dbApi.getDependencyResolver().resolveDependency( Procedures.class ).register(
      new CallableProcedure.BasicProcedure(
          procedureSignature( "boltissue", "sleep" )
              .in( "data", Neo4jTypes.NTString )
              .out( ProcedureSignature.VOID )
              .build() )
      {
        @Override
        public RawIterator<Object[],ProcedureException> apply(
            Context context, Object[] objects, ResourceTracker resourceTracker ) throws ProcedureException
        {
          try
          {
            Thread.sleep( 50 );
          }
          catch ( InterruptedException e )
          {
            throw new ProcedureException( Status.General.UnknownError, e, "Interrupted" );
          }
          return RawIterator.empty();
        }
      } );
}

代码示例来源:origin: neo4j/neo4j

@Description( "List all user functions in the DBMS." )
@Procedure( name = "dbms.functions", mode = DBMS )
public Stream<FunctionResult> listFunctions()
{
  securityContext.assertCredentialsNotExpired();
  return graph.getDependencyResolver().resolveDependency( Procedures.class ).getAllFunctions().stream()
      .sorted( Comparator.comparing( a -> a.name().toString() ) )
      .map( FunctionResult::new );
}

代码示例来源:origin: neo4j/neo4j

@Description( "List all procedures in the DBMS." )
@Procedure( name = "dbms.procedures", mode = DBMS )
public Stream<ProcedureResult> listProcedures()
{
  securityContext.assertCredentialsNotExpired();
  return graph.getDependencyResolver().resolveDependency( Procedures.class ).getAllProcedures().stream()
      .sorted( Comparator.comparing( a -> a.name().toString() ) )
      .map( ProcedureResult::new );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldBeAbleToUseResultsOfPointProcedureAsInputToDistanceFunction() throws Exception
{
  // given procedure that produces a point
  Procedures procedures =
      graphDb.getDependencyResolver().resolveDependency( Procedures.class );
  procedures.registerProcedure( PointProcs.class );
  // when calling procedure that produces a point
  Result result = graphDb.execute(
      "CALL spatial.point(144.317718, -37.031738) YIELD point " +
      "RETURN distance(point({longitude: 144.317718, latitude: -37.031738}), point) AS dist" );
  // then
  Double dist = (Double) result.next().get( "dist" );
  assertThat( dist, equalTo( 0.0 ) );
}

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

public static void registerProcedure(GraphDatabaseService db, Class<?>...procedures) throws KernelException {
  Procedures proceduresService = ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency(Procedures.class);
  for (Class<?> procedure : procedures) {
    proceduresService.registerProcedure(procedure,true);
    proceduresService.registerFunction(procedure, true);
    proceduresService.registerAggregationFunction(procedure, true);
  }
}

代码示例来源:origin: com.buschmais.jqassistant.neo4jserver/neo4jv3

void register() {
    LOGGER.info("Registering APOC procedures & functions.");
    Procedures procedures = graphDatabaseAPI.getDependencyResolver().resolveDependency(Procedures.class);
    for (Class<?> procedureType : PROCEDURE_TYPES) {
      try {
        LOGGER.debug("Registering procedure class " + procedureType.getName());
        procedures.registerProcedure(procedureType);
      } catch (KernelException e) {
        LOGGER.warn("Cannot register procedure class " + procedureType.getName(), e);
      }
    }
    for (Class<?> functionType : FUNCTION_TYPES) {
      try {
        LOGGER.debug("Registering function class " + functionType.getName());
        procedures.registerFunction(functionType);
      } catch (KernelException e) {
        LOGGER.warn("Cannot register function class " + functionType.getName(), e);
      }
    }
  }
}

代码示例来源:origin: graphaware/neo4j-nlp

@Before
public void registerFunction() throws Exception {
  ((GraphDatabaseAPI) getDatabase()).getDependencyResolver().resolveDependency(Procedures.class).registerFunction(TagOccurrenceFunctions.class);
}

代码示例来源:origin: neo4j/neo4j

/**
 * Register a new function. This method must not be called concurrently with {@link #procedure(QualifiedName)}.
 * @param function the function.
 */
public void register( CallableUserFunction function ) throws ProcedureException
{
  register( function, false );
}

代码示例来源:origin: org.neo4j/neo4j-causal-clustering

@Override
public void registerEditionSpecificProcedures( Procedures procedures ) throws KernelException
{
  procedures.registerProcedure( EnterpriseBuiltInDbmsProcedures.class, true );
  procedures.registerProcedure( EnterpriseBuiltInProcedures.class, true );
  procedures.register( new ReadReplicaRoleProcedure() );
  procedures.register( new ClusterOverviewProcedure( topologyService, logProvider ) );
}

代码示例来源:origin: neo4j/neo4j

/**
 * Register a new internal procedure defined with annotations on a java class.
 * @param proc the procedure class
 */
public void registerProcedure( Class<?> proc ) throws KernelException
{
  registerProcedure( proc, false );
}

代码示例来源:origin: neo4j/neo4j

@Before
public void setup() throws Exception
  procs.registerComponent( KernelTransaction.class, ctx -> ctx.get( KERNEL_TRANSACTION ), false );
  procs.registerComponent( DependencyResolver.class, ctx -> ctx.get( DEPENDENCY_RESOLVER ), false );
  procs.registerComponent( GraphDatabaseAPI.class, ctx -> ctx.get( GRAPHDATABASEAPI ), false );
  procs.registerComponent( SecurityContext.class, ctx -> ctx.get( SECURITY_CONTEXT ), true );
  procs.registerComponent( Log.class, ctx -> ctx.get( LOG), false );
  procs.registerType( Node.class, NTNode );
  procs.registerType( Relationship.class, NTRelationship );
  procs.registerType( Path.class, NTPath );
  procs.registerProcedure( BuiltInProcedures.class );
  procs.registerProcedure( BuiltInDbmsProcedures.class );

代码示例来源:origin: org.neo4j/neo4j-causal-clustering

@Override
public void registerEditionSpecificProcedures( Procedures procedures ) throws KernelException
{
  procedures.registerProcedure( EnterpriseBuiltInDbmsProcedures.class, true );
  procedures.registerProcedure( EnterpriseBuiltInProcedures.class, true );
  procedures.register( new LegacyGetServersProcedure( topologyService, consensusModule.raftMachine(), config, logProvider ) );
  if ( config.get( CausalClusteringSettings.multi_dc_license ) )
  {
    procedures.register( new GetServersProcedureForMultiDC( getLoadBalancingProcessor() ) );
  }
  else
  {
    procedures.register( new GetServersProcedureForSingleDC( topologyService, consensusModule.raftMachine(),
        config, logProvider ) );
  }
  procedures.register( new GetRoutersForAllDatabasesProcedure( topologyService, config ) );
  procedures.register( new GetRoutersForDatabaseProcedure( topologyService, config ) );
  procedures.register( new ClusterOverviewProcedure( topologyService, logProvider ) );
  procedures.register( new CoreRoleProcedure( consensusModule.raftMachine() ) );
  procedures.register( new InstalledProtocolsProcedure( clientInstalledProtocols, serverInstalledProtocols ) );
  procedures.registerComponent( Replicator.class, x -> replicationModule.getReplicator(), false );
  procedures.registerProcedure( ReplicationBenchmarkProcedure.class );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void deprecatedProcedureResultField() throws Exception
{
  db().getDependencyResolver().provideDependency( Procedures.class ).get().registerProcedure( TestProcedures.class );
  Stream.of( "CYPHER 3.5" ).forEach(
      version -> assertNotifications(
          version + "explain CALL changedProc() YIELD oldField RETURN oldField",
          containsItem( deprecatedProcedureReturnFieldWarning )
      ) );
}

代码示例来源:origin: com.graphaware.neo4j/tests

public static void registerAllProceduresAndFunctions(Procedures procedures) throws Exception {
  for (Class cls : proceduresAndFunctionsOnClassPath()) {
    procedures.registerProcedure(cls);
    procedures.registerFunction(cls);
  }
}

代码示例来源:origin: neo4j/neo4j

new Procedures( facade, new SpecialBuiltInProcedures( Version.getNeo4jVersion(), platform.databaseInfo.edition.toString() ), pluginDir,
        internalLog, procedureConfig );
platform.life.add( procedures );
platform.dependencies.satisfyDependency( procedures );
procedures.registerType( Node.class, NTNode );
procedures.registerType( Relationship.class, NTRelationship );
procedures.registerType( Path.class, NTPath );
procedures.registerType( Geometry.class, NTGeometry );
procedures.registerType( Point.class, NTPoint );
procedures.registerComponent( Log.class, ctx -> proceduresLog, true );
procedures.registerComponent( ProcedureTransaction.class, new ProcedureTransactionProvider(), true );
procedures.registerComponent( org.neo4j.procedure.TerminationGuard.class, new TerminationGuardProvider(), true );
procedures.registerComponent( DependencyResolver.class, ctx -> ctx.get( DEPENDENCY_RESOLVER ), false );
procedures.registerComponent( KernelTransaction.class, ctx -> ctx.get( KERNEL_TRANSACTION ), false );
procedures.registerComponent( GraphDatabaseAPI.class, ctx -> ctx.get( DATABASE_API ), false );
procedures.registerComponent( SecurityContext.class, ctx -> ctx.get( SECURITY_CONTEXT ), true );

相关文章