-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat: convert dataset to table class #1239
Conversation
heshan0131
commented
Aug 18, 2020
- add valueAccessor to Kepler field, remove tableFieldIdx
- Move filter dataset in to table class
- Move field domain calculation into table class
5b20ed2
to
ec2fc7a
Compare
ec2fc7a
to
1507458
Compare
a6c098c
to
8627384
Compare
test/node/utils/index.js
Outdated
import './color-util-test'; | ||
import './util-test'; | ||
import './export-utils-test'; | ||
// import './gpu-filter-utils-test'; |
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.
all these tests are disabled?
bbfcd58
to
1cc8c16
Compare
src/components/map-container.js
Outdated
@@ -503,7 +504,7 @@ export default function MapContainerFactory(MapPopover, MapControl, Editor) { | |||
transformRequest | |||
}; | |||
|
|||
const isEdit = mapControls.mapDraw.active; | |||
const isEdit = !isExport && mapControls.mapDraw.active; |
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.
this now has confict with master
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.
Rebased
Signed-off-by: Ib Green <ib@unfolded.ai>
Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Giuseppe Macri <macri.giuseppe@gmail.com>
Signed-off-by: Giuseppe Macri <macri.giuseppe@gmail.com>
Signed-off-by: Giuseppe Macri <macri.giuseppe@gmail.com>
Signed-off-by: Giuseppe Macri <macri.giuseppe@gmail.com>
Signed-off-by: Giuseppe Macri <macri.giuseppe@gmail.com>
Signed-off-by: Giuseppe Macri <macri.giuseppe@gmail.com>
Signed-off-by: Giuseppe Macri <macri.giuseppe@gmail.com>
Signed-off-by: Giuseppe Macri <macri.giuseppe@gmail.com>
1cc8c16
to
7993342
Compare
@igorDykhta Sounds like this is coming together, you can probably rebase your work on this now. |
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.
Looks good in general.
Not sure about inconsistent fieldIdx in several tests and some comments leftovers.
@@ -900,8 +895,8 @@ export default class Layer { | |||
* @returns {object} layer | |||
*/ | |||
updateLayerDomain(datasets, newFilter) { | |||
const dataset = this.getDataset(datasets); | |||
if (!dataset) { | |||
const table = this.getDataset(datasets); |
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.
Interchangeable table/dataset variables are quite confusing. Do we plan to unify this in the future?
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.
yea i agree, let's just keep calling it dataset
in kepler.gl, because it is used everywhere
src/processors/data-processor.js
Outdated
@@ -140,6 +140,7 @@ export function processCsvData(rawData, header) { | |||
// here we get a list of none null values to run analyze on | |||
const sample = getSampleForTypeAnalyze({fields: headerRow, allData: rows}); | |||
const fields = getFieldsFromData(sample, headerRow); | |||
// console.log(JSON.stringify(fields, null, 2)); |
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.
Comment left after testing.
test/fixtures/state-saved-v0.js
Outdated
analyzerType: 'INT' | ||
fieldIdx: 9, | ||
analyzerType: 'INT', | ||
valueAccessor: values => values[0] |
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.
Not exactly sure about underlying test logic, but should it be values[9]?
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.
the test logic only validates the presence of the valueAccessor. it's part of test field. It's really difficult to compare functions and that's why we only validate the presence and the validity of the field, e.g not null.
I can definitely update to valueAccessor: values => values[9]
but it will not make a difference.
test/fixtures/test-csv-data.js
Outdated
analyzerType: 'FLOAT' | ||
fieldIdx: 5, | ||
analyzerType: 'FLOAT', | ||
valueAccessor: values => values[4] |
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.
values[5] ?
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.
same as above
// mergedEpochFilter | ||
// ]; | ||
// | ||
// cmpFilters(t, expectedFilters, mergedState.filters); |
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.
Do we need this commented out check?
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.
yea, we should test these merged filters
analyzerType: 'FLOAT', | ||
format: '' | ||
format: '', | ||
valueAccessor: values => values[1] |
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.
values[0]?
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.
same as the above
@@ -79,17 +74,16 @@ export class Layer { | |||
_oldDataUpdateTriggers: any; | |||
hasAllColumns(): boolean; | |||
updateLayerConfig(p: Partial<LayerConfig>): Layer; | |||
updateLayerDomain(datasets: Datasets, filter?: Filter): Layer; |
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.
why is this type def deleted? base-layer still has updateLayerDomain
method
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.
not sure why this was deleted but i will revert it back
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.
probably some rebase conflicts
same for
isLayerHovered(objectInfo: any): boolean;
hasHoveredObject(objectInfo: any): any | null;
getHoverData(object: any, allData?: Dataset['allData'], fields?: Dataset['fields']): any;
src/reducers/vis-state-updaters.js
Outdated
@@ -481,12 +482,12 @@ export function layerVisualChannelChangeUpdater(state, action) { | |||
if (!oldLayer.config.dataId) { | |||
return state; | |||
} | |||
const dataset = state.datasets[oldLayer.config.dataId]; | |||
const table = state.datasets[oldLayer.config.dataId]; |
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.
change this back to dataset
?
src/reducers/vis-state-updaters.js
Outdated
|
||
const idx = state.layers.findIndex(l => l.id === oldLayer.id); | ||
const newLayer = oldLayer.updateLayerConfig(newConfig); | ||
|
||
newLayer.updateLayerVisualChannel(dataset, channel); | ||
newLayer.updateLayerVisualChannel(table, channel); |
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.
same her
src/utils/filter-utils.js
Outdated
@@ -962,45 +909,42 @@ export function applyFiltersToDatasets(datasetIds, datasets, filters, layers) { | |||
export function applyFilterFieldName(filter, dataset, fieldName, filterDatasetIndex = 0, option) { | |||
// using filterDatasetIndex we can filter only the specified dataset | |||
const mergeDomain = option && option.hasOwnProperty('mergeDomain') ? option.mergeDomain : false; | |||
const {fields, allData} = dataset; | |||
// const {fields, allData} = dataset; |
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.
delete comment
src/utils/filter-utils.js
Outdated
field.hasOwnProperty('filterProps') && field.filterProps | ||
? field.filterProps | ||
: getFilterProps(allData, field); | ||
// const field = fields[fieldIndex]; |
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.
delete comment
src/utils/filter-utils.js
Outdated
}; | ||
|
||
const newFields = Object.assign([...fields], {[fieldIndex]: fieldWithFilterProps}); | ||
// const fieldWithFilterProps = { |
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.
delete comment
tableFieldIndex: 10, | ||
analyzerType: 'DATETIME' | ||
analyzerType: 'DATETIME', | ||
valueAccessor: values => values[9] |
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.
this doesn't seem to be right, ts valueAccessor should return epoch milisecond, are these really tested?
tableFieldIndex: 9, | ||
analyzerType: 'DATETIME' | ||
analyzerType: 'DATETIME', | ||
valueAccessor: values => values[8] |
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.
Same as above
}); | ||
} | ||
} else if (k === 'valueAccessor') { | ||
t.ok(typeof actual[k] === 'function', `${name}.valueAccessor should be a function`); |
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.
we should actually test valueAccessor
not that it's just a function
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.
got it. it's not easy to test equality (not memory address but value) among functions, how should we test it?
I was thinking about the following options:
- calling the function with some data and check that both function return the same value? this may have other implications, e.g. sometimes we only compare layers and we don't have the actual data.
- use toString on both functions and compare the output?
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.
ok i guess it's fine. the result of valueAccessor is indirectly tested in format layer data and filter.
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.
cool
// mergedEpochFilter | ||
// ]; | ||
// | ||
// cmpFilters(t, expectedFilters, mergedState.filters); |
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.
yea, we should test these merged filters
@@ -400,39 +400,6 @@ test('VisStateMerger.v1 -> mergeLayers -> toEmptyState', t => { | |||
t.end(); | |||
}); | |||
|
|||
test('VisStateMerger.v1 -> mergeLayers -> toEmptyState', t => { |
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.
this test deleted?
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.
oh yeah, this test was a duplicate of the one at line 370
src/utils/filter-utils.js
Outdated
const isTime = field.type === ALL_FIELD_TYPES.timestamp; | ||
const valueAccessor = maybeToDate.bind(null, isTime, fieldIdx, field.format); | ||
let domain; | ||
// export function getFieldDomain(allData, field) { |
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.
remove comment
Signed-off-by: Giuseppe Macri <macri.giuseppe@gmail.com>
a81f141
to
d20eff8
Compare