-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows using struct columns in Arrow through an optional 'subfield' column. 'field' remains the unit of laziness, but now nested columns can hold multiple data, which is useful for expensive transformations that return data about multiple numbers (especially x and y at once, like geoprojections.) I've included a test in SwitchPositions.svelte that demonstrates working. <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Add subfield access for struct columns in Arrow, enhancing nested data handling in Deepscatter with updates across behavior, aesthetics, rendering, and types. > > - **Behavior**: > - Allow subfield access in struct columns in Arrow using an optional `subfield` parameter. > - Demonstrated with a test in `SwitchPositions.svelte`. > - **Deeptable**: > - Updated `get_column()` to support subfields in `Deeptable.ts`. > - Modified `domain()` to handle subfields for extent calculations. > - **Aesthetics**: > - Added `subfield` handling in `Aesthetic.ts` and `AestheticSet.ts`. > - Updated `StatefulAesthetic` to track needed fields with subfields. > - **Rendering**: > - Adjusted buffer management in `regl_rendering.ts` to accommodate subfields. > - Updated `BufferManager` to handle nested vectors with subfields. > - **Types**: > - Extended `ChannelType` and related types to include `subfield` property in `types.ts`. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=nomic-ai%2Fdeepscatter&utm_source=github&utm_medium=referral)<sup> for 181fa0a. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
- Loading branch information
Showing
13 changed files
with
346 additions
and
149 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,88 @@ | ||
<script> | ||
import { | ||
makeData, | ||
Float32, | ||
Vector, | ||
vectorFromArray, | ||
Struct, | ||
makeVector, | ||
Field, | ||
} from 'apache-arrow'; | ||
export let scatterplot; | ||
let positionNum = 0; | ||
async function click() { | ||
console.log(scatterplot.prefs.encoding.x) | ||
for (let i = 0; i < 10; i++) { | ||
if (scatterplot.deeptable.transformations['struct' + i]) { | ||
continue; | ||
} | ||
scatterplot.deeptable.transformations['struct' + i] = async function ( | ||
tile, | ||
) { | ||
// Create a nested struct with a change. | ||
const x = (await tile.get_column('x')).toArray(); | ||
const y = (await tile.get_column('y')).toArray(); | ||
const x_ = new Float32Array(x.length); | ||
const y_ = new Float32Array(y.length); | ||
for (let i = 0; i < x.length; i++) { | ||
const r = (Math.random() + Math.random()) / 3; | ||
const theta = Math.random() * Math.PI * 2; | ||
x_[i] = x[i] + Math.cos(theta) * r; | ||
y_[i] = y[i] + Math.sin(theta) * r; | ||
} | ||
const d = makeData({ | ||
type: new Struct([ | ||
new Field('x', new Float32()), | ||
new Field('y', new Float32()), | ||
]), | ||
children: [vectorFromArray(x_).data[0], vectorFromArray(y_).data[0]], | ||
}); | ||
const r = new Vector([d]); | ||
return r; | ||
}; | ||
scatterplot.deeptable.map((d) => d.get_column('struct' + i)); | ||
} | ||
await new Promise((resolve) => { | ||
setTimeout(() => resolve()); | ||
}, 100); | ||
let r = 'struct' + (positionNum++ % 10); | ||
await scatterplot.plotAPI({ | ||
duration: 1000, | ||
encoding: { | ||
x: { | ||
field: scatterplot.prefs.encoding.x.field === 'x' ? 'y' : 'x', | ||
transform: scatterplot.prefs.encoding.x.field === 'x' ? 'linear': 'literal' | ||
field: r, | ||
subfield: ['x'], | ||
transform: 'literal', | ||
domain: [-10, 10], | ||
}, | ||
y: { | ||
field: scatterplot.prefs.encoding.y.field === 'y' ? 'x' : 'y', | ||
transform: scatterplot.prefs.encoding.y.field === 'y' ? 'linear': 'literal' | ||
} | ||
} | ||
}) | ||
field: r, | ||
subfield: ['y'], | ||
transform: 'literal', | ||
domain: [-10, 10], | ||
}, | ||
}, | ||
}); | ||
// await scatterplot.plotAPI({ | ||
// encoding: { | ||
// x: { | ||
// field: scatterplot.prefs.encoding.x.field === 'x' ? 'y' : 'x', | ||
// transform: | ||
// scatterplot.prefs.encoding.x.field === 'x' ? 'linear' : 'literal', | ||
// }, | ||
// y: { | ||
// field: scatterplot.prefs.encoding.y.field === 'y' ? 'x' : 'y', | ||
// transform: | ||
// scatterplot.prefs.encoding.y.field === 'y' ? 'linear' : 'literal', | ||
// }, | ||
// }, | ||
// }); | ||
} | ||
</script> | ||
|
||
<button on:click={click}> | ||
Switch positions | ||
</button> | ||
<button on:click={click}> Switch positions </button> |
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
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
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.