/** * A helper method to construct a {@link VertexProgram} given the content of the supplied configuration. * The class of the VertexProgram is read from the {@link VertexProgram#VERTEX_PROGRAM} static configuration key. * Once the VertexProgram is constructed, {@link VertexProgram#loadState} method is called with the provided graph and configuration. * * @param graph The graph that the vertex program will execute against * @param configuration A configuration with requisite information to build a vertex program * @param <V> The vertex program type * @return the newly constructed vertex program */ public static <V extends VertexProgram> V createVertexProgram(final Graph graph, final Configuration configuration) { try { final Class<V> vertexProgramClass = (Class) Class.forName(configuration.getString(VERTEX_PROGRAM)); final Constructor<V> constructor = vertexProgramClass.getDeclaredConstructor(); constructor.setAccessible(true); final V vertexProgram = constructor.newInstance(); vertexProgram.loadState(graph, configuration); return vertexProgram; } catch (final Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public void loadState(final Graph graph, final Configuration configuration) { VertexProgram.super.loadState(graph, configuration); this.traversal = PureTraversal.loadState(configuration, VertexProgramStep.ROOT_TRAVERSAL, graph); this.haltedTraversers = TraversalVertexProgram.loadHaltedTraversers(configuration); this.programStep = new TraversalMatrix<>(this.traversal.get()).getStepById(configuration.getString(ProgramVertexProgramStep.STEP_ID)); this.memoryComputeKeys.addAll(MemoryTraversalSideEffects.getMemoryComputeKeys(this.traversal.get())); this.memoryComputeKeys.add(MemoryComputeKey.of(TraversalVertexProgram.HALTED_TRAVERSERS, Operator.addAll, false, false)); this.memoryComputeKeys.add(MemoryComputeKey.of(TraversalVertexProgram.ACTIVE_TRAVERSERS, Operator.addAll, true, true)); }
/** * A helper method to construct a {@link VertexProgram} given the content of the supplied configuration. * The class of the VertexProgram is read from the {@link VertexProgram#VERTEX_PROGRAM} static configuration key. * Once the VertexProgram is constructed, {@link VertexProgram#loadState} method is called with the provided graph and configuration. * * @param graph The graph that the vertex program will execute against * @param configuration A configuration with requisite information to build a vertex program * @param <V> The vertex program type * @return the newly constructed vertex program */ public static <V extends VertexProgram> V createVertexProgram(final Graph graph, final Configuration configuration) { try { final Class<V> vertexProgramClass = (Class) Class.forName(configuration.getString(VERTEX_PROGRAM)); final Constructor<V> constructor = vertexProgramClass.getDeclaredConstructor(); constructor.setAccessible(true); final V vertexProgram = constructor.newInstance(); vertexProgram.loadState(graph, configuration); return vertexProgram; } catch (final Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public void loadState(final Graph graph, final Configuration configuration) { VertexProgram.super.loadState(graph, configuration); this.traversal = PureTraversal.loadState(configuration, VertexProgramStep.ROOT_TRAVERSAL, graph); this.haltedTraversers = TraversalVertexProgram.loadHaltedTraversers(configuration); this.programStep = new TraversalMatrix<>(this.traversal.get()).getStepById(configuration.getString(ProgramVertexProgramStep.STEP_ID)); this.memoryComputeKeys.addAll(MemoryTraversalSideEffects.getMemoryComputeKeys(this.traversal.get())); this.memoryComputeKeys.add(MemoryComputeKey.of(TraversalVertexProgram.HALTED_TRAVERSERS, Operator.addAll, false, false)); this.memoryComputeKeys.add(MemoryComputeKey.of(TraversalVertexProgram.ACTIVE_TRAVERSERS, Operator.addAll, true, true)); }