Skip to content

Commit

Permalink
Merge branch 'master' of github.com:apache/spark into dag-viz-streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Or committed May 16, 2015
2 parents fd07d22 + 1b4e710 commit af4ba8d
Show file tree
Hide file tree
Showing 57 changed files with 2,383 additions and 1,059 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ The following components are provided under a BSD-style license. See project lin

(BSD 3 Clause) core (com.github.fommil.netlib:core:1.1.2 - https://github.com/fommil/netlib-java/core)
(BSD 3 Clause) JPMML-Model (org.jpmml:pmml-model:1.1.15 - https://github.com/jpmml/jpmml-model)
(BSD 3-clause style license) jblas (org.jblas:jblas:1.2.3 - http://jblas.org/)
(BSD 3-clause style license) jblas (org.jblas:jblas:1.2.4 - http://jblas.org/)
(BSD License) AntLR Parser Generator (antlr:antlr:2.7.7 - http://www.antlr.org/)
(BSD License) Javolution (javolution:javolution:5.5.1 - http://javolution.org)
(BSD licence) ANTLR ST4 4.0.4 (org.antlr:ST4:4.0.4 - http://www.stringtemplate.org)
Expand Down
23 changes: 23 additions & 0 deletions R/pkg/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,56 @@ exportMethods("arrange",
exportClasses("Column")

exportMethods("abs",
"acos",
"alias",
"approxCountDistinct",
"asc",
"asin",
"atan",
"atan2",
"avg",
"cast",
"cbrt",
"ceiling",
"contains",
"cos",
"cosh",
"countDistinct",
"desc",
"endsWith",
"exp",
"expm1",
"floor",
"getField",
"getItem",
"hypot",
"isNotNull",
"isNull",
"last",
"like",
"log",
"log10",
"log1p",
"lower",
"max",
"mean",
"min",
"n",
"n_distinct",
"rint",
"rlike",
"sign",
"sin",
"sinh",
"sqrt",
"startsWith",
"substr",
"sum",
"sumDistinct",
"tan",
"tanh",
"toDegrees",
"toRadians",
"upper")

exportClasses("GroupedData")
Expand Down
36 changes: 33 additions & 3 deletions R/pkg/R/column.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,17 @@ operators <- list(
"+" = "plus", "-" = "minus", "*" = "multiply", "/" = "divide", "%%" = "mod",
"==" = "equalTo", ">" = "gt", "<" = "lt", "!=" = "notEqual", "<=" = "leq", ">=" = "geq",
# we can not override `&&` and `||`, so use `&` and `|` instead
"&" = "and", "|" = "or" #, "!" = "unary_$bang"
"&" = "and", "|" = "or", #, "!" = "unary_$bang"
"^" = "pow"
)
column_functions1 <- c("asc", "desc", "isNull", "isNotNull")
column_functions2 <- c("like", "rlike", "startsWith", "endsWith", "getField", "getItem", "contains")
functions <- c("min", "max", "sum", "avg", "mean", "count", "abs", "sqrt",
"first", "last", "lower", "upper", "sumDistinct")
"first", "last", "lower", "upper", "sumDistinct",
"acos", "asin", "atan", "cbrt", "ceiling", "cos", "cosh", "exp",
"expm1", "floor", "log", "log10", "log1p", "rint", "sign",
"sin", "sinh", "tan", "tanh", "toDegrees", "toRadians")
binary_mathfunctions<- c("atan2", "hypot")

createOperator <- function(op) {
setMethod(op,
Expand All @@ -76,7 +81,11 @@ createOperator <- function(op) {
if (class(e2) == "Column") {
e2 <- e2@jc
}
callJMethod(e1@jc, operators[[op]], e2)
if (op == "^") {
jc <- callJStatic("org.apache.spark.sql.functions", operators[[op]], e1@jc, e2)
} else {
callJMethod(e1@jc, operators[[op]], e2)
}
}
column(jc)
})
Expand Down Expand Up @@ -106,11 +115,29 @@ createStaticFunction <- function(name) {
setMethod(name,
signature(x = "Column"),
function(x) {
if (name == "ceiling") {
name <- "ceil"
}
if (name == "sign") {
name <- "signum"
}
jc <- callJStatic("org.apache.spark.sql.functions", name, x@jc)
column(jc)
})
}

createBinaryMathfunctions <- function(name) {
setMethod(name,
signature(y = "Column"),
function(y, x) {
if (class(x) == "Column") {
x <- x@jc
}
jc <- callJStatic("org.apache.spark.sql.functions", name, y@jc, x)
column(jc)
})
}

createMethods <- function() {
for (op in names(operators)) {
createOperator(op)
Expand All @@ -124,6 +151,9 @@ createMethods <- function() {
for (x in functions) {
createStaticFunction(x)
}
for (name in binary_mathfunctions) {
createBinaryMathfunctions(name)
}
}

createMethods()
Expand Down
20 changes: 20 additions & 0 deletions R/pkg/R/generics.R
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,10 @@ setGeneric("avg", function(x, ...) { standardGeneric("avg") })
#' @export
setGeneric("cast", function(x, dataType) { standardGeneric("cast") })

#' @rdname column
#' @export
setGeneric("cbrt", function(x) { standardGeneric("cbrt") })

#' @rdname column
#' @export
setGeneric("contains", function(x, ...) { standardGeneric("contains") })
Expand All @@ -575,6 +579,10 @@ setGeneric("getField", function(x, ...) { standardGeneric("getField") })
#' @export
setGeneric("getItem", function(x, ...) { standardGeneric("getItem") })

#' @rdname column
#' @export
setGeneric("hypot", function(y, x) { standardGeneric("hypot") })

#' @rdname column
#' @export
setGeneric("isNull", function(x) { standardGeneric("isNull") })
Expand Down Expand Up @@ -603,6 +611,10 @@ setGeneric("n", function(x) { standardGeneric("n") })
#' @export
setGeneric("n_distinct", function(x, ...) { standardGeneric("n_distinct") })

#' @rdname column
#' @export
setGeneric("rint", function(x, ...) { standardGeneric("rint") })

#' @rdname column
#' @export
setGeneric("rlike", function(x, ...) { standardGeneric("rlike") })
Expand All @@ -615,6 +627,14 @@ setGeneric("startsWith", function(x, ...) { standardGeneric("startsWith") })
#' @export
setGeneric("sumDistinct", function(x) { standardGeneric("sumDistinct") })

#' @rdname column
#' @export
setGeneric("toDegrees", function(x) { standardGeneric("toDegrees") })

#' @rdname column
#' @export
setGeneric("toRadians", function(x) { standardGeneric("toRadians") })

#' @rdname column
#' @export
setGeneric("upper", function(x) { standardGeneric("upper") })
Expand Down
24 changes: 24 additions & 0 deletions R/pkg/inst/tests/test_sparkSQL.R
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ test_that("column operators", {
c2 <- (- c + 1 - 2) * 3 / 4.0
c3 <- (c + c2 - c2) * c2 %% c2
c4 <- (c > c2) & (c2 <= c3) | (c == c2) & (c2 != c3)
c5 <- c2 ^ c3 ^ c4
})

test_that("column functions", {
Expand All @@ -538,6 +539,29 @@ test_that("column functions", {
c3 <- lower(c) + upper(c) + first(c) + last(c)
c4 <- approxCountDistinct(c) + countDistinct(c) + cast(c, "string")
c5 <- n(c) + n_distinct(c)
c5 <- acos(c) + asin(c) + atan(c) + cbrt(c)
c6 <- ceiling(c) + cos(c) + cosh(c) + exp(c) + expm1(c)
c7 <- floor(c) + log(c) + log10(c) + log1p(c) + rint(c)
c8 <- sign(c) + sin(c) + sinh(c) + tan(c) + tanh(c)
c9 <- toDegrees(c) + toRadians(c)
})

test_that("column binary mathfunctions", {
lines <- c("{\"a\":1, \"b\":5}",
"{\"a\":2, \"b\":6}",
"{\"a\":3, \"b\":7}",
"{\"a\":4, \"b\":8}")
jsonPathWithDup <- tempfile(pattern="sparkr-test", fileext=".tmp")
writeLines(lines, jsonPathWithDup)
df <- jsonFile(sqlCtx, jsonPathWithDup)
expect_equal(collect(select(df, atan2(df$a, df$b)))[1, "ATAN2(a, b)"], atan2(1, 5))
expect_equal(collect(select(df, atan2(df$a, df$b)))[2, "ATAN2(a, b)"], atan2(2, 6))
expect_equal(collect(select(df, atan2(df$a, df$b)))[3, "ATAN2(a, b)"], atan2(3, 7))
expect_equal(collect(select(df, atan2(df$a, df$b)))[4, "ATAN2(a, b)"], atan2(4, 8))
expect_equal(collect(select(df, hypot(df$a, df$b)))[1, "HYPOT(a, b)"], sqrt(1^2 + 5^2))
expect_equal(collect(select(df, hypot(df$a, df$b)))[2, "HYPOT(a, b)"], sqrt(2^2 + 6^2))
expect_equal(collect(select(df, hypot(df$a, df$b)))[3, "HYPOT(a, b)"], sqrt(3^2 + 7^2))
expect_equal(collect(select(df, hypot(df$a, df$b)))[4, "HYPOT(a, b)"], sqrt(4^2 + 8^2))
})

test_that("string operators", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,65 @@ div#application-timeline, div#job-timeline {
margin-top: 5px;
}

#task-assignment-timeline div.legend-area {
width: 574px;
}

#task-assignment-timeline .legend-area > svg {
width: 100%;
height: 55px;
}

#task-assignment-timeline div.item.range {
padding: 0px;
height: 26px;
border-width: 0;
}

.task-assignment-timeline-content {
width: 100%;
}

.task-assignment-timeline-duration-bar {
width: 100%;
height: 26px;
}

rect.scheduler-delay-proportion {
fill: #80B1D3;
stroke: #6B94B0;
}

rect.deserialization-time-proportion {
fill: #FB8072;
stroke: #D26B5F;
}

rect.shuffle-read-time-proportion {
fill: #FDB462;
stroke: #D39651;
}

rect.executor-runtime-proportion {
fill: #B3DE69;
stroke: #95B957;
}

rect.shuffle-write-time-proportion {
fill: #FFED6F;
stroke: #D5C65C;
}

rect.serialization-time-proportion {
fill: #BC80BD;
stroke: #9D6B9E;
}

rect.getting-result-time-proportion {
fill: #8DD3C7;
stroke: #75B0A6;
}

.vis.timeline {
line-height: 14px;
}
Expand Down Expand Up @@ -178,6 +237,10 @@ tr.corresponding-item-hover > td, tr.corresponding-item-hover > th {
display: none;
}

#task-assignment-timeline.collapsed {
display: none;
}

.control-panel {
margin-bottom: 5px;
}
Expand All @@ -186,7 +249,8 @@ tr.corresponding-item-hover > td, tr.corresponding-item-hover > th {
margin: 0;
}

span.expand-application-timeline, span.expand-job-timeline {
span.expand-application-timeline, span.expand-job-timeline,
span.expand-task-assignment-timeline {
cursor: pointer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,57 @@ function drawJobTimeline(groupArray, eventObjArray, startTime) {
});
}

function drawTaskAssignmentTimeline(groupArray, eventObjArray, minLaunchTime, maxFinishTime) {
var groups = new vis.DataSet(groupArray);
var items = new vis.DataSet(eventObjArray);
var container = $("#task-assignment-timeline")[0]
var options = {
groupOrder: function(a, b) {
return a.value - b.value
},
editable: false,
align: 'left',
selectable: false,
showCurrentTime: false,
min: minLaunchTime,
max: maxFinishTime,
zoomable: false
};

var taskTimeline = new vis.Timeline(container)
taskTimeline.setOptions(options);
taskTimeline.setGroups(groups);
taskTimeline.setItems(items);

// If a user zooms while a tooltip is displayed, the user may zoom such that the cursor is no
// longer over the task that the tooltip corresponds to. So, when a user zooms, we should hide
// any currently displayed tooltips.
var currentDisplayedTooltip = null;
$("#task-assignment-timeline").on({
"mouseenter": function() {
currentDisplayedTooltip = this;
},
"mouseleave": function() {
currentDisplayedTooltip = null;
}
}, ".task-assignment-timeline-content");
taskTimeline.on("rangechange", function(prop) {
if (currentDisplayedTooltip !== null) {
$(currentDisplayedTooltip).tooltip("hide");
}
});

setupZoomable("#task-assignment-timeline-zoom-lock", taskTimeline);

$("span.expand-task-assignment-timeline").click(function() {
$("#task-assignment-timeline").toggleClass("collapsed");

// Switch the class of the arrow from open to closed.
$(this).find(".expand-task-assignment-timeline-arrow").toggleClass("arrow-open");
$(this).find(".expand-task-assignment-timeline-arrow").toggleClass("arrow-closed");
});
}

function setupExecutorEventAction() {
$(".item.box.executor").each(function () {
$(this).hover(
Expand All @@ -147,15 +198,15 @@ function setupExecutorEventAction() {
}

function setupZoomable(id, timeline) {
$(id + '>input[type="checkbox"]').click(function() {
$(id + ' > input[type="checkbox"]').click(function() {
if (this.checked) {
timeline.setOptions({zoomable: true});
} else {
timeline.setOptions({zoomable: false});
}
});

$(id + ">span").click(function() {
$(id + " > span").click(function() {
$(this).parent().find('input:checkbox').trigger('click');
});
}
2 changes: 1 addition & 1 deletion core/src/main/scala/org/apache/spark/SparkConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ private[spark] object SparkConf extends Logging {
AlternateConfig("spark.reducer.maxMbInFlight", "1.4")),
"spark.kryoserializer.buffer" ->
Seq(AlternateConfig("spark.kryoserializer.buffer.mb", "1.4",
translation = s => s"${s.toDouble * 1000}k")),
translation = s => s"${(s.toDouble * 1000).toInt}k")),
"spark.kryoserializer.buffer.max" -> Seq(
AlternateConfig("spark.kryoserializer.buffer.max.mb", "1.4")),
"spark.shuffle.file.buffer" -> Seq(
Expand Down
Loading

0 comments on commit af4ba8d

Please sign in to comment.