简体   繁体   English

如何使用 JAVA 获取在 spark 2.3 中写入的行数?

[英]How to get number of rows written in spark 2.3 using JAVA?

I know we can use the use count().我知道我们可以使用使用 count()。 But I'm trying to capture the count using sparkListener.但我正在尝试使用 sparkListener 捕获计数。 But I'm failing to write a proper java code for the same.但我没能写出正确的 java 代码。 I've tried following the exact approach given in this How to implement custom job listener/tracker in Spark?我已经尝试按照如何在 Spark 中实现自定义作业侦听器/跟踪器中给出的确切方法? But I'm not able to reproduce it in JAVA.但我无法在 JAVA 中重现它。 This is something that I've tried.这是我尝试过的事情。

sparkContext.sparkContext().addSparkListener(new SparkListener()
                {
                    @Override
                    private void onTaskEnd(SparkListenerTaskEnd taskEnd){
                        taskEnd.taskInfo().accumulables().name
                    }
                });

But it throws a lot of errors related to override and name.Any help is appreciated.但它会引发很多与覆盖和名称相关的错误。感谢任何帮助。 Thanks.谢谢。

Cannot reduce the visibility of the inherited method from SparkListener无法降低从 SparkListener 继承的方法的可见性

Change override method private to public code should work更改公共代码私有的覆盖方法应该可以工作

sparkContext.sparkContext().addSparkListener(new SparkListener() {
            @Override
            public void onTaskEnd(SparkListenerTaskEnd taskEnd){
                    System.out.println(taskEnd.taskInfo().accumulables());
            }
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM