-1

Can any one help me with the Java equivalent of this?

wordCountRDD.saveAsNewAPIHadoopFile(outputFile,classOf[Text],classOf[IntWritable],classOf[TextOutputFormat[Text,IntWritable]])

I tried below : but it give me error at TextOutputFormat<>(Text,IntWritable) ..

wordCountRDD.saveAsNewAPIHadoopFile(
                        output,
                        Text.class,
                        IntWritable.class,
                        TextOutputFormat<>(Text,IntWritable)
                        context.hadoopConfiguration());
Neethu Lalitha
  • 3,031
  • 4
  • 35
  • 60

1 Answers1

2

Here:

TextOutputFormat<>(Text,IntWritable)

You have to pass the class instead:

TextOutputFormat.class

But note: the java type system doesn't allow you to express something like. TextOutputFormat<Text,IntWritable>.class! See here for why that is.

From that point of view, TextOutputFormat.class seems to be your only option.

GhostCat
  • 137,827
  • 25
  • 176
  • 248
  • 1
    The precise term for this behavior of generics is [type erasure](https://stackoverflow.com/a/339708/5699679) – Avi Aug 14 '19 at 17:47