Last active
December 26, 2015 21:09
-
-
Save sblask/7213431 to your computer and use it in GitHub Desktop.
How to read Avro files using Spark.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.avro.generic.GenericRecord | |
import org.apache.avro.mapred.AvroKey | |
import org.apache.avro.mapreduce.AvroKeyInputFormat | |
import org.apache.hadoop.io.NullWritable | |
import org.apache.spark.SparkContext | |
private def readAvro(sparkContext: SparkContext, path: String) = { | |
sparkContext.newAPIHadoopFile[ | |
AvroKey[GenericRecord], | |
NullWritable, | |
AvroKeyInputFormat[GenericRecord] | |
](path) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment