View proba_simulation_dice_forge.py
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
import random | |
p = 1/6 | |
nb_roll = 4 | |
nb_simulation = 10_000 | |
nb_sucess = 0 | |
for _ in range(nb_simulation): | |
if any(random.random() < p for _ in range(nb_roll)): |
View change_spark_version.py
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
""" | |
Small script to change Apache Spark version in all the modules. | |
It has been tested against Spark 3.0.1 | |
We used it to rebuild Spark against different versions of the dependencies | |
""" | |
import os | |
def main(): | |
old_version = "3.0.1" |
View MeanAggregatorUdaf.scala
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
import org.apache.spark.sql.Encoder | |
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder | |
import org.apache.spark.sql.expressions.{Aggregator, UserDefinedFunction} | |
import org.apache.spark.sql.functions._ | |
case class AggregatorState(sum: Long, count: Long) | |
// Aggregator[IN, BUF, OUT] | |
val meanAggregator = new Aggregator[Long, AggregatorState, Double]() { | |
// Initialize your buffer |