forked from mongodb/mongo-hadoop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Formatting corrections for compliance to sytle guide
- Loading branch information
Bryan Reinero
committed
Dec 3, 2015
1 parent
9ef021f
commit 53467ad
Showing
3 changed files
with
91 additions
and
90 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,9 +23,9 @@ | |
* Created by bryan on 12/3/15. | ||
*/ | ||
public class DataframeExample { | ||
public static void main ( String[] args ) { | ||
public static void main(final String[] args) { | ||
|
||
JavaSparkContext sc = new JavaSparkContext( new SparkConf() ); | ||
JavaSparkContext sc = new JavaSparkContext(new SparkConf()); | ||
// Set configuration options for the MongoDB Hadoop Connector. | ||
Configuration mongodbConfig = new Configuration(); | ||
// MongoInputFormat allows us to read from a live MongoDB instance. | ||
|
@@ -50,14 +50,14 @@ public static void main ( String[] args ) { | |
|
||
new Function<Tuple2<Object, BSONObject>, Message>() { | ||
|
||
public Message call(Tuple2<Object, BSONObject> tuple) { | ||
public Message call(final Tuple2<Object, BSONObject> tuple) { | ||
Message m = new Message(); | ||
BSONObject header = (BSONObject) tuple._2.get("headers"); | ||
|
||
m.setTo( (String) header.get("To") ); | ||
m.setX_From( (String) header.get("From") ); | ||
m.setMessage_ID( (String) header.get( "Message-ID" ) ); | ||
m.setBody( (String) tuple._2.get( "body" ) ); | ||
m.setTo((String) header.get("To")); | ||
m.setxFrom((String) header.get("From")); | ||
m.setMessageID((String) header.get("Message-ID")); | ||
m.setBody((String) tuple._2.get("body")); | ||
|
||
return m; | ||
} | ||
|
@@ -69,11 +69,10 @@ public Message call(Tuple2<Object, BSONObject> tuple) { | |
DataFrame messagesSchema = sqlContext.createDataFrame(messages, Message.class); | ||
messagesSchema.registerTempTable("messages"); | ||
|
||
DataFrame ericsMessages = sqlContext.sql("SELECT to, body FROM messages WHERE to = \"[email protected]\" " ); | ||
DataFrame ericsMessages = sqlContext.sql("SELECT to, body FROM messages WHERE to = \"[email protected]\""); | ||
|
||
ericsMessages.show(); | ||
|
||
|
||
messagesSchema.printSchema(); | ||
} | ||
|
||
|
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
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