René's URL Explorer Experiment


Title: feat: add CancellationToken with collect/executeStream overloads by LantaoJin · Pull Request #69 · apache/datafusion-java · GitHub

Open Graph Title: feat: add CancellationToken with collect/executeStream overloads by LantaoJin · Pull Request #69 · apache/datafusion-java

X Title: feat: add CancellationToken with collect/executeStream overloads by LantaoJin · Pull Request #69 · apache/datafusion-java

Description: Which issue does this PR close? Closes #68 . Rationale for this change A long-running DataFrame.collect(allocator) or DataFrame.executeStream(allocator) call blocks the calling Java thread for the full duration of the query. Thread.interrupt() is a no-op (the thread is parked inside runtime().block_on(...)), and there is no way to free the in-flight query's native resources early. For any embedder running request timeouts, user-cancel actions, or node-shutdown drains, this is a hard operational gap. What changes are included in this PR? The cancellation we ship lives on the session, not on the DataFrame. A token is allocated by the session, passed to collect / executeStream, and fired from any thread. We deliberately do not add DataFrame.cancel(): a DataFrame is a lazy plan that can be executed concurrently from multiple threads, so a per-DataFrame cancel verb has ambiguous semantics. The token is the primitive; a Spark-style ctx.addTag(name) / ctx.cancelTag(name) sugar layer can land in a follow-up. Native shape: tokio_util::sync::CancellationToken per token, owned by a process-global registry keyed by an opaque u64 ID. JNI handlers look up by ID under a Mutex and clone the Arc out before any blocking work. The cloned Arc keeps the inner token alive for the borrow's lifetime, so an in-flight collect() future that already holds a clone keeps working through a concurrent close. close() removes the registry entry; the underlying token drops only when the last Arc clone goes away. Race safety: CancellationToken.nativeHandle is final AtomicLong. cancel() / isCancelled() read via get(); close() uses getAndSet(0L) so only the winning thread issues closeToken. Combined with the registry on the native side, a concurrent close + cancel + query-start race produces at worst a clean IllegalStateException from a missing-ID lookup -- never a use-after-free of a freed Box. The registry pattern is the same scaffolding upstream issue #40 calls for across all handle types; cancellation tokens get it first because they are designed to be fired from a thread that does not own them, so the race window is the widest of any handle. Are these changes tested? Yes -- 19 new tests across CancellationTokenTest and DataFrameCancellationTest. Are there any user-facing changes? Yes -- purely additive. New CancellationToken class, one new method on SessionContext, two new overloads on DataFrame. No API removals, no deprecations, no behaviour change for existing callers. New Cargo dependency: tokio-util = { version = "0.7", features = ["rt"] }; already a transitive dep, so no new crate in the build, just a feature flag added.

Open Graph Description: Which issue does this PR close? Closes #68 . Rationale for this change A long-running DataFrame.collect(allocator) or DataFrame.executeStream(allocator) call blocks the calling Java thread for th...

X Description: Which issue does this PR close? Closes #68 . Rationale for this change A long-running DataFrame.collect(allocator) or DataFrame.executeStream(allocator) call blocks the calling Java thread for th...

Opengraph URL: https://github.com/apache/datafusion-java/pull/69

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.4

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:7f7a1419-4227-af76-30e8-21253351b9a2
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idDD4A:3ABDFB:2324CB:306A98:6B04681D
html-safe-nonce33dd7fb789683f6eef196361dcf7d63b7e5ce52a37f2b9cf763ca2320b541a9a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDRBOjNBQkRGQjoyMzI0Q0I6MzA2QTk4OjZCMDQ2ODFEIiwidmlzaXRvcl9pZCI6IjcyODQ4MjAwOTQxMjYxNTU4MDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacec6be25dd9001815f8f5cec1f07ea8eb039b904253aa2d016214e920a263eedd
hovercard-subject-tagpull_request:3709029531
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/apache/datafusion-java/pull/69/files
twitter:imagehttps://avatars.githubusercontent.com/u/1853780?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1853780?s=400&v=4
og:image:altWhich issue does this PR close? Closes #68 . Rationale for this change A long-running DataFrame.collect(allocator) or DataFrame.executeStream(allocator) call blocks the calling Java thread for th...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None83e4c0e58c5162177f3c161c5fbad38527ae04c11ac14980f9f9d85ae2027b1f
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/apache/datafusion-java git https://github.com/apache/datafusion-java.git
octolytics-dimension-user_id47359
octolytics-dimension-user_loginapache
octolytics-dimension-repository_id1237105117
octolytics-dimension-repository_nwoapache/datafusion-java
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1237105117
octolytics-dimension-repository_network_root_nwoapache/datafusion-java
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseca4d07a7cef4e4b75f821dc25e7300d80c1450a9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/apache/datafusion-java/pull/69/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fapache%2Fdatafusion-java%2Fpull%2F69%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fapache%2Fdatafusion-java%2Fpull%2F69%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=apache%2Fdatafusion-java
Reloadhttps://github.com/apache/datafusion-java/pull/69/files
Reloadhttps://github.com/apache/datafusion-java/pull/69/files
Reloadhttps://github.com/apache/datafusion-java/pull/69/files
apachehttps://github.com/apache
datafusion-javahttps://github.com/apache/datafusion-java
Codehttps://github.com/apache/datafusion-java
Issues10 (10)https://github.com/apache/datafusion-java/issues
Pull requests10 (10)https://github.com/apache/datafusion-java/pulls
Discussionshttps://github.com/apache/datafusion-java/discussions
Actionshttps://github.com/apache/datafusion-java/actions
Security and qualityhttps://github.com/apache/datafusion-java/security
Insightshttps://github.com/apache/datafusion-java/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fapache%2Fdatafusion-java%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fapache%2Fdatafusion-java%2Fissues%2Fnew%2Fchoose
LantaoJinhttps://github.com/LantaoJin
apache:mainhttps://github.com/apache/datafusion-java/tree/main
LantaoJin:feat/dataframe-cancellationhttps://github.com/LantaoJin/datafusion-java/tree/feat/dataframe-cancellation
Conversation 2 https://github.com/apache/datafusion-java/pull/69
Commits 4 https://github.com/apache/datafusion-java/pull/69/commits
Checks 1 https://github.com/apache/datafusion-java/pull/69/checks
Files changed https://github.com/apache/datafusion-java/pull/69/files
Please reload this pagehttps://github.com/apache/datafusion-java/pull/69/files
feat: add CancellationToken with collect/executeStream overloads https://github.com/apache/datafusion-java/pull/69/files#top
Show all changes 4 commits https://github.com/apache/datafusion-java/pull/69/files
05f0d3d feat(cancel): add CancellationToken with collect/executeStream overloads LantaoJin May 19, 2026 https://github.com/apache/datafusion-java/pull/69/commits/05f0d3daa10eee98b0c15d92def1c4f494546e43
4bd2ad1 Merge remote-tracking branch 'upstream/main' into feat/dataframe-canc… LantaoJin May 20, 2026 https://github.com/apache/datafusion-java/pull/69/commits/4bd2ad15ebc5ddb4a0ead5ee8bfc664118de8cde
1d3011d Merge remote-tracking branch 'upstream/main' into feat/dataframe-canc… LantaoJin May 26, 2026 https://github.com/apache/datafusion-java/pull/69/commits/1d3011d8acc399b872839b37b26149972e64bdcb
eaa74c6 Merge remote-tracking branch 'upstream/main' into feat/dataframe-canc… LantaoJin May 26, 2026 https://github.com/apache/datafusion-java/pull/69/commits/eaa74c6fc18e57aa386072a82d6b34ad702e2b36
Clear filters https://github.com/apache/datafusion-java/pull/69/files
Please reload this pagehttps://github.com/apache/datafusion-java/pull/69/files
Please reload this pagehttps://github.com/apache/datafusion-java/pull/69/files
CancellationToken.java https://github.com/apache/datafusion-java/pull/69/files#diff-937089d21d3dde6d73ea28dc52a68daa5fba65cf15938215b026c289399c1e62
DataFrame.java https://github.com/apache/datafusion-java/pull/69/files#diff-a044f0300400b70bd8ec9c4e4a27c17b89674595e0ae3f5a6ebf88e393ba479b
SessionContext.java https://github.com/apache/datafusion-java/pull/69/files#diff-9aa9338a7364e93d5e2e4547564e7eb08e65a70f6d51b6fa896325cd4d87451e
CancellationTokenTest.java https://github.com/apache/datafusion-java/pull/69/files#diff-d8a3228525feef73f08fa0f66ae6e19c4c2e3fa3178783e015eca625fbef8344
DataFrameCancellationTest.java https://github.com/apache/datafusion-java/pull/69/files#diff-3549ca9d191055b130b5b682ab628716046ad63381019d342a56858da2b46354
Cargo.lock https://github.com/apache/datafusion-java/pull/69/files#diff-078f375cfc74d2a2bae74160d7469389a54227046a6daec4edb0481597ec2aa8
Cargo.toml https://github.com/apache/datafusion-java/pull/69/files#diff-a1571d177cbc44d96f49c8f29b6340febcee141a0e26833931bcd78c5441fb55
cancellation.rs https://github.com/apache/datafusion-java/pull/69/files#diff-00e32986f2d6c62374204cb7fbb79dfab1488743f81b278b6c326e1732df935f
errors.rs https://github.com/apache/datafusion-java/pull/69/files#diff-69e4ba2c475e7c1718d299d82907ff348fbca3827d6a3c175cc01d0750264511
lib.rs https://github.com/apache/datafusion-java/pull/69/files#diff-697685fba8d3d4a3a8a287bad6e1369e50e1c98bd878823415758c2a642cbb6e
core/src/main/java/org/apache/datafusion/CancellationToken.javahttps://github.com/apache/datafusion-java/pull/69/files#diff-937089d21d3dde6d73ea28dc52a68daa5fba65cf15938215b026c289399c1e62
View file https://github.com/apache/datafusion-java/blob/eaa74c6fc18e57aa386072a82d6b34ad702e2b36/core/src/main/java/org/apache/datafusion/CancellationToken.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/apache/datafusion-java/pull/69/{{ revealButtonHref }}
core/src/main/java/org/apache/datafusion/DataFrame.javahttps://github.com/apache/datafusion-java/pull/69/files#diff-a044f0300400b70bd8ec9c4e4a27c17b89674595e0ae3f5a6ebf88e393ba479b
View file https://github.com/apache/datafusion-java/blob/eaa74c6fc18e57aa386072a82d6b34ad702e2b36/core/src/main/java/org/apache/datafusion/DataFrame.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/apache/datafusion-java/pull/69/{{ revealButtonHref }}
https://github.com/apache/datafusion-java/pull/69/files#diff-a044f0300400b70bd8ec9c4e4a27c17b89674595e0ae3f5a6ebf88e393ba479b
https://github.com/apache/datafusion-java/pull/69/files#diff-a044f0300400b70bd8ec9c4e4a27c17b89674595e0ae3f5a6ebf88e393ba479b
https://github.com/apache/datafusion-java/pull/69/files#diff-a044f0300400b70bd8ec9c4e4a27c17b89674595e0ae3f5a6ebf88e393ba479b
https://github.com/apache/datafusion-java/pull/69/files#diff-a044f0300400b70bd8ec9c4e4a27c17b89674595e0ae3f5a6ebf88e393ba479b
https://github.com/apache/datafusion-java/pull/69/files#diff-a044f0300400b70bd8ec9c4e4a27c17b89674595e0ae3f5a6ebf88e393ba479b
core/src/main/java/org/apache/datafusion/SessionContext.javahttps://github.com/apache/datafusion-java/pull/69/files#diff-9aa9338a7364e93d5e2e4547564e7eb08e65a70f6d51b6fa896325cd4d87451e
View file https://github.com/apache/datafusion-java/blob/eaa74c6fc18e57aa386072a82d6b34ad702e2b36/core/src/main/java/org/apache/datafusion/SessionContext.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/apache/datafusion-java/pull/69/{{ revealButtonHref }}
https://github.com/apache/datafusion-java/pull/69/files#diff-9aa9338a7364e93d5e2e4547564e7eb08e65a70f6d51b6fa896325cd4d87451e
https://github.com/apache/datafusion-java/pull/69/files#diff-9aa9338a7364e93d5e2e4547564e7eb08e65a70f6d51b6fa896325cd4d87451e
https://github.com/apache/datafusion-java/pull/69/files#diff-9aa9338a7364e93d5e2e4547564e7eb08e65a70f6d51b6fa896325cd4d87451e
Please reload this pagehttps://github.com/apache/datafusion-java/pull/69/files
Please reload this pagehttps://github.com/apache/datafusion-java/pull/69/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.