This file contains hidden or 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
| use strict; | |
| use warnings; | |
| my $spawn_processes = 5; | |
| my $forked = 0; | |
| my $err = 0; | |
| print "($$) parent has started\n"; | |
| foreach(1..$spawn_processes) { | |
| my $child_pid = fork(); |
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| my $child_pid = fork(); | |
| if(defined $child_pid && $child_pid > 0) { | |
| ## Parent | |
| wait(); | |
| print "p($$) c($child_pid) child finished, exiting\n"; | |
| } else { | |
| ## Child |
This file contains hidden or 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
| #reading data from a file | |
| logData = sc.textFile(logFile) | |
| X = 10 | |
| #for each key finding entries that occur more than X times | |
| outliers = logData.map(lambda (k, v): (k, 1)).reduceByKey(lambda a, b: a + b).filter(lambda (k, v): v > X).cache() | |
| #filtering these entries out |
This file contains hidden or 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
| # getting an objectId object from a string | |
| getObjectID = function(str) { | |
| return(mongo.oid.from.string(str)) | |
| } | |
| database = "" | |
| mongo = NULL | |
| namespace = "" | |
| connectToMongoDB = function(host, db, collection) { |
NewerOlder