mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-06 06:48:12 +08:00
Do not over-prune var data cache (#1198)
* Remove unused variables and imports
* Simplify conditional
* Fix typo
* Do not overprune var data cache
There is a bug in how the universe and world gene sets are constructed
and passed to `ControlsHelpers.pruneVarDataCache` that causes the var
data cache to be over-pruned. This commit fixes the issue.
Consider the following example from the node console:
```
❯ node
Welcome to Node.js v13.5.0.
Type ".help" for more information.
> new Set([1], [2], [3])
Set(1) { 1 }
```
What we really want is the set `Set(3) { 1, 2, 3 }`, which can be
constructed as:
```
> new Set([].concat([1], [2], [3]))
Set(3) { 1, 2, 3 }
```
This commit is contained in:
@@ -127,14 +127,14 @@ const doInitialDataLoad = () =>
|
|||||||
Step 2 - load the minimum stuff required to display.
|
Step 2 - load the minimum stuff required to display.
|
||||||
*/
|
*/
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
layoutFetchAndLoad(dispatch, schema, universe),
|
layoutFetchAndLoad(dispatch),
|
||||||
varAnnotationFetchAndLoad(dispatch, schema, universe)
|
varAnnotationFetchAndLoad(dispatch, schema)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Step 3 - load everything else
|
Step 3 - load everything else
|
||||||
*/
|
*/
|
||||||
await obsAnnotationFetchAndLoad(dispatch, schema, universe);
|
await obsAnnotationFetchAndLoad(dispatch, schema);
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: "initial data load complete (universe exists)",
|
type: "initial data load complete (universe exists)",
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class Category extends React.Component {
|
|||||||
// || this.checkbox.indeterminate === false
|
// || this.checkbox.indeterminate === false
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
this.toggleNone();
|
this.toggleNone();
|
||||||
} else if (!isChecked) {
|
} else {
|
||||||
this.toggleAll();
|
this.toggleAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -422,8 +422,7 @@ class Graph extends React.Component {
|
|||||||
handleEnd,
|
handleEnd,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
responsive,
|
responsive,
|
||||||
this.graphPaddingRightLeft,
|
this.graphPaddingRightLeft
|
||||||
graphInteractionMode
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return { toolSVG: newToolSVG, tool, container };
|
return { toolSVG: newToolSVG, tool, container };
|
||||||
|
|||||||
Vendored
-1
@@ -1,7 +1,6 @@
|
|||||||
// jshint esversion: 6
|
// jshint esversion: 6
|
||||||
|
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import * as globals from "../globals";
|
|
||||||
import { subsetAndResetGeneLists } from "../util/stateManager/controlsHelpers";
|
import { subsetAndResetGeneLists } from "../util/stateManager/controlsHelpers";
|
||||||
|
|
||||||
const Controls = (
|
const Controls = (
|
||||||
|
|||||||
@@ -221,15 +221,15 @@ const Undoable = (reducer, undoableKeys, options = {}) => {
|
|||||||
const aType = action.type;
|
const aType = action.type;
|
||||||
switch (aType) {
|
switch (aType) {
|
||||||
case "@@undoable/undo": {
|
case "@@undoable/undo": {
|
||||||
return undo(currentState, action);
|
return undo(currentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
case "@@undoable/redo": {
|
case "@@undoable/redo": {
|
||||||
return redo(currentState, action);
|
return redo(currentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
case "@@undoable/clear": {
|
case "@@undoable/clear": {
|
||||||
return clear(currentState, action);
|
return clear(currentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ Signature: (fsm, event, from) => undoableAction
|
|||||||
const onFsmError = (fsm, event, from) => {
|
const onFsmError = (fsm, event, from) => {
|
||||||
console.error(`FSM error [event: "${event}", state: "${from}"]`, fsm);
|
console.error(`FSM error [event: "${event}", state: "${from}"]`, fsm);
|
||||||
// In production, try to recover gracefully if we have unexpected state
|
// In production, try to recover gracefully if we have unexpected state
|
||||||
return clear(fsm);
|
return clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -62,9 +62,7 @@ const Universe = (state = null, action, nextSharedState, prevSharedState) => {
|
|||||||
const { userDefinedGenes, diffexpGenes } = prevSharedState;
|
const { userDefinedGenes, diffexpGenes } = prevSharedState;
|
||||||
const allTheGenesWeNeed = [
|
const allTheGenesWeNeed = [
|
||||||
...new Set(
|
...new Set(
|
||||||
userDefinedGenes,
|
[userDefinedGenes, diffexpGenes, Object.keys(action.expressionData)].filter(ele => ele).flat()
|
||||||
diffexpGenes,
|
|
||||||
Object.keys(action.expressionData)
|
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
varData = ControlsHelpers.pruneVarDataCache(varData, allTheGenesWeNeed);
|
varData = ControlsHelpers.pruneVarDataCache(varData, allTheGenesWeNeed);
|
||||||
|
|||||||
@@ -101,15 +101,10 @@ const WorldReducer = (
|
|||||||
const { userDefinedGenes, diffexpGenes } = prevSharedState;
|
const { userDefinedGenes, diffexpGenes } = prevSharedState;
|
||||||
const allTheGenesWeNeed = [
|
const allTheGenesWeNeed = [
|
||||||
...new Set(
|
...new Set(
|
||||||
userDefinedGenes,
|
[userDefinedGenes, diffexpGenes, Object.keys(action.expressionData)].filter(ele => ele).flat()
|
||||||
diffexpGenes,
|
|
||||||
Object.keys(action.expressionData)
|
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
unclippedVarData = ControlsHelpers.pruneVarDataCache(
|
unclippedVarData = ControlsHelpers.pruneVarDataCache(unclippedVarData, allTheGenesWeNeed);
|
||||||
unclippedVarData,
|
|
||||||
allTheGenesWeNeed
|
|
||||||
);
|
|
||||||
|
|
||||||
// at this point, we have the unclipped data in unclippedVarData.
|
// at this point, we have the unclipped data in unclippedVarData.
|
||||||
// Now create clipped.
|
// Now create clipped.
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ export function pruneVarDataCache(varData, needed) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
VarDataCacheLowWatermark - this cofig value sets the minimum cache size,
|
VarDataCacheLowWatermark - this config value sets the minimum cache size,
|
||||||
in columns, below which we don't throw away data.
|
in columns, below which we don't throw away data.
|
||||||
|
|
||||||
The value should be high enough so we are caching the maximum which will
|
The value should be high enough so we are caching the maximum which will
|
||||||
|
|||||||
Reference in New Issue
Block a user