@uwdata/mosaic-core 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mosaic-core.js +96 -39
- package/dist/mosaic-core.min.js +5 -5
- package/package.json +3 -3
- package/src/DataCubeIndexer.js +10 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uwdata/mosaic-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Scalable and extensible linked data views.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mosaic",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@duckdb/duckdb-wasm": "^1.28.1-dev106.0",
|
|
32
|
-
"@uwdata/mosaic-sql": "^0.
|
|
32
|
+
"@uwdata/mosaic-sql": "^0.6.0",
|
|
33
33
|
"apache-arrow": "^14.0.1"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "51517b28e916e355f4ce0dc6e98aef3a1db3f7b2"
|
|
36
36
|
}
|
package/src/DataCubeIndexer.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { Query, and,
|
|
1
|
+
import { Query, and, create, isBetween, scaleTransform, sql } from '@uwdata/mosaic-sql';
|
|
2
2
|
import { fnv_hash } from './util/hash.js';
|
|
3
3
|
|
|
4
|
-
const identity = x => x;
|
|
5
|
-
|
|
6
4
|
/**
|
|
7
5
|
* Build and query optimized indices ("data cubes") for fast computation of
|
|
8
6
|
* groupby aggregate queries over compatible client queries and selections.
|
|
@@ -149,7 +147,7 @@ function getActiveView(clause) {
|
|
|
149
147
|
);
|
|
150
148
|
}
|
|
151
149
|
} else if (type === 'point') {
|
|
152
|
-
predicate =
|
|
150
|
+
predicate = x => x;
|
|
153
151
|
columns = Object.fromEntries(columns.map(col => [col.toString(), col]));
|
|
154
152
|
} else {
|
|
155
153
|
return null; // unsupported type
|
|
@@ -159,42 +157,15 @@ function getActiveView(clause) {
|
|
|
159
157
|
}
|
|
160
158
|
|
|
161
159
|
function binInterval(scale, pixelSize) {
|
|
162
|
-
const {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
case 'log':
|
|
171
|
-
lift = Math.log;
|
|
172
|
-
toSql = c => sql`LN(${asColumn(c)})`;
|
|
173
|
-
break;
|
|
174
|
-
case 'symlog':
|
|
175
|
-
// TODO: support log constants other than 1?
|
|
176
|
-
lift = x => Math.sign(x) * Math.log1p(Math.abs(x));
|
|
177
|
-
toSql = c => (c = asColumn(c), sql`SIGN(${c}) * LN(1 + ABS(${c}))`);
|
|
178
|
-
break;
|
|
179
|
-
case 'sqrt':
|
|
180
|
-
lift = Math.sqrt;
|
|
181
|
-
toSql = c => sql`SQRT(${asColumn(c)})`;
|
|
182
|
-
break;
|
|
183
|
-
case 'utc':
|
|
184
|
-
case 'time':
|
|
185
|
-
lift = x => +x;
|
|
186
|
-
toSql = c => c instanceof Date ? +c : epoch_ms(asColumn(c));
|
|
187
|
-
break;
|
|
160
|
+
const { apply, sqlApply } = scaleTransform(scale);
|
|
161
|
+
if (apply) {
|
|
162
|
+
const { domain, range } = scale;
|
|
163
|
+
const lo = apply(Math.min(...domain));
|
|
164
|
+
const hi = apply(Math.max(...domain));
|
|
165
|
+
const a = (Math.abs(range[1] - range[0]) / (hi - lo)) / pixelSize;
|
|
166
|
+
const s = pixelSize === 1 ? '' : `${pixelSize}::INTEGER * `;
|
|
167
|
+
return value => sql`${s}FLOOR(${a}::DOUBLE * (${sqlApply(value)} - ${lo}::DOUBLE))::INTEGER`;
|
|
188
168
|
}
|
|
189
|
-
return lift ? binFunction(domain, range, pixelSize, lift, toSql) : null;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function binFunction(domain, range, pixelSize, lift, toSql) {
|
|
193
|
-
const lo = lift(Math.min(domain[0], domain[1]));
|
|
194
|
-
const hi = lift(Math.max(domain[0], domain[1]));
|
|
195
|
-
const a = (Math.abs(lift(range[1]) - lift(range[0])) / (hi - lo)) / pixelSize;
|
|
196
|
-
const s = pixelSize === 1 ? '' : `${pixelSize}::INTEGER * `;
|
|
197
|
-
return value => sql`${s}FLOOR(${a}::DOUBLE * (${toSql(value)} - ${lo}::DOUBLE))::INTEGER`;
|
|
198
169
|
}
|
|
199
170
|
|
|
200
171
|
const NO_INDEX = { from: NaN };
|