This gist consists of Spark presentation examples.
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
https://confluence.atlassian.com/display/JIRA/Logging+Work+on+an+Issue#LoggingWorkonanIssue-Loggingworkwhileresolvingorclosinganissue | |
https://confluence.atlassian.com/display/JIRAKB/Set+Remaining+Estimate+to+0+on+post+function |
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
List of currenies is generated using python. | |
Dependencies | |
============ | |
pip install pycountry pytz requests |
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
The /user/ directory is owned by "hdfs" with 755 permissions. As a result only hdfs can write to that directory. Unlike unix/linux, hdfs is the superuser and not root. So you would need to do this: | |
sudo -u hdfs hadoop fs -mkdir /user/,,myfile,, | |
sudo -u hdfs hadoop fs -put myfile.txt /user/,,/,, | |
If you want to create a home directory for root so you can store files in his directory, do: | |
sudo -u hdfs hadoop fs -mkdir /user/root | |
sudo -u hdfs hadoop fs -chown root /user/root |
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
class Graph[T] { | |
type Vertex = T | |
type GraphMap = Map[Vertex,List[Vertex]] | |
var g:GraphMap = Map() | |
def BFS(start: Vertex): List[List[Vertex]] = { | |
def BFS0(elems: List[Vertex],visited: List[List[Vertex]]): List[List[Vertex]] = { | |
val newNeighbors = elems.flatMap(g(_)).filterNot(visited.flatten.contains).distinct | |
if (newNeighbors.isEmpty) |
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
df1.unionAll(df2.select(fd1.columns.map(df1(_)): _*)) |
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
def combine[T](s: Seq[T]): Seq[Seq[T]] = | |
for { | |
len <- 1 to s.length | |
combinations <- s combinations len | |
} yield combinations | |
println(combine(List('a', 'b', 'c'))) |
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
val schedule = sqlContext.read | |
.format("com.databricks.spark.csv") | |
.option("header", "true") | |
.option("inferSchema", "true") | |
.load("lookup-example/san-jose-schedule-2016-2017.csv") | |
.select( | |
to_date( | |
unix_timestamp($"START_DATE", "MM/dd/yyyy").cast("timestamp") | |
) as "date", | |
when( |
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
val schedule = sqlContext.read | |
.format("com.databricks.spark.csv") | |
.option("header", "true") | |
.option("inferSchema", "true") | |
.load("lookup-example/san-jose-schedule-2016-2017.csv") | |
.select( | |
to_date( | |
unix_timestamp($"START_DATE", "MM/dd/yyyy").cast("timestamp") | |
) as "date", | |
when( |
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
CREATE EXTERNAL TABLE IF NOT EXISTS lookup_example_nhl_ext( | |
team String, | |
division String, | |
conference String) | |
COMMENT 'NHL teams' | |
ROW FORMAT DELIMITED | |
FIELDS TERMINATED BY ',' | |
LINES TERMINATED BY '\n' | |
STORED AS TEXTFILE | |
LOCATION 'hdfs:///user/<user>/lookup-example/nhl-lookup' |
OlderNewer