任何人都可以解释RecordReader如何实际工作?这些方法如何nextkeyvalue(),getCurrentkey()并getprogress()在程序开始执行后工作?
我一直在尝试编写一些代码来使用MapReduce查找数字的平均值.
我试图使用全局计数器来达到我的目标,但我无法在map我的Mapper方法中设置计数器值,我也无法在reduce我的Reducer方法中检索计数器值.
我是否必须使用全局计数器map(例如使用incrCounter(key, amount)提供的Reporter)?或者你会建议任何不同的逻辑来获得一些数字的平均值?
我正在尝试将JavaPairRDD写入本地系统中的文件。代码如下:
JavaPairDStream<String, Integer> wordCounts = words.mapToPair(
new PairFunction<String, String, Integer>() {
@Override
public Tuple2<String, Integer> call(String s) {
return new Tuple2<String, Integer>(s, 1);
}
}).reduceByKey(new Function2<Integer, Integer, Integer>() {
@Override
public Integer call(Integer i1, Integer i2) {
return i1 + i2;
}
});
wordCounts.dstream().saveAsTextFiles("/home/laxmikant/Desktop/teppppp", "txt");
Run Code Online (Sandbox Code Playgroud)
我正在尝试将日志或单词计数保存在文件中。但是它不能保存在本地文件中(不是HDFS)。
我也尝试使用以下方式保存在HDFS上
saveAsHadoopFiles("hdfs://10.42.0.1:54310/stream","txt")
Run Code Online (Sandbox Code Playgroud)
上面的行未写入文件。有人可以告诉解决方案吗?关于stackoverflow的各种解决方案不起作用。
streaming hadoop-streaming apache-spark spark-streaming pyspark
我正在尝试使用BatchGraph在Titan中加载数据.使用TitanGraph作为对象参数.
根据Tinkerpop的Batch Implementation,这是实现应该如何:
TitanGraph g = TitanFactory.open("titan-cassandra.properties");
BatchGraph bgraph = new BatchGraph( g, VertexIDType.STRING, 1000);
Run Code Online (Sandbox Code Playgroud)
但是在BatchGraph构造函数中需要TrasanctionalGraph对象.所以,当我把它投射为:
TitanGraph g = TitanFactory.open("titan-cassandra.properties");
BatchGraph bgraph = new BatchGraph( (TransactionalGraph) g, VertexIDType.STRING, 1000)
Run Code Online (Sandbox Code Playgroud)
这会出现以下错误:
Exception in thread "main" java.lang.ClassCastException:
com.thinkaurelius.titan.graphdb.database.StandardTitanGraph cannot be cast to com.tinkerpop.blueprints.TransactionalGraph
Run Code Online (Sandbox Code Playgroud)
在这种情况下如何使用BatchGraph?如何处理?
我正在使用Titan 1.0.0和Blueprints 2.7.0以及cassandra 2.2.4版.
谢谢.
hadoop ×2
mapreduce ×2
apache-spark ×1
cassandra ×1
database ×1
distributed ×1
java ×1
pyspark ×1
streaming ×1
titan ×1