[SPARK-707] Adding Java versions of Pi, LogQuery and K-Means examples #528

Merged
merged 7 commits into from Mar 20, 2013

Projects

None yet

2 participants

@MLnick
Contributor
MLnick commented Mar 15, 2013

No description provided.

@mateiz mateiz commented on an outdated diff Mar 15, 2013
examples/src/main/java/spark/examples/JavaLogQuery.java
+
+ public static List<String> exampleApacheLogs = Lists.newArrayList(
+ "10.10.10.10 - \"FRED\" [18/Jan/2013:17:56:07 +1100] \"GET http://images.com/2013/Generic.jpg " +
+ "HTTP/1.1\" 304 315 \"http://referall.com/\" \"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB7.4; .NET CLR 2.0.50727; " +
+ ".NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR " +
+ "3.5.30729; Release=ARP)\" \"UD-1\" - \"image/jpeg\" \"whatever\" 0.350 \"-\" - \"\" 265 923 934 \"\" " +
+ "62.24.11.25 images.com 1358492167 - Whatup",
+ "10.10.10.10 - \"FRED\" [18/Jan/2013:18:02:37 +1100] \"GET http://images.com/2013/Generic.jpg " +
+ "HTTP/1.1\" 304 306 \"http:/referall.com\" \"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; " +
+ "GTB7.4; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR " +
+ "3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR " +
+ "3.5.30729; Release=ARP)\" \"UD-1\" - \"image/jpeg\" \"whatever\" 0.352 \"-\" - \"\" 256 977 988 \"\" " +
+ "0 73.23.2.15 images.com 1358492557 - Whatup");
+
+
+ public static Pattern apacheLogRegex = Pattern.compile("^([\\d.]+) (\\S+) (\\S+) \\[([\\w\\d:/]+\\s[+\\-]\\d{4})\\] \"(.+?)\" (\\d{3}) ([\\d\\-]+) \"([^\"]+)\" \"([^\"]+)\".*");
@mateiz
mateiz Mar 15, 2013 Member

Minor thing, break the line after compile( to make this more closely fit 100-character line lengths

@mateiz
Member
mateiz commented Mar 15, 2013

This is great, thanks! Just made a small formatting comment.

@MLnick
Contributor
MLnick commented Mar 18, 2013

@mateiz made the formatting change, but I'd prefer to first add the K-Means example (utilizing the code from http://ampcamp.berkeley.edu/big-data-mini-course/machine-learning-with-spark.html) before merging. Give me a few days to find a moment to do that.

@mateiz
Member
mateiz commented Mar 18, 2013

Alright, NP.

@mateiz
Member
mateiz commented Mar 20, 2013

Hey, looks great, but I just noticed one small thing: do you mind changing the indentation of the Java code from four spaces to two? That seems to be the style we had in our other Java code.

@mateiz mateiz merged commit ca4d083 into mesos:master Mar 20, 2013
@mateiz
Member
mateiz commented Mar 20, 2013

Great, thanks a lot!

@MLnick MLnick deleted the unknown repository branch Mar 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment