Skip to content

Commit 89c4611

Browse files
committed
Merge branch 'master' into SPARK-7511-pyspark-ml-seed-param-should-be-random-by-default-or-42-is-quite-funny-but-not-very-random
2 parents 31cd96f + 2f22424 commit 89c4611

File tree

131 files changed

+4246
-2271
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+4246
-2271
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ The following components are provided under a BSD-style license. See project lin
861861

862862
(BSD 3 Clause) core (com.github.fommil.netlib:core:1.1.2 - https://github.com/fommil/netlib-java/core)
863863
(BSD 3 Clause) JPMML-Model (org.jpmml:pmml-model:1.1.15 - https://github.com/jpmml/jpmml-model)
864-
(BSD 3-clause style license) jblas (org.jblas:jblas:1.2.3 - http://jblas.org/)
864+
(BSD 3-clause style license) jblas (org.jblas:jblas:1.2.4 - http://jblas.org/)
865865
(BSD License) AntLR Parser Generator (antlr:antlr:2.7.7 - http://www.antlr.org/)
866866
(BSD License) Javolution (javolution:javolution:5.5.1 - http://javolution.org)
867867
(BSD licence) ANTLR ST4 4.0.4 (org.antlr:ST4:4.0.4 - http://www.stringtemplate.org)

R/pkg/NAMESPACE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,33 +59,56 @@ exportMethods("arrange",
5959
exportClasses("Column")
6060

6161
exportMethods("abs",
62+
"acos",
6263
"alias",
6364
"approxCountDistinct",
6465
"asc",
66+
"asin",
67+
"atan",
68+
"atan2",
6569
"avg",
6670
"cast",
71+
"cbrt",
72+
"ceiling",
6773
"contains",
74+
"cos",
75+
"cosh",
6876
"countDistinct",
6977
"desc",
7078
"endsWith",
79+
"exp",
80+
"expm1",
81+
"floor",
7182
"getField",
7283
"getItem",
84+
"hypot",
7385
"isNotNull",
7486
"isNull",
7587
"last",
7688
"like",
89+
"log",
90+
"log10",
91+
"log1p",
7792
"lower",
7893
"max",
7994
"mean",
8095
"min",
8196
"n",
8297
"n_distinct",
98+
"rint",
8399
"rlike",
100+
"sign",
101+
"sin",
102+
"sinh",
84103
"sqrt",
85104
"startsWith",
86105
"substr",
87106
"sum",
88107
"sumDistinct",
108+
"tan",
109+
"tanh",
110+
"toDegrees",
111+
"toRadians",
89112
"upper")
90113

91114
exportClasses("GroupedData")

R/pkg/R/column.R

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,17 @@ operators <- list(
5555
"+" = "plus", "-" = "minus", "*" = "multiply", "/" = "divide", "%%" = "mod",
5656
"==" = "equalTo", ">" = "gt", "<" = "lt", "!=" = "notEqual", "<=" = "leq", ">=" = "geq",
5757
# we can not override `&&` and `||`, so use `&` and `|` instead
58-
"&" = "and", "|" = "or" #, "!" = "unary_$bang"
58+
"&" = "and", "|" = "or", #, "!" = "unary_$bang"
59+
"^" = "pow"
5960
)
6061
column_functions1 <- c("asc", "desc", "isNull", "isNotNull")
6162
column_functions2 <- c("like", "rlike", "startsWith", "endsWith", "getField", "getItem", "contains")
6263
functions <- c("min", "max", "sum", "avg", "mean", "count", "abs", "sqrt",
63-
"first", "last", "lower", "upper", "sumDistinct")
64+
"first", "last", "lower", "upper", "sumDistinct",
65+
"acos", "asin", "atan", "cbrt", "ceiling", "cos", "cosh", "exp",
66+
"expm1", "floor", "log", "log10", "log1p", "rint", "sign",
67+
"sin", "sinh", "tan", "tanh", "toDegrees", "toRadians")
68+
binary_mathfunctions<- c("atan2", "hypot")
6469

6570
createOperator <- function(op) {
6671
setMethod(op,
@@ -76,7 +81,11 @@ createOperator <- function(op) {
7681
if (class(e2) == "Column") {
7782
e2 <- e2@jc
7883
}
79-
callJMethod(e1@jc, operators[[op]], e2)
84+
if (op == "^") {
85+
jc <- callJStatic("org.apache.spark.sql.functions", operators[[op]], e1@jc, e2)
86+
} else {
87+
callJMethod(e1@jc, operators[[op]], e2)
88+
}
8089
}
8190
column(jc)
8291
})
@@ -106,11 +115,29 @@ createStaticFunction <- function(name) {
106115
setMethod(name,
107116
signature(x = "Column"),
108117
function(x) {
118+
if (name == "ceiling") {
119+
name <- "ceil"
120+
}
121+
if (name == "sign") {
122+
name <- "signum"
123+
}
109124
jc <- callJStatic("org.apache.spark.sql.functions", name, x@jc)
110125
column(jc)
111126
})
112127
}
113128

129+
createBinaryMathfunctions <- function(name) {
130+
setMethod(name,
131+
signature(y = "Column"),
132+
function(y, x) {
133+
if (class(x) == "Column") {
134+
x <- x@jc
135+
}
136+
jc <- callJStatic("org.apache.spark.sql.functions", name, y@jc, x)
137+
column(jc)
138+
})
139+
}
140+
114141
createMethods <- function() {
115142
for (op in names(operators)) {
116143
createOperator(op)
@@ -124,6 +151,9 @@ createMethods <- function() {
124151
for (x in functions) {
125152
createStaticFunction(x)
126153
}
154+
for (name in binary_mathfunctions) {
155+
createBinaryMathfunctions(name)
156+
}
127157
}
128158

129159
createMethods()

R/pkg/R/generics.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,10 @@ setGeneric("avg", function(x, ...) { standardGeneric("avg") })
552552
#' @export
553553
setGeneric("cast", function(x, dataType) { standardGeneric("cast") })
554554

555+
#' @rdname column
556+
#' @export
557+
setGeneric("cbrt", function(x) { standardGeneric("cbrt") })
558+
555559
#' @rdname column
556560
#' @export
557561
setGeneric("contains", function(x, ...) { standardGeneric("contains") })
@@ -575,6 +579,10 @@ setGeneric("getField", function(x, ...) { standardGeneric("getField") })
575579
#' @export
576580
setGeneric("getItem", function(x, ...) { standardGeneric("getItem") })
577581

582+
#' @rdname column
583+
#' @export
584+
setGeneric("hypot", function(y, x) { standardGeneric("hypot") })
585+
578586
#' @rdname column
579587
#' @export
580588
setGeneric("isNull", function(x) { standardGeneric("isNull") })
@@ -603,6 +611,10 @@ setGeneric("n", function(x) { standardGeneric("n") })
603611
#' @export
604612
setGeneric("n_distinct", function(x, ...) { standardGeneric("n_distinct") })
605613

614+
#' @rdname column
615+
#' @export
616+
setGeneric("rint", function(x, ...) { standardGeneric("rint") })
617+
606618
#' @rdname column
607619
#' @export
608620
setGeneric("rlike", function(x, ...) { standardGeneric("rlike") })
@@ -615,6 +627,14 @@ setGeneric("startsWith", function(x, ...) { standardGeneric("startsWith") })
615627
#' @export
616628
setGeneric("sumDistinct", function(x) { standardGeneric("sumDistinct") })
617629

630+
#' @rdname column
631+
#' @export
632+
setGeneric("toDegrees", function(x) { standardGeneric("toDegrees") })
633+
634+
#' @rdname column
635+
#' @export
636+
setGeneric("toRadians", function(x) { standardGeneric("toRadians") })
637+
618638
#' @rdname column
619639
#' @export
620640
setGeneric("upper", function(x) { standardGeneric("upper") })

R/pkg/inst/tests/test_sparkSQL.R

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ test_that("column operators", {
530530
c2 <- (- c + 1 - 2) * 3 / 4.0
531531
c3 <- (c + c2 - c2) * c2 %% c2
532532
c4 <- (c > c2) & (c2 <= c3) | (c == c2) & (c2 != c3)
533+
c5 <- c2 ^ c3 ^ c4
533534
})
534535

535536
test_that("column functions", {
@@ -538,6 +539,29 @@ test_that("column functions", {
538539
c3 <- lower(c) + upper(c) + first(c) + last(c)
539540
c4 <- approxCountDistinct(c) + countDistinct(c) + cast(c, "string")
540541
c5 <- n(c) + n_distinct(c)
542+
c5 <- acos(c) + asin(c) + atan(c) + cbrt(c)
543+
c6 <- ceiling(c) + cos(c) + cosh(c) + exp(c) + expm1(c)
544+
c7 <- floor(c) + log(c) + log10(c) + log1p(c) + rint(c)
545+
c8 <- sign(c) + sin(c) + sinh(c) + tan(c) + tanh(c)
546+
c9 <- toDegrees(c) + toRadians(c)
547+
})
548+
549+
test_that("column binary mathfunctions", {
550+
lines <- c("{\"a\":1, \"b\":5}",
551+
"{\"a\":2, \"b\":6}",
552+
"{\"a\":3, \"b\":7}",
553+
"{\"a\":4, \"b\":8}")
554+
jsonPathWithDup <- tempfile(pattern="sparkr-test", fileext=".tmp")
555+
writeLines(lines, jsonPathWithDup)
556+
df <- jsonFile(sqlCtx, jsonPathWithDup)
557+
expect_equal(collect(select(df, atan2(df$a, df$b)))[1, "ATAN2(a, b)"], atan2(1, 5))
558+
expect_equal(collect(select(df, atan2(df$a, df$b)))[2, "ATAN2(a, b)"], atan2(2, 6))
559+
expect_equal(collect(select(df, atan2(df$a, df$b)))[3, "ATAN2(a, b)"], atan2(3, 7))
560+
expect_equal(collect(select(df, atan2(df$a, df$b)))[4, "ATAN2(a, b)"], atan2(4, 8))
561+
expect_equal(collect(select(df, hypot(df$a, df$b)))[1, "HYPOT(a, b)"], sqrt(1^2 + 5^2))
562+
expect_equal(collect(select(df, hypot(df$a, df$b)))[2, "HYPOT(a, b)"], sqrt(2^2 + 6^2))
563+
expect_equal(collect(select(df, hypot(df$a, df$b)))[3, "HYPOT(a, b)"], sqrt(3^2 + 7^2))
564+
expect_equal(collect(select(df, hypot(df$a, df$b)))[4, "HYPOT(a, b)"], sqrt(4^2 + 8^2))
541565
})
542566

543567
test_that("string operators", {

core/src/main/resources/org/apache/spark/ui/static/spark-dag-viz.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@ function renderDagVizForJob(svgContainer) {
186186
var stageId = metadata.attr("stage-id");
187187
var containerId = VizConstants.graphPrefix + stageId;
188188
// Link each graph to the corresponding stage page (TODO: handle stage attempts)
189-
var stageLink = "/stages/stage/?id=" +
190-
stageId.replace(VizConstants.stagePrefix, "") + "&attempt=0&expandDagViz=true";
189+
var stageLink = $("#stage-" + stageId.replace(VizConstants.stagePrefix, "") + "-0")
190+
.find("a")
191+
.attr("href") + "&expandDagViz=true";
191192
var container = svgContainer
192193
.append("a")
193194
.attr("xlink:href", stageLink)

core/src/main/resources/org/apache/spark/ui/static/timeline-view.css

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,65 @@ div#application-timeline, div#job-timeline {
2424
margin-top: 5px;
2525
}
2626

27+
#task-assignment-timeline div.legend-area {
28+
width: 574px;
29+
}
30+
31+
#task-assignment-timeline .legend-area > svg {
32+
width: 100%;
33+
height: 55px;
34+
}
35+
36+
#task-assignment-timeline div.item.range {
37+
padding: 0px;
38+
height: 26px;
39+
border-width: 0;
40+
}
41+
42+
.task-assignment-timeline-content {
43+
width: 100%;
44+
}
45+
46+
.task-assignment-timeline-duration-bar {
47+
width: 100%;
48+
height: 26px;
49+
}
50+
51+
rect.scheduler-delay-proportion {
52+
fill: #80B1D3;
53+
stroke: #6B94B0;
54+
}
55+
56+
rect.deserialization-time-proportion {
57+
fill: #FB8072;
58+
stroke: #D26B5F;
59+
}
60+
61+
rect.shuffle-read-time-proportion {
62+
fill: #FDB462;
63+
stroke: #D39651;
64+
}
65+
66+
rect.executor-runtime-proportion {
67+
fill: #B3DE69;
68+
stroke: #95B957;
69+
}
70+
71+
rect.shuffle-write-time-proportion {
72+
fill: #FFED6F;
73+
stroke: #D5C65C;
74+
}
75+
76+
rect.serialization-time-proportion {
77+
fill: #BC80BD;
78+
stroke: #9D6B9E;
79+
}
80+
81+
rect.getting-result-time-proportion {
82+
fill: #8DD3C7;
83+
stroke: #75B0A6;
84+
}
85+
2786
.vis.timeline {
2887
line-height: 14px;
2988
}
@@ -178,6 +237,10 @@ tr.corresponding-item-hover > td, tr.corresponding-item-hover > th {
178237
display: none;
179238
}
180239

240+
#task-assignment-timeline.collapsed {
241+
display: none;
242+
}
243+
181244
.control-panel {
182245
margin-bottom: 5px;
183246
}
@@ -186,7 +249,8 @@ tr.corresponding-item-hover > td, tr.corresponding-item-hover > th {
186249
margin: 0;
187250
}
188251

189-
span.expand-application-timeline, span.expand-job-timeline {
252+
span.expand-application-timeline, span.expand-job-timeline,
253+
span.expand-task-assignment-timeline {
190254
cursor: pointer;
191255
}
192256

core/src/main/resources/org/apache/spark/ui/static/timeline-view.js

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,57 @@ function drawJobTimeline(groupArray, eventObjArray, startTime) {
133133
});
134134
}
135135

136+
function drawTaskAssignmentTimeline(groupArray, eventObjArray, minLaunchTime, maxFinishTime) {
137+
var groups = new vis.DataSet(groupArray);
138+
var items = new vis.DataSet(eventObjArray);
139+
var container = $("#task-assignment-timeline")[0]
140+
var options = {
141+
groupOrder: function(a, b) {
142+
return a.value - b.value
143+
},
144+
editable: false,
145+
align: 'left',
146+
selectable: false,
147+
showCurrentTime: false,
148+
min: minLaunchTime,
149+
max: maxFinishTime,
150+
zoomable: false
151+
};
152+
153+
var taskTimeline = new vis.Timeline(container)
154+
taskTimeline.setOptions(options);
155+
taskTimeline.setGroups(groups);
156+
taskTimeline.setItems(items);
157+
158+
// If a user zooms while a tooltip is displayed, the user may zoom such that the cursor is no
159+
// longer over the task that the tooltip corresponds to. So, when a user zooms, we should hide
160+
// any currently displayed tooltips.
161+
var currentDisplayedTooltip = null;
162+
$("#task-assignment-timeline").on({
163+
"mouseenter": function() {
164+
currentDisplayedTooltip = this;
165+
},
166+
"mouseleave": function() {
167+
currentDisplayedTooltip = null;
168+
}
169+
}, ".task-assignment-timeline-content");
170+
taskTimeline.on("rangechange", function(prop) {
171+
if (currentDisplayedTooltip !== null) {
172+
$(currentDisplayedTooltip).tooltip("hide");
173+
}
174+
});
175+
176+
setupZoomable("#task-assignment-timeline-zoom-lock", taskTimeline);
177+
178+
$("span.expand-task-assignment-timeline").click(function() {
179+
$("#task-assignment-timeline").toggleClass("collapsed");
180+
181+
// Switch the class of the arrow from open to closed.
182+
$(this).find(".expand-task-assignment-timeline-arrow").toggleClass("arrow-open");
183+
$(this).find(".expand-task-assignment-timeline-arrow").toggleClass("arrow-closed");
184+
});
185+
}
186+
136187
function setupExecutorEventAction() {
137188
$(".item.box.executor").each(function () {
138189
$(this).hover(
@@ -147,15 +198,15 @@ function setupExecutorEventAction() {
147198
}
148199

149200
function setupZoomable(id, timeline) {
150-
$(id + '>input[type="checkbox"]').click(function() {
201+
$(id + ' > input[type="checkbox"]').click(function() {
151202
if (this.checked) {
152203
timeline.setOptions({zoomable: true});
153204
} else {
154205
timeline.setOptions({zoomable: false});
155206
}
156207
});
157208

158-
$(id + ">span").click(function() {
209+
$(id + " > span").click(function() {
159210
$(this).parent().find('input:checkbox').trigger('click');
160211
});
161212
}

0 commit comments

Comments
 (0)