0

Here is a demo for Spark read Protobuf in scala: SparkReadProtoBuf.scala

I don't know how can I do the same in Java as in Scala: classOf[BinaryWritable[MyProtocolBuffers.MyProtocolBuffer]]

And I use the following java code has no effect:

JavaPairRDD<LongWritable, ProtobufWritable> rdd = sc.newAPIHadoopFile(
            path,
            MultiInputFormat.class,
            LongWritable.class,
            ProtobufWritable.class,
            conf);

Thanks very much.

secfree
  • 4,357
  • 2
  • 28
  • 36
  • It seems is not the reason of my java code. I run the scala code and it has no effect too, just as no data in path, and with no other log information. Sorry. – secfree Jun 19 '16 at 08:30

1 Answers1

0

You should be using

BinaryWritable.class instead of ProtobufWritable.class

this link might be of help

How to do MyClass<String>.class in Java?

Community
  • 1
  • 1
Akash
  • 355
  • 4
  • 11
  • Thanks, I have also tried `BinaryWritable.class`. Perhaps it's not the real problem of my program. – secfree Jun 18 '16 at 11:58