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
use std::fmt; | |
#[derive(Clone, Debug)] | |
pub struct DateTime { | |
/// Seconds after the minute - [0, 59] | |
pub sec: i32, | |
/// Minutes after the hour - [0, 59] | |
pub min: i32, | |
/// Hours after midnight - [0, 23] | |
pub hour: i32, |
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.rdd.batch.implicits._ | |
val rdd = sc.parallelize(0 until 1000, 100) | |
val res = rdd.batch(numPartitionsPerBatch = 20) | |
res.collect | |
val rdd = sc.parallelize(Seq("a", "b", "c", "d", "e", "f", "g", "h"), 10) | |
val res = rdd.batch(numPartitionsPerBatch = 4) | |
res.collect |
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
package mobilepackage | |
import io.gatling.core.Predef._ | |
import io.gatling.core.session._ | |
import io.gatling.http.Predef._ | |
import scala.concurrent.duration._ | |
import scala.util.parsing.json._ | |
import general._ | |
class LoginSimulation extends Simulation { |
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
sc.hadoopConfiguration.set("parquet.writer.version", "v1") // either "v1" or "v2" | |
// disable vectorized reading, does not support delta encoding | |
spark.conf.set("spark.sql.parquet.enableVectorizedReader", "false") |
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._ | |
import org.apache.spark.sql.types._ | |
import org.apache.spark.sql.expressions._ | |
val df = Seq( | |
("str", 1, 0.2) | |
).toDF("a", "b", "c"). | |
withColumn("struct", struct($"a", $"b", $"c")) | |
// UDF for struct |
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
object DB { | |
import org.apache.spark.sql._ | |
import org.apache.spark.sql.types._ | |
var url = "jdbc:sqlserver://..." | |
var props = new java.util.Properties() | |
var autoCommit = true | |
var spark = SparkSession.getActiveSession.get | |
def execute(conn: java.sql.Connection, query: String): DataFrame = { |
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 df = Seq( | |
(System.currentTimeMillis, "user1", 0.3, Seq(0.1, 0.2)), | |
(System.currentTimeMillis + 1000000L, "user1", 0.5, Seq(0.1, 0.2)), | |
(System.currentTimeMillis + 2000000L, "user1", 0.2, Seq(0.1, 0.2)), | |
(System.currentTimeMillis + 3000000L, "user1", 0.1, Seq(0.1, 0.2)), | |
(System.currentTimeMillis + 4000000L, "user1", 1.3, Seq(0.1, 0.2)), | |
(System.currentTimeMillis + 5000000L, "user1", 2.3, Seq(0.1, 0.2)), | |
(System.currentTimeMillis + 6000000L, "user2", 2.3, Seq(0.1, 0.2)) | |
).toDF("t", "u", "s", "l") |
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 java.util.Random; | |
import java.util.concurrent.ConcurrentHashMap; | |
import javafx.animation.AnimationTimer; | |
import javafx.application.Application; | |
import javafx.scene.Scene; | |
import javafx.scene.Group; | |
import javafx.scene.canvas.Canvas; | |
import javafx.scene.canvas.GraphicsContext; | |
import javafx.scene.paint.Color; |
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
open -a "Google Chrome" --args --proxy-server=http://localhost:8080 --ignore-certificate-errors |
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.Row | |
import org.apache.spark.sql.expressions.{MutableAggregationBuffer, UserDefinedAggregateFunction} | |
import org.apache.spark.sql.types.{ArrayType, LongType, DataType, StructType, StructField} | |
class CollectionFunction(private val limit: Int) extends UserDefinedAggregateFunction { | |
def inputSchema: StructType = | |
StructType(StructField("value", LongType, false) :: Nil) | |
def bufferSchema: StructType = | |
StructType(StructField("list", ArrayType(LongType, true), true) :: Nil) |
NewerOlder