Uh oh!
There was an error while loading. Please reload this page.
SPARK-1240: handle the case of empty RDD when takeSample - #135
Conversation
AmplabJenkins
commented
Mar 13, 2014
Merged build triggered. |
AmplabJenkins
commented
Mar 13, 2014
Merged build started. |
There was a problem hiding this comment.
Use require. i.e.
require(fraction >Double.MinValue&& fraction <Double.MaxValue, "...")Shouldn't you just check for fraction > 0 but < 1?
There was a problem hiding this comment.
The lower bound should be >= 0.0. Sample with replacement can have a faction greater than 1.0.
There was a problem hiding this comment.
Hi, @rxin , I'm also a bit confused here, I think the name of the argument is a bit confusing
https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/rdd/RDD.scala#L357
The above line contains a multiplier to ensure that the sampling can return enough sample points in most of cases..(I think so), so the fraction value can actually be larger than 1
also, this value actually determines the mean value of Poisson/Bernoulli distribution
https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/rdd/RDD.scala#L314
There was a problem hiding this comment.
require(fraction >= 0.0) should be sufficient here.
AmplabJenkins
commented
Mar 13, 2014
Merged build finished. |
AmplabJenkins
commented
Mar 13, 2014
All automated tests passed. |
AmplabJenkins
commented
Mar 13, 2014
Merged build triggered. |
AmplabJenkins
commented
Mar 13, 2014
Merged build started. |
There was a problem hiding this comment.
Let us create a separate test "takeSample from an empty rdd" and construct an empty rdd directly:
val emptyRdd = sc.parallelize(Seq.empty[Int], 2)
AmplabJenkins
commented
Mar 13, 2014
Merged build finished. |
AmplabJenkins
commented
Mar 13, 2014
All automated tests passed. |
AmplabJenkins
commented
Mar 13, 2014
Merged build triggered. |
AmplabJenkins
commented
Mar 13, 2014
Merged build started. |
mengxr
commented
Mar 13, 2014
LGTM. Waiting for Jenkins. |
AmplabJenkins
commented
Mar 13, 2014
Merged build finished. |
AmplabJenkins
commented
Mar 13, 2014
All automated tests passed. |
CodingCat
commented
Mar 14, 2014
mateiz
commented
Mar 14, 2014
Can you check whether this is broken in Python too, and fix it there as well? |
CodingCat
commented
Mar 14, 2014
sure, will do that this evening~ |
AmplabJenkins
commented
Mar 14, 2014
Merged build triggered. |
AmplabJenkins
commented
Mar 14, 2014
Merged build started. |
AmplabJenkins
commented
Mar 14, 2014
Merged build finished. |
AmplabJenkins
commented
Mar 14, 2014
All automated tests passed. |
CodingCat
commented
Mar 14, 2014
@mateiz, done~ |
mateiz
commented
Mar 17, 2014
Actually sorry, one other thought -- instead of throwing an error when Anyway both this and the empty RDD case are good catches. |
CodingCat
commented
Mar 17, 2014
Hi, @mateiz , I think the current implementation allows fraction == 0 case, or I misunderstood something? |
mateiz
commented
Mar 17, 2014
Ah, thanks, I missed that. Merged this in. |
https://spark-project.atlassian.net/browse/SPARK-1240 It seems that the current implementation does not handle the empty RDD case when run takeSample In this patch, before calling sample() inside takeSample API, I add a checker for this case and returns an empty Array when it's a empty RDD; also in sample(), I add a checker for the invalid fraction value In the test case, I also add several lines for this case Author: CodingCat <zhunansjtu@gmail.com> Closes#135 from CodingCat/SPARK-1240 and squashes the following commits: fef57d4 [CodingCat] fix the same problem in PySpark 36db06b [CodingCat] create new test cases for takeSample from an empty red 810948d [CodingCat] further fix a40e8fb [CodingCat] replace if with require ad483fd [CodingCat] handle the case with empty RDD when take sample Conflicts: core/src/main/scala/org/apache/spark/rdd/RDD.scala core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala
https://spark-project.atlassian.net/browse/SPARK-1240 It seems that the current implementation does not handle the empty RDD case when run takeSample In this patch, before calling sample() inside takeSample API, I add a checker for this case and returns an empty Array when it's a empty RDD; also in sample(), I add a checker for the invalid fraction value In the test case, I also add several lines for this case Author: CodingCat <zhunansjtu@gmail.com> Closesapache#135 from CodingCat/SPARK-1240 and squashes the following commits: fef57d4 [CodingCat] fix the same problem in PySpark 36db06b [CodingCat] create new test cases for takeSample from an empty red 810948d [CodingCat] further fix a40e8fb [CodingCat] replace if with require ad483fd [CodingCat] handle the case with empty RDD when take sample Conflicts: core/src/main/scala/org/apache/spark/rdd/RDD.scala core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala
Previous merge with upstream broke the build. Author: Herman van Hovell <hvanhovell@databricks.com> Closesapache#135 from hvanhovell/fix-hook-calling-external-catalog.
[ESPARK-135] 解决当不需要合并的时候仍然更换临时目录,导致最终结束为空的问题 解决当不需要合并的时候仍然更换临时目录,导致最终结束为空的问题 . resolveapache#135 See merge request !82
(cherry picked from commit b27ea82)
* Support k8s E2E test against specified k8s version - Create install-k8s role - Support to specify version of k8s and etcd - Add new job cloud-provider-openstack-acceptance-test-e2e-conformance-latest-release - Skip to copy 0 size test_results.html - Add post.yaml in cloud-provider-openstack-acceptance-test-e2e-conformance as a placeholder to upload test result to testgrid, but upload_e2e.py can not be found, implement it in following patchset. Partial-Bug: kubernetes/cloud-provider-openstack#103
* apache#135 bump jackson version to 2.10.4 * apache#135 update spark version r41 Co-authored-by: Yu Gan <yu.gan@kyligence.io>
Co-authored-by: Yu Gan <yu.gan@kyligence.io>
* apache#135 bump jackson version to 2.10.4 * apache#135 update spark version r41 Co-authored-by: Yu Gan <yu.gan@kyligence.io>
Co-authored-by: Yu Gan <yu.gan@kyligence.io>
### What changes were proposed in this pull request? The pr aims to upgrade commons-codec from 1.15 to 1.16.0. ### Why are the changes needed? 1.The new version brings some bug fixed, eg: - Fix byte-skipping in Base16 decoding #135. Fixes CODEC-305. - BaseNCodecOutputStream.eof() should not throw IOException. - Add support for Blake3 family of hashes. Fixes [CODEC-296](https://issues.apache.org/jira/browse/CODEC-296). 2.The full release notes: https://commons.apache.org/proper/commons-codec/changes-report.html#a1.16.0 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass GA. Closes#41707 from panbingkun/SPARK-44151. Authored-by: panbingkun <pbk1982@gmail.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
### What changes were proposed in this pull request? Plan files only, no code. `PLAN_TASK_63.md` for task 63, milestone 4's `Add`, `Subtract`, `Multiply` and `UnaryMinus` over fused int fields, int columns and int literals, in Spark's three evaluation modes: `LEGACY` wraps as the lanewise op does; `ANSI` detects an overflowing lane with a sign test (two XORs, an AND, a compare - two compares for a literal multiplier) ORed into task 52's accumulator, so the batch declines through the existing route and the row engine raises Spark's own `ARITHMETIC_OVERFLOW` for the same row; `TRY` clears the lane's validity and forfeits the dense body under task 42's rule. Two IR records carry the op and the mode as shape-bearing enums; a dedicated int-operand function keeps the int column entering only through arithmetic and comparisons, preserving task 38's leaf rule; `date_add` over an arithmetic offset goes through the existing column-shifted range analysis unchanged. The column-by-column multiply under `ANSI`/`TRY` declines in this task - the exact overflow test needs a product's high half, which is milestone 5's widening. `PLAN_MILESTONE_4.md` row 63 gains a `**Planned**` marker pointing at the plan. ### Why are the changes needed? The admission check, the register, the tests and the measurement plan are written and reviewed now so the task is ready the moment its prerequisites land, following the precedent set by task 67's plan PR. The code itself is intentionally not part of this PR: every file the implementation touches - `VarkaExpressionCompiler`, `VarkaVectorIR`, `VarkaLoopEmitter`, `VarkaEmitOptions` - is also being edited by the still-open task 59/60/61 stack (apache#126, apache#128, apache#130), so starting the code now would mean rebasing through three more merges before it could land. The plan records that gate explicitly: "the code starts after the task 61 stack lands." ### Does this PR introduce _any_ user-facing change? No. Documentation only. ### How was this patch tested? N/A - no code in this PR. `PLAN_TASK_63.md` was reviewed against the current compiler, emitter and evaluator sources on this branch as its admission check (section 2), tracing each of the four operations and three evaluation modes to Spark's own `BinaryArithmetic`/`UnaryMinus` semantics. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Sonnet 5)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V3VxmqDKhWHkvQ4Jrp6coG
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V3VxmqDKhWHkvQ4Jrp6coG
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V3VxmqDKhWHkvQ4Jrp6coG
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V3VxmqDKhWHkvQ4Jrp6coG
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V3VxmqDKhWHkvQ4Jrp6coG
https://spark-project.atlassian.net/browse/SPARK-1240
It seems that the current implementation does not handle the empty RDD case when run takeSample
In this patch, before calling sample() inside takeSample API, I add a checker for this case and returns an empty Array when it's a empty RDD; also in sample(), I add a checker for the invalid fraction value
In the test case, I also add several lines for this case