-
Notifications
You must be signed in to change notification settings - Fork 161
feat(doris): prune index fields request by time range #2362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { FormInstance } from 'antd/es/form'; | ||
| import moment from 'moment'; | ||
|
|
||
| import { parseRange } from '@/components/TimeRangePicker'; | ||
|
|
||
| import { IndexTimeRange } from '../../services'; | ||
|
|
||
| /** | ||
| * 取当前检索时间范围(毫秒),用于 index 字段接口。后端据此把 DESC 裁到覆盖该范围的分区, | ||
| * 不传则 DESC 整张表,大表上要几十秒。字段集随时间范围变化,所以时间范围变了要重新取。 | ||
| */ | ||
| export default function getIndexTimeRange(form: FormInstance): IndexTimeRange { | ||
| const range = form.getFieldValue(['query', 'range']); | ||
| if (!range) { | ||
| return {}; | ||
| } | ||
| const parsedRange = parseRange(range); | ||
| return { | ||
| from: moment(parsedRange.start).valueOf(), | ||
| to: moment(parsedRange.end).valueOf(), | ||
| }; | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🤖 get_repo_knowledge executed:
get_repo_knowledge n9e/fe /tmp/coderabbit-repo-knowledge/n9e-fe-c84179d0/conventionsLength of output: 2554
🏁 Script executed:
Repository: n9e/fe
Length of output: 15773
🏁 Script executed:
Repository: n9e/fe
Length of output: 32781
🏁 Script executed:
Repository: n9e/fe
Length of output: 27708
🏁 Script executed:
Repository: n9e/fe
Length of output: 1454
🌐 Web query:
ahooks 3.8.0 useRequest refreshDeps concurrent requests cancellation stale result implementation💡 Result:
<search_synthesis>
In ahooks 3.8.0, useRequest handles concurrent requests and race conditions through an internal mechanism that ensures only the result of the latest request is applied to the state [1][2]. Key implementation details regarding your query include: 1. Concurrent Requests and Race Conditions: By default, useRequest manages race conditions by tracking the execution count of requests [1]. When multiple requests are triggered (e.g., via rapid calls to runAsync), the hook internally ignores the results of any "stale" (previous) requests [1][2]. Only the result from the most recent request will trigger state updates (like data, loading, or error) and execute callbacks such as onSuccess or onError [3][2]. 2. Cancellation and Stale Results: Because standard JavaScript Promises cannot be physically aborted, ahooks implements this by "hanging" or ignoring the results of superseded requests [1]. In version 3.8.0, improvements were made to ensure that superseded runAsync/refreshAsync calls reject with a dedicated CancelledError rather than hanging indefinitely [3]. This allows developers to distinguish between a genuine service failure and a request that was cancelled due to a newer request superseding it [3]. 3. refreshDeps: The refreshDeps option automatically triggers a re-run of the request when any of the dependencies in the provided array change [4]. This is integrated into the same request lifecycle, meaning if a dependency change triggers a new request while a previous one is still pending, the race condition handling described above will apply, and the previous request&
#39;s result will be ignored [1]. 4. Stale Data (SWR): When using cacheKey, useRequest implements a stale-while-revalidate (SWR) pattern [5][6]. The staleTime option defines how long cached data is considered "fresh" [5]. If a request is made within the staleTime window, the hook returns the cached data immediately without re-initiating the network request [5][7]. If the data is stale, it returns the cached data while simultaneously triggering a background request to update the cache [5][7]. In summary, you do not need to manually implement cancellation logic for standard race conditions; the library handles this by ensuring only the latest request's lifecycle events (onSuccess, etc.) are processed [2]. If you need to handle the cancellation explicitly in your own code, you can catch the CancelledError using isCancelledError(error) [3].</search_synthesis>
<source_evidence>
Citations:
Discard superseded field responses.
useRequestignores stale results for its own state, but it cannot abort the underlying promise or prevent side effects inside the service. A slower request can therefore apply fields from an older time range after a newer request starts.SideBarNav, check a latest-request sequence ID beforeform.setFieldsValue({ query: patch })andonIndexDataChange(fields).QueryBuilder, use the same check before settingtime_field.📍 Affects 2 files
src/plugins/doris/ExplorerNG/SideBarNav/index.tsx#L122-L122(this comment)src/plugins/doris/ExplorerNG/components/QueryBuilder/index.tsx#L98-L98🤖 Prompt for AI Agents
Source: Learnings