Skip to content

Commit

Permalink
[Lens] Performance refactoring for indexpattern fast lookup and Opera…
Browse files Browse the repository at this point in the history
…tion support matrix computation (#82829)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
dej611 and kibanamachine committed Nov 10, 2020
1 parent 33fdc42 commit 9951465
Show file tree
Hide file tree
Showing 30 changed files with 996 additions and 792 deletions.
254 changes: 133 additions & 121 deletions x-pack/plugins/lens/public/indexpattern_datasource/datapanel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,131 @@ import { ChangeIndexPattern } from './change_indexpattern';
import { EuiProgress, EuiLoadingSpinner } from '@elastic/eui';
import { documentField } from './document_field';
import { chartPluginMock } from '../../../../../src/plugins/charts/public/mocks';
import { getFieldByNameFactory } from './pure_helpers';

const fieldsOne = [
{
name: 'timestamp',
displayName: 'timestampLabel',
type: 'date',
aggregatable: true,
searchable: true,
},
{
name: 'bytes',
displayName: 'bytes',
type: 'number',
aggregatable: true,
searchable: true,
},
{
name: 'memory',
displayName: 'amemory',
type: 'number',
aggregatable: true,
searchable: true,
},
{
name: 'unsupported',
displayName: 'unsupported',
type: 'geo',
aggregatable: true,
searchable: true,
},
{
name: 'source',
displayName: 'source',
type: 'string',
aggregatable: true,
searchable: true,
},
{
name: 'client',
displayName: 'client',
type: 'ip',
aggregatable: true,
searchable: true,
},
documentField,
];

const fieldsTwo = [
{
name: 'timestamp',
displayName: 'timestampLabel',
type: 'date',
aggregatable: true,
searchable: true,
aggregationRestrictions: {
date_histogram: {
agg: 'date_histogram',
fixed_interval: '1d',
delay: '7d',
time_zone: 'UTC',
},
},
},
{
name: 'bytes',
displayName: 'bytes',
type: 'number',
aggregatable: true,
searchable: true,
aggregationRestrictions: {
histogram: {
agg: 'histogram',
interval: 1000,
},
max: {
agg: 'max',
},
min: {
agg: 'min',
},
sum: {
agg: 'sum',
},
},
},
{
name: 'source',
displayName: 'source',
type: 'string',
aggregatable: true,
searchable: true,
aggregationRestrictions: {
terms: {
agg: 'terms',
},
},
},
documentField,
];

const fieldsThree = [
{
name: 'timestamp',
displayName: 'timestampLabel',
type: 'date',
aggregatable: true,
searchable: true,
},
{
name: 'bytes',
displayName: 'bytes',
type: 'number',
aggregatable: true,
searchable: true,
},
{
name: 'source',
displayName: 'source',
type: 'string',
aggregatable: true,
searchable: true,
},
documentField,
];

const initialState: IndexPatternPrivateState = {
indexPatternRefs: [],
Expand Down Expand Up @@ -85,139 +210,24 @@ const initialState: IndexPatternPrivateState = {
title: 'idx1',
timeFieldName: 'timestamp',
hasRestrictions: false,
fields: [
{
name: 'timestamp',
displayName: 'timestampLabel',
type: 'date',
aggregatable: true,
searchable: true,
},
{
name: 'bytes',
displayName: 'bytes',
type: 'number',
aggregatable: true,
searchable: true,
},
{
name: 'memory',
displayName: 'amemory',
type: 'number',
aggregatable: true,
searchable: true,
},
{
name: 'unsupported',
displayName: 'unsupported',
type: 'geo',
aggregatable: true,
searchable: true,
},
{
name: 'source',
displayName: 'source',
type: 'string',
aggregatable: true,
searchable: true,
},
{
name: 'client',
displayName: 'client',
type: 'ip',
aggregatable: true,
searchable: true,
},
documentField,
],
fields: fieldsOne,
getFieldByName: getFieldByNameFactory(fieldsOne),
},
'2': {
id: '2',
title: 'idx2',
timeFieldName: 'timestamp',
hasRestrictions: true,
fields: [
{
name: 'timestamp',
displayName: 'timestampLabel',
type: 'date',
aggregatable: true,
searchable: true,
aggregationRestrictions: {
date_histogram: {
agg: 'date_histogram',
fixed_interval: '1d',
delay: '7d',
time_zone: 'UTC',
},
},
},
{
name: 'bytes',
displayName: 'bytes',
type: 'number',
aggregatable: true,
searchable: true,
aggregationRestrictions: {
histogram: {
agg: 'histogram',
interval: 1000,
},
max: {
agg: 'max',
},
min: {
agg: 'min',
},
sum: {
agg: 'sum',
},
},
},
{
name: 'source',
displayName: 'source',
type: 'string',
aggregatable: true,
searchable: true,
aggregationRestrictions: {
terms: {
agg: 'terms',
},
},
},
documentField,
],
fields: fieldsTwo,
getFieldByName: getFieldByNameFactory(fieldsTwo),
},
'3': {
id: '3',
title: 'idx3',
timeFieldName: 'timestamp',
hasRestrictions: false,
fields: [
{
name: 'timestamp',
displayName: 'timestampLabel',
type: 'date',
aggregatable: true,
searchable: true,
},
{
name: 'bytes',
displayName: 'bytes',
type: 'number',
aggregatable: true,
searchable: true,
},
{
name: 'source',
displayName: 'source',
type: 'string',
aggregatable: true,
searchable: true,
},
documentField,
],
fields: fieldsThree,
getFieldByName: getFieldByNameFactory(fieldsThree),
},
},
isFirstExistenceFetch: false,
Expand Down Expand Up @@ -330,13 +340,15 @@ describe('IndexPattern Data Panel', () => {
title: 'aaa',
timeFieldName: 'atime',
fields: [],
getFieldByName: getFieldByNameFactory([]),
hasRestrictions: false,
},
b: {
id: 'b',
title: 'bbb',
timeFieldName: 'btime',
fields: [],
getFieldByName: getFieldByNameFactory([]),
hasRestrictions: false,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import './datapanel.scss';
import { uniq, keyBy, groupBy } from 'lodash';
import { uniq, groupBy } from 'lodash';
import React, { useState, memo, useCallback, useMemo } from 'react';
import {
EuiFlexGroup,
Expand Down Expand Up @@ -266,9 +266,8 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
const fieldInfoUnavailable = existenceFetchFailed || currentIndexPattern.hasRestrictions;

const unfilteredFieldGroups: FieldGroups = useMemo(() => {
const fieldByName = keyBy(allFields, 'name');
const containsData = (field: IndexPatternField) => {
const overallField = fieldByName[field.name];
const overallField = currentIndexPattern.getFieldByName(field.name);

return (
overallField && fieldExists(existingFields, currentIndexPattern.title, overallField.name)
Expand Down
Loading

0 comments on commit 9951465

Please sign in to comment.