Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Sep 4, 2024
1 parent 74a3796 commit 2adb243
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/api-reference/aggregation-layers/aggregation-layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Any layer subclassing the `AggregationLayer` must implement the following method

#### `getAggregatorType` {#getaggregatortype}

Returns a string that indicates the type of aggregator that this layer uses, for example `'gpu'`. This method is invoked with each `updateState` lifecycle. If the type string does not match its previous value, the existing aggregator will be disposed and recreated.
Returns a string that indicates the type of aggregator that this layer uses, for example `'gpu'`. The aggregator type is re-evaluated every time the layer updates (usually due to props or state change). If the type string does not match its previous value, any existing aggregator will be disposed,and `createAggregator` is called to create a new instance.

#### `createAggregator` {#createaggregator}

Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/aggregation-layers/aggregator.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ aggregator.setProps({

Arguments:
- `pointCount` (number) - number of data points.
- `attributes` ([attributes](../core/layer.md#dataattributes)) - the input data in binary format.
- `attributes` ([Attribute](../core/attribute.md)[]) - the input data.
- `operations` (string[]) - How to aggregate the values inside a bin, defined per channel.
- `binOptions` (object) - arbitrary settings that affect bin sorting.
- `onUpdate` (Function) - callback when a channel has been recalculated. Receives the following arguments:
Expand Down
9 changes: 6 additions & 3 deletions docs/api-reference/aggregation-layers/cpu-aggregator.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ const aggregator = new CPUAggregator({
]
});

const position = new Attribute(device, {id: 'position', size: 1});
position.setData({value: new Float32Array(...)});
const weight = new Attribute(device, {id: 'weight', size: 1});
position.setData({value: new Float32Array(...)});

aggregator.setProps({
pointCount: data.length,
operations: ['SUM'],
binOptions: {
binSize: 1
},
attributes: {
// Generated by AttributeManager.getAttributes()
}
attributes: {position, weight}
});

aggregator.update();
Expand Down
12 changes: 8 additions & 4 deletions docs/api-reference/aggregation-layers/webgl-aggregator.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const aggregator = new WebGLAggregator(device, {
dimensions: 1,
channelCount: 1,
bufferLayout: [
// Generated by AttributeManager.getBufferLayout()
{name: 'position', format: 'float32'},
{name: 'weight', format: 'float32'}
],
vs: `
uniform float binSize;
Expand All @@ -27,16 +28,19 @@ const aggregator = new WebGLAggregator(device, {
}`
});

const position = new Attribute(device, {id: 'position', size: 1});
position.setData({value: new Float32Array(...)});
const weight = new Attribute(device, {id: 'weight', size: 1});
position.setData({value: new Float32Array(...)});

aggregator.setProps({
pointCount: data.length,
binIdRange: [0, 100],
operations: ['SUM'],
binOptions: {
binSize: 1
},
attributes: {
// Generated by AttributeManager.getAttributes()
}
attributes: {position, weight}
});

aggregator.update();
Expand Down

0 comments on commit 2adb243

Please sign in to comment.