Skip to content

Commit

Permalink
rename dataset to deeptable
Browse files Browse the repository at this point in the history
  • Loading branch information
bmschmidt committed May 15, 2024
1 parent e5fc4ab commit e76e2f3
Show file tree
Hide file tree
Showing 15 changed files with 163 additions and 168 deletions.
17 changes: 8 additions & 9 deletions src/Dataset.ts → src/Deeptable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// A Dataset manages the production and manipulation of *tiles*.
import { Tile, Rectangle, p_in_rect } from './tile';
import { max, bisectLeft, extent } from 'd3-array';
import type * as DS from './shared';
Expand Down Expand Up @@ -62,11 +61,11 @@ const defaultTransformations: Record<string, Transformation> = {
};

/**
* A Dataset manages the production and manipulation of tiles. Each plot has a
* single dataset; the dataset handles all transformations around data through
* A Deeptable manages the production and manipulation of tiles. Each plot has a
* single deeptable; the deeptable handles all transformations around data through
* batchwise operations.
*/
export class Dataset {
export class Deeptable {
public transformations: Record<string, Transformation> =
defaultTransformations;
public _plot: Scatterplot | null;
Expand Down Expand Up @@ -113,7 +112,7 @@ export class Dataset {
// optional with non-undefined defaults.
rootKey = '0/0/0',
tileStructure = 'quadtree',
}: DS.DatasetCreateParams) {
}: DS.DeeptableCreateParams) {
this._plot = plot;
this.tileProxy = tileProxy;
this.tileStucture = tileStructure;
Expand Down Expand Up @@ -274,12 +273,12 @@ export class Dataset {
);
}

static from_quadfeather(url: string, plot: Scatterplot | null): Dataset {
const options: Partial<DS.DatasetCreateParams> = {};
static from_quadfeather(url: string, plot: Scatterplot | null): Deeptable {
const options: Partial<DS.DeeptableCreateParams> = {};
if (plot.tileProxy) {
options['tileProxy'] = plot.tileProxy;
}
return new Dataset({
return new Deeptable({
tileProxy: plot.tileProxy ? plot.tileProxy : undefined,
baseUrl: url,
rootKey: '0/0/0',
Expand All @@ -295,7 +294,7 @@ export class Dataset {
* @param plot The Scatterplot to use.
* @returns
*/
static fromArrowTable(table: Table, plot: Scatterplot): Dataset {
static fromArrowTable(table: Table, plot: Scatterplot): Deeptable {
return wrapArrowTable(tableToIPC(table), plot);
}

Expand Down
6 changes: 3 additions & 3 deletions src/aesthetics/Aesthetic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export abstract class Aesthetic<
}
}

get dataset() {
return this.scatterplot.dataset;
get deeptable() {
return this.scatterplot.deeptable;
}

abstract apply(point: Datum): Output['rangeType'];
Expand Down Expand Up @@ -136,7 +136,7 @@ export abstract class Aesthetic<
if (this.field === null || this.field === undefined) {
return (this.column = null);
}
return (this.column = this.dataset.root_tile.record_batch.getChild(
return (this.column = this.deeptable.root_tile.record_batch.getChild(
this.field,
) as Vector<Input['arrowType']>);
}
Expand Down
6 changes: 3 additions & 3 deletions src/aesthetics/AestheticSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { Regl, Texture2D } from 'regl';
import { dimensions } from './StatefulAesthetic';
import type { Scatterplot } from '../scatterplot';
import type { Dataset } from '../Dataset';
import type { Deeptable } from '../Deeptable';
import { StatefulAesthetic } from './StatefulAesthetic';
import type { Encoding } from '../shared';
import type * as DS from '../shared';
Expand All @@ -19,7 +19,7 @@ type StateList<T> = {
};

export class AestheticSet {
public tileSet: Dataset;
public tileSet: Deeptable;
public scatterplot: Scatterplot;
public regl: Regl;
public encoding: Encoding = {};
Expand All @@ -31,7 +31,7 @@ export class AestheticSet {
} = {
jitter_method: { current: 'None', last: 'None' },
};
constructor(scatterplot: Scatterplot, regl: Regl, tileSet: Dataset) {
constructor(scatterplot: Scatterplot, regl: Regl, tileSet: Deeptable) {
this.scatterplot = scatterplot;
this.regl = regl;
this.tileSet = tileSet;
Expand Down
14 changes: 9 additions & 5 deletions src/aesthetics/ScaledAesthetic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export abstract class ScaledAesthetic<

const bands = scaleBand()
.domain(vals)
.range(this.dataset.extent.x)
.range(this.deeptable.extent.x)
.padding(0.1)
.round(true)
.align(0.5);
Expand Down Expand Up @@ -230,7 +230,7 @@ export abstract class ScaledAesthetic<
return [1, 1];
}

const domain = this.dataset.domain(this.field);
const domain = this.deeptable.domain(this.field);
return domain;
}

Expand All @@ -250,7 +250,7 @@ export abstract class ScaledAesthetic<
Input['domainType'],
];
} else {
return this.scatterplot.dataset.domain(this.field);
return this.scatterplot.deeptable.domain(this.field);
}
}

Expand Down Expand Up @@ -322,8 +322,12 @@ export abstract class PositionalAesthetic<
return this.default_range;
}
get default_range(): [number, number] {
if (this.dataset.extent && this.axis && this.dataset.extent[this.axis]) {
return this.dataset.extent[this.axis];
if (
this.deeptable.extent &&
this.axis &&
this.deeptable.extent[this.axis]
) {
return this.deeptable.extent[this.axis];
}
return [-1, 1];
}
Expand Down
8 changes: 4 additions & 4 deletions src/aesthetics/StatefulAesthetic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export type ConcreteScaledAesthetic =
| Jitter_radius
| Color;

import type { Dataset } from '../Dataset';
import type { Deeptable } from '../Deeptable';
import type { Regl } from 'regl';
import type { TextureSet } from './AestheticSet';

Expand All @@ -67,7 +67,7 @@ export class StatefulAesthetic<T extends ConcreteAesthetic> {
* channel in a scatterplot has exactly on StatefulAesthetic that persists for the lifetime of the Plot.
*/
public states: [T, T];
public dataset: Dataset;
public deeptable: Deeptable;
public regl: Regl;
public scatterplot: Scatterplot;
public needs_transitions = false;
Expand All @@ -78,7 +78,7 @@ export class StatefulAesthetic<T extends ConcreteAesthetic> {
constructor(
scatterplot: Scatterplot,
regl: Regl,
dataset: Dataset,
deeptable: Deeptable,
aesthetic_map: TextureSet,
Factory: DS.Newable<T>,
) {
Expand All @@ -87,7 +87,7 @@ export class StatefulAesthetic<T extends ConcreteAesthetic> {
}
this.scatterplot = scatterplot;
this.regl = regl;
this.dataset = dataset;
this.deeptable = deeptable;
this.aesthetic_map = aesthetic_map;
this.factory = Factory;
this.ids = [Math.random().toString(), Math.random().toString()];
Expand Down
2 changes: 1 addition & 1 deletion src/deepscatter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { Scatterplot } from './scatterplot';
export { Bitmask, DataSelection } from './selection';
export { Dataset } from './Dataset';
export { Deeptable } from './Deeptable';
export { LabelMaker } from './label_rendering';
export { dictionaryFromArrays } from './utilityFunctions';
24 changes: 12 additions & 12 deletions src/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { Renderer } from './rendering';
import { ReglRenderer } from './regl_rendering';
import { StructRowProxy } from 'apache-arrow';
import { Rectangle } from './tile';
import type { Dataset } from './Dataset';
import type { Deeptable } from './Deeptable';
import type * as DS from './shared';
import type { Scatterplot } from './scatterplot';
import { PositionalAesthetic } from './aesthetics/ScaledAesthetic';
Expand All @@ -34,7 +34,7 @@ export class Zoom {
public width: number;
public height: number;
public renderers: Map<string, Renderer>;
public tileSet?: Dataset;
public deeptable?: Deeptable;
public _timer?: d3.Timer;
public _scales?: Record<string, d3.ScaleLinear<number, number>>;
public zoomer?: d3.ZoomBehavior<Element, unknown>;
Expand All @@ -60,8 +60,8 @@ export class Zoom {
this.renderers = new Map();
}

attach_tiles(tiles: Dataset) {
this.tileSet = tiles;
attach_tiles(tiles: Deeptable) {
this.deeptable = tiles;
return this;
}

Expand Down Expand Up @@ -278,14 +278,14 @@ export class Zoom {
return this._timer;
}

data(dataset: undefined): Dataset;
data(dataset: Dataset): Zoom;
data(deeptable: undefined): Deeptable;
data(deeptable: Deeptable): Zoom;

data(dataset: Dataset | undefined) {
if (dataset === undefined) {
return this.tileSet;
data(deeptable: Deeptable | undefined) {
if (deeptable === undefined) {
return this.deeptable;
}
this.tileSet = dataset;
this.deeptable = deeptable;
return this as Zoom;
}

Expand All @@ -305,10 +305,10 @@ export class Zoom {
}

const { width, height } = this;
if (this.tileSet === undefined) {
if (this.deeptable === undefined) {
throw new Error('Error--scales created before tileSet present.');
}
const { extent } = this.tileSet;
const { extent } = this.deeptable;
const scales: Record<string, ScaleLinear<number, number>> = {};
if (extent === undefined) {
throw new Error('Error--scales created before extent present.');
Expand Down
2 changes: 1 addition & 1 deletion src/label_rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class LabelMaker extends Renderer {
) {
super(
scatterplot.div!.node() as HTMLDivElement,
scatterplot.dataset,
scatterplot.deeptable,
scatterplot,
);
this.options = options;
Expand Down
28 changes: 14 additions & 14 deletions src/regl_rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { rgb } from 'd3-color';
import type * as DS from './shared';
import type { Tile } from './tile';
import REGL from 'regl';
import { Dataset } from './Dataset';
import { Deeptable } from './Deeptable';
import {
ConcreteScaledAesthetic,
dimensions,
Expand Down Expand Up @@ -52,7 +52,7 @@ export class ReglRenderer extends Renderer {
public buffer_size = 1024 * 1024 * 64; // Use GPU memory in blocks of 64 MB buffers by default.
private _buffers: MultipurposeBufferSet;
public _initializations: Promise<void>;
public dataset: Dataset;
public deeptable: Deeptable;
public _zoom?: Zoom;
public most_recent_restart?: number;
public _default_webgl_scale?: number[];
Expand All @@ -72,7 +72,7 @@ export class ReglRenderer extends Renderer {

constructor(
selector: string | Node,
tileSet: Dataset,
tileSet: Deeptable,
scatterplot: Scatterplot,
) {
super(selector, tileSet, scatterplot);
Expand All @@ -91,7 +91,7 @@ export class ReglRenderer extends Renderer {
],
canvas: c,
});
this.dataset = tileSet;
this.deeptable = tileSet;

this.aes = new AestheticSet(scatterplot, this.regl, tileSet);

Expand All @@ -101,7 +101,7 @@ export class ReglRenderer extends Renderer {
// Not the right way, for sure.
this._initializations = Promise.all([
// some things that need to be initialized before the renderer is loaded.
this.dataset.promise.then(() => {
this.deeptable.promise.then(() => {
this.remake_renderer();
this._webgl_scale_history = [
this.default_webgl_scale,
Expand All @@ -119,12 +119,12 @@ export class ReglRenderer extends Renderer {
return this._buffers;
}

data(dataset: Dataset) {
if (dataset === undefined) {
data(deeptable: Deeptable) {
if (deeptable === undefined) {
// throw
return this.dataset;
return this.deeptable;
}
this.dataset = dataset;
this.deeptable = deeptable;
return this;
}

Expand Down Expand Up @@ -261,12 +261,12 @@ export class ReglRenderer extends Renderer {
* Actions that run on a single animation tick.
*/
tick() {
const { prefs, dataset, props } = this;
const { prefs, deeptable, props } = this;
this.tick_num = this.tick_num || 0;
this.tick_num++;
// Set a download call in motion.
if (this._use_scale_to_download_tiles) {
dataset.spawnDownloads(
deeptable.spawnDownloads(
this.zoom.current_corners(),
this.props.max_ix,
5,
Expand All @@ -275,7 +275,7 @@ export class ReglRenderer extends Renderer {
);
} else {
// console.warn("No good rules here yet.")
dataset.spawnDownloads(
deeptable.spawnDownloads(
undefined,
prefs.max_points,
5,
Expand Down Expand Up @@ -1139,14 +1139,14 @@ export class TileBufferManager {
type ColumnType = Vector<Dictionary<Utf8> | Float | Bool | Int | Timestamp>;

if (!tile.hasLoadedColumn(key)) {
if (tile.dataset.transformations[key] !== undefined) {
if (tile.deeptable.transformations[key] !== undefined) {
throw new Error(
'Attempted to create buffer data on an unloaded transformation',
);
} else {
let col_names = [
...tile.record_batch.schema.fields.map((d) => d.name),
...Object.keys(tile.dataset.transformations),
...Object.keys(tile.deeptable.transformations),
];
if (!key.startsWith('_')) {
// Don't warn internal columns unless the user is in internal-column land.
Expand Down
Loading

0 comments on commit e76e2f3

Please sign in to comment.