Tabnine Logo
JavaDStream.count
Code IndexAdd Tabnine to your IDE (free)

How to use
count
method
in
org.apache.spark.streaming.api.java.JavaDStream

Best Java code snippets using org.apache.spark.streaming.api.java.JavaDStream.count (Showing top 7 results out of 315)

origin: org.apache.spark/spark-streaming_2.11

@SuppressWarnings("unchecked")
@Test
public void testCount() {
 List<List<Integer>> inputData = Arrays.asList(
   Arrays.asList(1,2,3,4),
   Arrays.asList(3,4,5),
   Arrays.asList(3));
 List<List<Long>> expected = Arrays.asList(
   Arrays.asList(4L),
   Arrays.asList(3L),
   Arrays.asList(1L));
 JavaDStream<Integer> stream = JavaTestUtils.attachTestInputStream(ssc, inputData, 1);
 JavaDStream<Long> count = stream.count();
 JavaTestUtils.attachTestOutputStream(count);
 List<List<Long>> result = JavaTestUtils.runStreams(ssc, 3, 3);
 assertOrderInvariantEquals(expected, result);
}
origin: org.apache.spark/spark-streaming_2.10

@SuppressWarnings("unchecked")
@Test
public void testCount() {
 List<List<Integer>> inputData = Arrays.asList(
   Arrays.asList(1,2,3,4),
   Arrays.asList(3,4,5),
   Arrays.asList(3));
 List<List<Long>> expected = Arrays.asList(
   Arrays.asList(4L),
   Arrays.asList(3L),
   Arrays.asList(1L));
 JavaDStream<Integer> stream = JavaTestUtils.attachTestInputStream(ssc, inputData, 1);
 JavaDStream<Long> count = stream.count();
 JavaTestUtils.attachTestOutputStream(count);
 List<List<Long>> result = JavaTestUtils.runStreams(ssc, 3, 3);
 assertOrderInvariantEquals(expected, result);
}
origin: wankunde/logcount

JavaDStream<Long> nums = lines.count();
nums.foreachRDD(new Function<JavaRDD<Long>, Void>() {
origin: zhang637/kafka_spark_hbase_demo

JavaDStream<Long> nums = lines.count();
nums.foreachRDD(new Function<JavaRDD<Long>, Void>() {
  private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
origin: spirom/learning-spark-with-java

streamOfRecords.count().foreachRDD((rdd, timeStamp) ->
 rdd.foreach(countValue ->
origin: org.apache.spark/spark-streaming_2.10

@SuppressWarnings("unchecked")
@Test
public void testForeachRDD() {
 final LongAccumulator accumRdd = ssc.sparkContext().sc().longAccumulator();
 final LongAccumulator accumEle = ssc.sparkContext().sc().longAccumulator();
 List<List<Integer>> inputData = Arrays.asList(
   Arrays.asList(1,1,1),
   Arrays.asList(1,1,1));
 JavaDStream<Integer> stream = JavaTestUtils.attachTestInputStream(ssc, inputData, 1);
 JavaTestUtils.attachTestOutputStream(stream.count()); // dummy output
 stream.foreachRDD(rdd -> {
  accumRdd.add(1);
  rdd.foreach(i -> accumEle.add(1));
 });
 // This is a test to make sure foreachRDD(VoidFunction2) can be called from Java
 stream.foreachRDD((rdd, time) -> {});
 JavaTestUtils.runStreams(ssc, 2, 2);
 Assert.assertEquals(2, accumRdd.value().intValue());
 Assert.assertEquals(6, accumEle.value().intValue());
}
origin: org.apache.spark/spark-streaming_2.11

@SuppressWarnings("unchecked")
@Test
public void testForeachRDD() {
 final LongAccumulator accumRdd = ssc.sparkContext().sc().longAccumulator();
 final LongAccumulator accumEle = ssc.sparkContext().sc().longAccumulator();
 List<List<Integer>> inputData = Arrays.asList(
   Arrays.asList(1,1,1),
   Arrays.asList(1,1,1));
 JavaDStream<Integer> stream = JavaTestUtils.attachTestInputStream(ssc, inputData, 1);
 JavaTestUtils.attachTestOutputStream(stream.count()); // dummy output
 stream.foreachRDD(rdd -> {
  accumRdd.add(1);
  rdd.foreach(i -> accumEle.add(1));
 });
 // This is a test to make sure foreachRDD(VoidFunction2) can be called from Java
 stream.foreachRDD((rdd, time) -> {});
 JavaTestUtils.runStreams(ssc, 2, 2);
 Assert.assertEquals(2, accumRdd.value().intValue());
 Assert.assertEquals(6, accumEle.value().intValue());
}
org.apache.spark.streaming.api.javaJavaDStreamcount

Popular methods of JavaDStream

  • foreachRDD
  • map
  • mapToPair
  • union
  • filter
  • flatMap
  • dstream
  • countByValue
  • cache
  • transformToPair
  • window
  • transform
  • window,
  • transform,
  • countByValueAndWindow,
  • flatMapToPair,
  • print,
  • reduceByWindow,
  • repartition,
  • glom,
  • mapPartitions

Popular in Java

  • Creating JSON documents from java classes using gson
  • startActivity (Activity)
  • getSharedPreferences (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now