listener = {
if (searchterm == "") {
return;
}
await scatterplot.ready;
scatterplot._root.transformations[searchterm] = async function (tile) {
const encoded = encode_string(searchterm);
const key = tile.key;
await tile.promise;
const data = tile.record_batch.getChild("title").data[0];
let match_start = 0;
let match_length = 0;
let target_length = encoded.findIndex((d) => d === 0);
const matches = [];
for (let i = 0; i < data.values.length; i++) {
if (data.values[i] === encoded[match_length]) {
match_length += 1;
if (match_length === 1) {
match_start = i;
}
if (match_length === target_length) {
matches.push(match_start);
match_length = 0;
}
} else {
if (match_length > 0) {
match_length = 0;
}
}
}
const output = new Float32Array(tile.record_batch.numRows);
let offsets_index = 0;
while (matches.length > 0) {
const searching = matches.shift();
while (data.valueOffsets[offsets_index + 1] < searching) {
offsets_index += 1;
}
output[offsets_index] = 1;
}
return output;
};
}