/** * Variant of {@link #preferLocalParallelismOne(ProcessorSupplier)} where * the supplied {@code DistributedSupplier<Processor>} will be * wrapped into a {@link ProcessorSupplier}. */ @Nonnull static ProcessorMetaSupplier preferLocalParallelismOne( @Nonnull DistributedSupplier<? extends Processor> procSupplier ) { return of(ProcessorSupplier.of(procSupplier), 1); }
public static ProcessorTransform customProcessorTransform( @Nonnull String name, @Nonnull Transform upstream, @Nonnull DistributedSupplier<Processor> createProcessorFn ) { return new ProcessorTransform(name, upstream, ProcessorSupplier.of(createProcessorFn)); }
/** * Factory method that wraps the given {@code Supplier<Processor>} * and uses it as the supplier of all {@code Processor} instances. * Specifically, returns a meta-supplier that will always return the * result of calling {@link ProcessorSupplier#of(DistributedSupplier)}. * * @param procSupplier the supplier of processors * @param preferredLocalParallelism the value to return from {@link #preferredLocalParallelism()} */ @Nonnull static ProcessorMetaSupplier of( @Nonnull DistributedSupplier<? extends Processor> procSupplier, int preferredLocalParallelism ) { return of(ProcessorSupplier.of(procSupplier), preferredLocalParallelism); }
public static <T> ProcessorMetaSupplier supplier( @Nonnull String connectionURL, @Nonnull String query, @Nonnull DistributedFunction<? super ResultSet, ? extends T> mapOutputFn ) { return ProcessorMetaSupplier.forceTotalParallelismOne(ProcessorSupplier.of(() -> new ReadJdbcP<>( () -> DriverManager.getConnection(connectionURL), (connection, parallelism, index) -> { PreparedStatement statement = connection.prepareStatement(query); try { return statement.executeQuery(); } catch (SQLException e) { statement.close(); throw e; } }, mapOutputFn) )); }
public static ProcessorMetaSupplier streamTwitterP(Properties properties, List<String> terms) { return preferLocalParallelismOne(ProcessorSupplier.of(() -> new StreamTwitterP(properties, terms))); }
public static ProcessorMetaSupplier metaSupplier(String listName, ClientConfig clientConfig) { String clientXml = asXmlString(clientConfig); return forceTotalParallelismOne( ProcessorSupplier.of(() -> { return new ReadIListP(listName, clientXml); }), listName ); } }
checkSerializable(destroyFn, "destroyFn"); checkNotNegative(preferredLocalParallelism + 1, "preferredLocalParallelism must >= -1"); ProcessorSupplier procSup = ProcessorSupplier.of( () -> new ConvenientSourceP<>( createFn,
checkSerializable(destroyFn, "destroyFn"); checkNotNegative(preferredLocalParallelism + 1, "preferredLocalParallelism must >= -1"); ProcessorSupplier procSup = ProcessorSupplier.of( () -> new ConvenientSourceP<S, T>( createFn,