Created
August 29, 2015 16:49
-
-
Save khan5v/1cd4aac392779f86d23f to your computer and use it in GitHub Desktop.
Shows how to filter entries out based on some logic in Spark
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
#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 | |
reducedLogData = logData.subtractByKey(outliers).cache() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment