Skip to content

Commit

Permalink
Formatting corrections for compliance to sytle guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Reinero committed Dec 3, 2015
1 parent 9ef021f commit 53467ad
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}
Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
*/
public class Enron {

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.
Expand All @@ -49,42 +49,43 @@ public static void main ( String[] args ) {

JavaRDD<String> edges = documents.flatMap(

new FlatMapFunction<Tuple2<Object, BSONObject>, String >() {
new FlatMapFunction<Tuple2<Object, BSONObject>, String>() {

@Override
public Iterable<String> call(Tuple2<Object, BSONObject> t) throws Exception {
public Iterable<String> call(final Tuple2<Object, BSONObject> t) throws Exception {

BSONObject header = (BSONObject) t._2.get("headers");
String to = (String) header.get("To");
String from = (String) header.get("From");

// each tuple in the set is an individual from|to pair
//JavaPairRDD< String, Integer > tuples = new JavaPairRDD<String, Integer>();
//JavaPairRDD<String, Integer> tuples = new JavaPairRDD<String, Integer>();
List<String> tuples = new ArrayList<String>();

if ( to != null && !to.isEmpty() )
if (to != null && !to.isEmpty()) {
for (String recipient : to.split(",")) {
String s = recipient.trim();
if (s.length() > 0) {
tuples.add( from + "|" + s );
tuples.add(from + "|" + s);
}
}
}
return tuples;
}
}
);

JavaPairRDD<String, Integer> pairs = edges.mapToPair(
new PairFunction<String, String, Integer>() {
public Tuple2<String, Integer> call(String s) {
public Tuple2<String, Integer> call(final String s) {
return new Tuple2<String, Integer>(s, 1);
}
}
);

JavaPairRDD<String, Integer> counts = pairs.reduceByKey(
new Function2<Integer, Integer, Integer>() {
public Integer call(Integer a, Integer b) {
public Integer call(final Integer a, final Integer b) {
return a + b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,168 +3,169 @@
/**
* Created by bryan on 12/3/15.
*/

public class Message {

private String id;
private String body;
private String mailbox;
private String filename;
private String X_cc;
private String Subject;
private String X_Folder;
private String Content_Transfer_Encoding;
private String X_bcc;
private String To;
private String X_Origin;
private String X_FileName;
private String X_From;
private String Date;
private String X_To;
private String Message_ID;
private String Content_Type;
private String Mime_Version;
private String xCC;
private String subject;
private String xFolder;
private String contentTransferEncoding;
private String xBcc;
private String to;
private String xOrigin;
private String xFilename;
private String xFrom;
private String date;
private String xTo;
private String messageID;
private String contentType;
private String mimeVersion;

public String getId() {
return id;
}

public void setId(String id) {
public void setId(final String id) {
this.id = id;
}

public String getBody() {
return body;
}

public void setBody(String body) {
public void setBody(final String body) {
this.body = body;
}

public String getMailbox() {
return mailbox;
}

public void setMailbox(String mailbox) {
public void setMailboxfinal(final String mailbox) {
this.mailbox = mailbox;
}

public String getFilename() {
return filename;
}

public void setFilename(String filename) {
public void setFilename(final String filename) {
this.filename = filename;
}

public String getX_cc() {
return X_cc;
public String getxCC() {
return xCC;
}

public void setX_cc(String x_cc) {
X_cc = x_cc;
public void setxCC(final String xCC) {
this.xCC = xCC;
}

public String getSubject() {
return Subject;
return subject;
}

public void setSubject(String subject) {
Subject = subject;
public void setSubject(final String subject) {
this.subject = subject;
}

public String getX_Folder() {
return X_Folder;
public String getxFolder() {
return xFolder;
}

public void setX_Folder(String x_Folder) {
X_Folder = x_Folder;
public void setxFolder(final String xFolder) {
this.xFolder = xFolder;
}

public String getContent_Transfer_Encoding() {
return Content_Transfer_Encoding;
public String getContentTransferEncoding() {
return contentTransferEncoding;
}

public void setContent_Transfer_Encoding(String content_Transfer_Encoding) {
Content_Transfer_Encoding = content_Transfer_Encoding;
public void setContentTransferEncoding(final String contentTransferEncoding) {
this.contentTransferEncoding = contentTransferEncoding;
}

public String getX_bcc() {
return X_bcc;
public String getxBcc() {
return xBcc;
}

public void setX_bcc(String x_bcc) {
X_bcc = x_bcc;
public void setxBcc(final String xBcc) {
this.xBcc = xBcc;
}

public String getTo() {
return To;
return to;
}

public void setTo(String to) {
To = to;
public void setTo(final String to) {
this.to = to;
}

public String getX_Origin() {
return X_Origin;
public String getxOrigin() {
return xOrigin;
}

public void setX_Origin(String x_Origin) {
X_Origin = x_Origin;
public void setxOrigin(final String xOrigin) {
this.xOrigin = xOrigin;
}

public String getX_FileName() {
return X_FileName;
public String getxFilename() {
return xFilename;
}

public void setX_FileName(String x_FileName) {
X_FileName = x_FileName;
public void setxFilename(final String xFilename) {
this.xFilename = xFilename;
}

public String getX_From() {
return X_From;
public String getxFrom() {
return xFrom;
}

public void setX_From(String x_From) {
X_From = x_From;
public void setxFrom(final String xFrom) {
this.xFrom = xFrom;
}

public String getDate() {
return Date;
return date;
}

public void setDate(String date) {
Date = date;
public void setDate(final String date) {
this.date = date;
}

public String getX_To() {
return X_To;
public String getxTo() {
return xTo;
}

public void setX_To(String x_To) {
X_To = x_To;
public void setxTo(final String xTo) {
this.xTo = xTo;
}

public String getMessage_ID() {
return Message_ID;
public String getMessageID() {
return messageID;
}

public void setMessage_ID(String message_ID) {
Message_ID = message_ID;
public void setMessageID(final String messageID) {
this.messageID = messageID;
}

public String getContent_Type() {
return Content_Type;
public String getContentType() {
return contentType;
}

public void setContent_Type(String content_Type) {
Content_Type = content_Type;
public void setContentType(final String contentType) {
this.contentType = contentType;
}

public String getMime_Version() {
return Mime_Version;
public String getMimeVersion() {
return mimeVersion;
}

public void setMime_Version(String mime_Version) {
Mime_Version = mime_Version;
public void setMimeVersion(final String mimeVersion) {
this.mimeVersion = mimeVersion;
}
}
}

0 comments on commit 53467ad

Please sign in to comment.