当前位置: 首页>>代码示例>>Java>>正文


Java JavaStreamingContext.ssc方法代码示例

本文整理汇总了Java中org.apache.spark.streaming.api.java.JavaStreamingContext.ssc方法的典型用法代码示例。如果您正苦于以下问题:Java JavaStreamingContext.ssc方法的具体用法?Java JavaStreamingContext.ssc怎么用?Java JavaStreamingContext.ssc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.spark.streaming.api.java.JavaStreamingContext的用法示例。


在下文中一共展示了JavaStreamingContext.ssc方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import org.apache.spark.streaming.api.java.JavaStreamingContext; //导入方法依赖的package包/类
public static <T, CheckpointMarkT extends CheckpointMark> UnboundedDataset<T> read(
    JavaStreamingContext jssc,
    SerializablePipelineOptions rc,
    UnboundedSource<T, CheckpointMarkT> source,
    String stepName) {

  SparkPipelineOptions options = rc.get().as(SparkPipelineOptions.class);
  Long maxRecordsPerBatch = options.getMaxRecordsPerBatch();
  SourceDStream<T, CheckpointMarkT> sourceDStream =
      new SourceDStream<>(jssc.ssc(), source, rc, maxRecordsPerBatch);

  JavaPairInputDStream<Source<T>, CheckpointMarkT> inputDStream =
      JavaPairInputDStream$.MODULE$.fromInputDStream(sourceDStream,
          JavaSparkContext$.MODULE$.<Source<T>>fakeClassTag(),
              JavaSparkContext$.MODULE$.<CheckpointMarkT>fakeClassTag());

  // call mapWithState to read from a checkpointable sources.
  JavaMapWithStateDStream<Source<T>, CheckpointMarkT, Tuple2<byte[], Instant>,
      Tuple2<Iterable<byte[]>, Metadata>> mapWithStateDStream =
      inputDStream.mapWithState(
          StateSpec
              .function(StateSpecFunctions.<T, CheckpointMarkT>mapSourceFunction(rc, stepName))
              .numPartitions(sourceDStream.getNumPartitions()));

  // set checkpoint duration for read stream, if set.
  checkpointStream(mapWithStateDStream, options);

  // report the number of input elements for this InputDStream to the InputInfoTracker.
  int id = inputDStream.inputDStream().id();
  JavaDStream<Metadata> metadataDStream = mapWithStateDStream.map(new Tuple2MetadataFunction());

  // register ReadReportDStream to report information related to this read.
  new ReadReportDStream(metadataDStream.dstream(), id, getSourceName(source, id), stepName)
      .register();

  // output the actual (deserialized) stream.
  WindowedValue.FullWindowedValueCoder<T> coder =
      WindowedValue.FullWindowedValueCoder.of(
          source.getOutputCoder(),
          GlobalWindow.Coder.INSTANCE);
  JavaDStream<WindowedValue<T>> readUnboundedStream =
      mapWithStateDStream
          .flatMap(new Tuple2byteFlatMapFunction())
          .map(CoderHelpers.fromByteFunction(coder));
  return new UnboundedDataset<>(readUnboundedStream, Collections.singletonList(id));
}
 
开发者ID:apache,项目名称:beam,代码行数:47,代码来源:SparkUnboundedSource.java

示例2: PubsubInputDStream

import org.apache.spark.streaming.api.java.JavaStreamingContext; //导入方法依赖的package包/类
public PubsubInputDStream(final JavaStreamingContext _jssc, final String _subscription, final Integer _batchSize,
		final boolean _decodeData) {
	super(_jssc.ssc(), new PubsubReceiver(_subscription, _batchSize, _decodeData), STRING_CLASS_TAG);
}
 
开发者ID:SignifAi,项目名称:Spark-PubSub,代码行数:5,代码来源:PubsubInputDStream.java

示例3: createStream

import org.apache.spark.streaming.api.java.JavaStreamingContext; //导入方法依赖的package包/类
public static ReceiverInputDStream<String> createStream(JavaStreamingContext jssc, String accessToken,
        BatchRequestBuilder[] batchRequestBuilders) {
    return new FacebookInputDStream(jssc.ssc(), accessToken, batchRequestBuilders, StorageLevel.MEMORY_AND_DISK_2());
}
 
开发者ID:ogidogi,项目名称:laughing-octo-sansa,代码行数:5,代码来源:FacebookUtils.java


注:本文中的org.apache.spark.streaming.api.java.JavaStreamingContext.ssc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。