Last active
May 14, 2020 13:12
-
-
Save ceteri/8ae5b9509a08c08a1132 to your computer and use it in GitHub Desktop.
Intro to Apache Spark: code example for RDD animation
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
// load error messages from a log into memory | |
// then interactively search for various patterns | |
// base RDD | |
lines = spark.textFile("hdfs://…") | |
// transformed RDDs | |
errors = lines.filter(lambda s: s.startswith("ERROR")) | |
messages = errors.map(lambda s: s.split("\t")[2]) | |
messages.cache() | |
// actions | |
messages.filter(lambda s: "mysql" in s).count() | |
messages.filter(lambda s: "php" in s).count() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment