-
Notifications
You must be signed in to change notification settings - Fork 63
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
allow subfield access #141
Closed
bmschmidt
wants to merge
2
commits into
09-09-use_a_shared_object_with_multiple_length_keys_to_store_regl_buffers
from
09-07-allow_subfield_access
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import type { TextureSet } from './AestheticSet'; | ||
import { isConstantChannel } from '../typing'; | ||
import { Type, Vector } from 'apache-arrow'; | ||
import { Struct, Type, Vector } from 'apache-arrow'; | ||
import { StructRowProxy } from 'apache-arrow/row/struct'; | ||
import { isNumber } from 'lodash'; | ||
import type * as DS from '../types'; | ||
import { Scatterplot } from '../scatterplot'; | ||
import { Some } from '../utilityFunctions'; | ||
|
||
/** | ||
* An Aesthetic bundles all operations in mapping from user dataspace to webGL based aesthetics. | ||
|
@@ -26,6 +27,7 @@ export abstract class Aesthetic< | |
public abstract default_range: [Output['rangeType'], Output['rangeType']]; | ||
public scatterplot: Scatterplot; | ||
public field: string | null = null; | ||
public subfield: string[] = []; | ||
public _texture_buffer: Float32Array | Uint8Array | null = null; | ||
protected abstract _func?: (d: Input['domainType']) => Output['rangeType']; | ||
public aesthetic_map: TextureSet; | ||
|
@@ -76,9 +78,25 @@ export abstract class Aesthetic< | |
this.field = null; | ||
} else { | ||
this.field = encoding.field; | ||
if (encoding.subfield) { | ||
this.subfield = Array.isArray(encoding.subfield) | ||
? encoding.subfield | ||
: [encoding.subfield]; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Returns the keys that are used to access the data in the record batch, | ||
* including with any nesting. | ||
*/ | ||
get columnKeys(): null | Some<string> { | ||
if (this.field === null) { | ||
return null; | ||
} | ||
return [this.field, ...this.subfield] as Some<string>; | ||
} | ||
|
||
get deeptable() { | ||
return this.scatterplot.deeptable; | ||
} | ||
|
@@ -100,10 +118,14 @@ export abstract class Aesthetic< | |
|
||
value_for(point: Datum): Input['domainType'] | null { | ||
if (this.field && point[this.field]) { | ||
return point[this.field] as Input['domainType']; | ||
let v = point[this.field] as Input['domainType']; | ||
for (let i = 0; i < this.subfield.length; i++) { | ||
v = v[this.subfield[i]] as Input['domainType']; | ||
} | ||
return v; | ||
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. Redundant return statement. Remove the line after |
||
// Needs a default perhaps? | ||
return null; | ||
} | ||
bmschmidt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Needs a default perhaps? | ||
return null; | ||
} | ||
|
||
get map_position() { | ||
|
@@ -136,9 +158,17 @@ export abstract class Aesthetic< | |
if (this.field === null || this.field === undefined) { | ||
return (this.column = null); | ||
} | ||
return (this.column = this.deeptable.root_tile.record_batch.getChild( | ||
this.field, | ||
) as Vector<Input['arrowType']>); | ||
let output: Vector<Input['arrowType']> | Vector<Struct> | null = null; | ||
for (const f of [this.field, ...this.subfield]) { | ||
if (output === null) { | ||
output = this.deeptable.root_tile.record_batch.getChild(f) as Vector< | ||
Input['arrowType'] | ||
>; | ||
} else { | ||
output = (output as Vector<Struct>).getChild(f) as Vector<Struct>; | ||
} | ||
} | ||
return (this.column = output as Vector<Input['arrowType']>); | ||
} | ||
|
||
is_dictionary(): boolean { | ||
|
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
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.
Unreachable code after
return v;
invalue_for
method. Remove the redundantreturn null;
statement.