-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[ML] Switch from normal sampling to random sampler for Index data visualizer table #144646
Merged
Merged
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
7857ec2
Change to random sampler
qn895 086ac92
Fix time field
qn895 5894931
Clean up, update functional tests
qn895 20edcf2
Tweak heading of column
qn895 454597b
Merge remote-tracking branch 'upstream/main' into ml-dv-random-sample…
qn895 9c5dcfd
Merge remote-tracking branch 'upstream/main' into ml-dv-random-sample…
qn895 0a6d366
Fix count & percentage, add loading indicating when sampling prob cha…
qn895 2a9f150
Add comment to num sampled, fix translation
qn895 9358d01
Match count for discover/lens and data viz
qn895 1556606
Match count for discover/lens and data viz
qn895 b1fb6ec
Clean up, i18n, types
qn895 c3c626d
Update tests
qn895 214482c
Update tests data view management
qn895 16bd9ef
Merge remote-tracking branch 'upstream/main' into ml-dv-random-sample…
qn895 97d46f6
Delete unused file, remove todos
qn895 cb33dd2
Merge remote-tracking branch 'upstream/main' into ml-dv-random-sample…
qn895 80872e0
Fix percentage message if undefined, move types,
qn895 33c645f
Move gear to the left, change debounce to 100ms
qn895 65902a4
Merge remote-tracking branch 'upstream/main' into ml-dv-random-sample…
qn895 1d5fe9b
Move cog icon to right, refactor onChange
qn895 7d7ba42
Fix count for file data visualizer
qn895 c24049c
Merge branch 'main' into ml-dv-random-sampler-part-2
kibanamachine 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 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 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
*/ | ||
|
||
import React, { FC, useMemo } from 'react'; | ||
import { EuiSpacer, EuiText, htmlIdGenerator } from '@elastic/eui'; | ||
import { EuiText, htmlIdGenerator } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { | ||
|
@@ -18,6 +18,8 @@ import { | |
VectorLayerDescriptor, | ||
} from '@kbn/maps-plugin/common'; | ||
import { EMSTermJoinConfig } from '@kbn/maps-plugin/public'; | ||
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types'; | ||
import { useDataVisualizerKibana } from '../../../../../kibana_context'; | ||
import { EmbeddedMapComponent } from '../../../embedded_map'; | ||
import { FieldVisStats } from '../../../../../../../common/types'; | ||
import { ExpandedRowPanel } from './expanded_row_panel'; | ||
|
@@ -97,13 +99,55 @@ interface Props { | |
} | ||
|
||
export const ChoroplethMap: FC<Props> = ({ stats, suggestion }) => { | ||
const { fieldName, isTopValuesSampled, topValues, topValuesSamplerShardSize } = stats!; | ||
const { | ||
services: { | ||
data: { fieldFormats }, | ||
}, | ||
} = useDataVisualizerKibana(); | ||
|
||
const { fieldName, isTopValuesSampled, topValues, sampleCount, totalDocuments } = stats!; | ||
|
||
const layerList: VectorLayerDescriptor[] = useMemo( | ||
() => [getChoroplethTopValuesLayer(fieldName || '', topValues || [], suggestion)], | ||
[suggestion, fieldName, topValues] | ||
); | ||
|
||
const countsElement = totalDocuments ? ( | ||
<EuiText color="subdued" size="xs"> | ||
{isTopValuesSampled ? ( | ||
<FormattedMessage | ||
id="xpack.dataVisualizer.dataGrid.fieldExpandedRow.choroplethMapTopValues.calculatedFromSampleRecordsLabel" | ||
defaultMessage="Calculated from {sampledDocumentsFormatted} sample {sampledDocuments, plural, one {record} other {records}}." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed here |
||
values={{ | ||
sampledDocuments: sampleCount, | ||
sampledDocumentsFormatted: ( | ||
<strong> | ||
{fieldFormats | ||
.getDefaultInstance(KBN_FIELD_TYPES.NUMBER, [ES_FIELD_TYPES.INTEGER]) | ||
.convert(sampleCount)} | ||
</strong> | ||
), | ||
}} | ||
/> | ||
) : ( | ||
<FormattedMessage | ||
id="xpack.dataVisualizer.dataGrid.fieldExpandedRow.choroplethMapTopValues.calculatedFromTotalRecordsLabel" | ||
defaultMessage="Calculated from {totalDocumentsFormatted} {totalDocuments, plural, one {record} other {records}}." | ||
values={{ | ||
totalDocuments, | ||
totalDocumentsFormatted: ( | ||
<strong> | ||
{fieldFormats | ||
.getDefaultInstance(KBN_FIELD_TYPES.NUMBER, [ES_FIELD_TYPES.INTEGER]) | ||
.convert(totalDocuments ?? 0)} | ||
</strong> | ||
), | ||
}} | ||
/> | ||
)} | ||
</EuiText> | ||
) : null; | ||
|
||
return ( | ||
<ExpandedRowPanel | ||
dataTestSubj={'fileDataVisualizerChoroplethMapTopValues'} | ||
|
@@ -114,20 +158,7 @@ export const ChoroplethMap: FC<Props> = ({ stats, suggestion }) => { | |
<EmbeddedMapComponent layerList={layerList} /> | ||
</div> | ||
|
||
{isTopValuesSampled === true && ( | ||
<div> | ||
<EuiSpacer size={'s'} /> | ||
<EuiText size="xs" textAlign={'center'}> | ||
<FormattedMessage | ||
id="xpack.dataVisualizer.dataGrid.fieldExpandedRow.choroplethMapTopValues.calculatedFromSampleDescription" | ||
defaultMessage="Calculated from sample of {topValuesSamplerShardSize} documents per shard" | ||
values={{ | ||
topValuesSamplerShardSize, | ||
}} | ||
/> | ||
</EuiText> | ||
</div> | ||
)} | ||
{countsElement} | ||
</ExpandedRowPanel> | ||
); | ||
}; |
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.
it would be more performant to put all of the logic in this
onChange
function inside the function that is wrapped in the debounce. There's no need to be calculating theclosestProbability
on every change if it's just going to be discarded.Also there is a useful hook called
useDebounce
which might work well here.You could put the
e.currentTarget.value
in a temporary state variable e.g.newProbability
and thenuseDebounce
could watch for changes in that variable.