Created
April 5, 2016 22:35
-
-
Save jonathanmv/c6cf31f0dd44a59e06ca4d1ae8a6ef67 to your computer and use it in GitHub Desktop.
Calls a converter giving it the json string and emits the converted thrift object
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
package jonathanmv.storage; | |
import java.io.IOException; | |
import org.apache.hadoop.io.Text; | |
import org.apache.hadoop.mapreduce.Mapper; | |
import org.json.simple.parser.ParseException; | |
public class JsonToThriftMapper extends Mapper<Object, Text, Void, FriendsEdge> { | |
public void map(Object key, Text value, Context context) throws IOException, InterruptedException { | |
String jsonString = value.toString(); | |
try { | |
JsonToThriftConverter converter = new JsonToThriftConverter(jsonString); | |
FriendsEdge thriftObject = converter.convert(); | |
context.write(null, thriftObject); | |
} catch (ParseException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment