@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/dist/mosaic-core.js
CHANGED
|
@@ -12302,8 +12302,7 @@ var arrayAgg = aggf("ARRAY_AGG");
|
|
|
12302
12302
|
|
|
12303
12303
|
// ../sql/src/datetime.js
|
|
12304
12304
|
var epoch_ms = (expr) => {
|
|
12305
|
-
|
|
12306
|
-
return sql`(1000 * (epoch(${d}) - second(${d})) + millisecond(${d}))::DOUBLE`;
|
|
12305
|
+
return sql`epoch_ms(${asColumn(expr)})`;
|
|
12307
12306
|
};
|
|
12308
12307
|
|
|
12309
12308
|
// ../sql/src/spatial.js
|
|
@@ -12710,6 +12709,89 @@ function isDoubleQuoted(s) {
|
|
|
12710
12709
|
return s[0] === '"' && s[s.length - 1] === '"';
|
|
12711
12710
|
}
|
|
12712
12711
|
|
|
12712
|
+
// ../sql/src/scales.js
|
|
12713
|
+
var identity = (x3) => x3;
|
|
12714
|
+
function scaleLinear() {
|
|
12715
|
+
return {
|
|
12716
|
+
apply: identity,
|
|
12717
|
+
invert: identity,
|
|
12718
|
+
sqlApply: asColumn,
|
|
12719
|
+
sqlInvert: identity
|
|
12720
|
+
};
|
|
12721
|
+
}
|
|
12722
|
+
function scaleLog({ base } = {}) {
|
|
12723
|
+
if (base == null || base === Math.E) {
|
|
12724
|
+
return {
|
|
12725
|
+
apply: Math.log,
|
|
12726
|
+
invert: Math.exp,
|
|
12727
|
+
sqlApply: (c) => sql`LN(${asColumn(c)})`,
|
|
12728
|
+
sqlInvert: (c) => sql`EXP(${c})`
|
|
12729
|
+
};
|
|
12730
|
+
} else if (base === 10) {
|
|
12731
|
+
return {
|
|
12732
|
+
apply: Math.log10,
|
|
12733
|
+
invert: (x3) => Math.pow(10, x3),
|
|
12734
|
+
sqlApply: (c) => sql`LOG(${asColumn(c)})`,
|
|
12735
|
+
sqlInvert: (c) => sql`POW(10, ${c})`
|
|
12736
|
+
};
|
|
12737
|
+
} else {
|
|
12738
|
+
const b2 = +base;
|
|
12739
|
+
return {
|
|
12740
|
+
apply: (x3) => Math.log(x3) / Math.log(b2),
|
|
12741
|
+
invert: (x3) => Math.pow(b2, x3),
|
|
12742
|
+
sqlApply: (c) => sql`LN(${asColumn(c)}) / LN(${b2})`,
|
|
12743
|
+
sqlInvert: (c) => sql`POW(${b2}, ${c})`
|
|
12744
|
+
};
|
|
12745
|
+
}
|
|
12746
|
+
}
|
|
12747
|
+
function scaleSymlog({ constant = 1 } = {}) {
|
|
12748
|
+
const _2 = +constant;
|
|
12749
|
+
return {
|
|
12750
|
+
apply: (x3) => Math.sign(x3) * Math.log1p(Math.abs(x3)),
|
|
12751
|
+
invert: (x3) => Math.sign(x3) * Math.exp(Math.abs(x3) - _2),
|
|
12752
|
+
sqlApply: (c) => (c = asColumn(c), sql`SIGN(${c}) * LN(${_2} + ABS(${c}))`),
|
|
12753
|
+
sqlInvert: (c) => sql`SIGN(${c}) * (EXP(ABS(${c})) - ${_2})`
|
|
12754
|
+
};
|
|
12755
|
+
}
|
|
12756
|
+
function scaleSqrt() {
|
|
12757
|
+
return {
|
|
12758
|
+
apply: (x3) => Math.sign(x3) * Math.sqrt(Math.abs(x3)),
|
|
12759
|
+
invert: (x3) => Math.sign(x3) * x3 * x3,
|
|
12760
|
+
sqlApply: (c) => (c = asColumn(c), sql`SIGN(${c}) * SQRT(ABS(${c}))`),
|
|
12761
|
+
sqlInvert: (c) => sql`SIGN(${c}) * (${c}) ** 2`
|
|
12762
|
+
};
|
|
12763
|
+
}
|
|
12764
|
+
function scalePow({ exponent = 1 } = {}) {
|
|
12765
|
+
const e = +exponent;
|
|
12766
|
+
return {
|
|
12767
|
+
apply: (x3) => Math.sign(x3) * Math.pow(Math.abs(x3), e),
|
|
12768
|
+
invert: (x3) => Math.sign(x3) * Math.pow(Math.abs(x3), 1 / e),
|
|
12769
|
+
sqlApply: (c) => (c = asColumn(c), sql`SIGN(${c}) * POW(ABS(${c}), ${e})`),
|
|
12770
|
+
sqlInvert: (c) => sql`SIGN(${c}) * POW(ABS(${c}), 1/${e})`
|
|
12771
|
+
};
|
|
12772
|
+
}
|
|
12773
|
+
function scaleTime() {
|
|
12774
|
+
return {
|
|
12775
|
+
apply: (x3) => +x3,
|
|
12776
|
+
invert: (x3) => new Date(x3),
|
|
12777
|
+
sqlApply: (c) => c instanceof Date ? +c : epoch_ms(asColumn(c)),
|
|
12778
|
+
sqlInvert: identity
|
|
12779
|
+
};
|
|
12780
|
+
}
|
|
12781
|
+
var scales = {
|
|
12782
|
+
linear: scaleLinear,
|
|
12783
|
+
log: scaleLog,
|
|
12784
|
+
symlog: scaleSymlog,
|
|
12785
|
+
sqrt: scaleSqrt,
|
|
12786
|
+
pow: scalePow,
|
|
12787
|
+
time: scaleTime,
|
|
12788
|
+
utc: scaleTime
|
|
12789
|
+
};
|
|
12790
|
+
function scaleTransform(options) {
|
|
12791
|
+
const scale = scales[options.type];
|
|
12792
|
+
return scale ? { ...options, ...scale(options) } : null;
|
|
12793
|
+
}
|
|
12794
|
+
|
|
12713
12795
|
// ../sql/src/load/create.js
|
|
12714
12796
|
function create(name, query, {
|
|
12715
12797
|
replace = false,
|
|
@@ -12869,7 +12951,6 @@ function fnv_mix(a2) {
|
|
|
12869
12951
|
}
|
|
12870
12952
|
|
|
12871
12953
|
// src/DataCubeIndexer.js
|
|
12872
|
-
var identity = (x3) => x3;
|
|
12873
12954
|
var DataCubeIndexer = class {
|
|
12874
12955
|
/**
|
|
12875
12956
|
*
|
|
@@ -12962,10 +13043,10 @@ function getActiveView(clause) {
|
|
|
12962
13043
|
let columns = clause.predicate?.columns;
|
|
12963
13044
|
if (!schema || !columns)
|
|
12964
13045
|
return null;
|
|
12965
|
-
const { type, scales, pixelSize = 1 } = schema;
|
|
13046
|
+
const { type, scales: scales2, pixelSize = 1 } = schema;
|
|
12966
13047
|
let predicate;
|
|
12967
|
-
if (type === "interval" &&
|
|
12968
|
-
const bins =
|
|
13048
|
+
if (type === "interval" && scales2) {
|
|
13049
|
+
const bins = scales2.map((s) => binInterval(s, pixelSize));
|
|
12969
13050
|
if (bins.some((b2) => b2 == null))
|
|
12970
13051
|
return null;
|
|
12971
13052
|
if (bins.length === 1) {
|
|
@@ -12978,7 +13059,7 @@ function getActiveView(clause) {
|
|
|
12978
13059
|
);
|
|
12979
13060
|
}
|
|
12980
13061
|
} else if (type === "point") {
|
|
12981
|
-
predicate =
|
|
13062
|
+
predicate = (x3) => x3;
|
|
12982
13063
|
columns = Object.fromEntries(columns.map((col) => [col.toString(), col]));
|
|
12983
13064
|
} else {
|
|
12984
13065
|
return null;
|
|
@@ -12986,39 +13067,15 @@ function getActiveView(clause) {
|
|
|
12986
13067
|
return { source, columns, predicate };
|
|
12987
13068
|
}
|
|
12988
13069
|
function binInterval(scale, pixelSize) {
|
|
12989
|
-
const {
|
|
12990
|
-
|
|
12991
|
-
|
|
12992
|
-
|
|
12993
|
-
|
|
12994
|
-
|
|
12995
|
-
|
|
12996
|
-
|
|
12997
|
-
lift = Math.log;
|
|
12998
|
-
toSql = (c) => sql`LN(${asColumn(c)})`;
|
|
12999
|
-
break;
|
|
13000
|
-
case "symlog":
|
|
13001
|
-
lift = (x3) => Math.sign(x3) * Math.log1p(Math.abs(x3));
|
|
13002
|
-
toSql = (c) => (c = asColumn(c), sql`SIGN(${c}) * LN(1 + ABS(${c}))`);
|
|
13003
|
-
break;
|
|
13004
|
-
case "sqrt":
|
|
13005
|
-
lift = Math.sqrt;
|
|
13006
|
-
toSql = (c) => sql`SQRT(${asColumn(c)})`;
|
|
13007
|
-
break;
|
|
13008
|
-
case "utc":
|
|
13009
|
-
case "time":
|
|
13010
|
-
lift = (x3) => +x3;
|
|
13011
|
-
toSql = (c) => c instanceof Date ? +c : epoch_ms(asColumn(c));
|
|
13012
|
-
break;
|
|
13070
|
+
const { apply, sqlApply } = scaleTransform(scale);
|
|
13071
|
+
if (apply) {
|
|
13072
|
+
const { domain, range } = scale;
|
|
13073
|
+
const lo = apply(Math.min(...domain));
|
|
13074
|
+
const hi = apply(Math.max(...domain));
|
|
13075
|
+
const a2 = Math.abs(range[1] - range[0]) / (hi - lo) / pixelSize;
|
|
13076
|
+
const s = pixelSize === 1 ? "" : `${pixelSize}::INTEGER * `;
|
|
13077
|
+
return (value) => sql`${s}FLOOR(${a2}::DOUBLE * (${sqlApply(value)} - ${lo}::DOUBLE))::INTEGER`;
|
|
13013
13078
|
}
|
|
13014
|
-
return lift ? binFunction(domain, range, pixelSize, lift, toSql) : null;
|
|
13015
|
-
}
|
|
13016
|
-
function binFunction(domain, range, pixelSize, lift, toSql) {
|
|
13017
|
-
const lo = lift(Math.min(domain[0], domain[1]));
|
|
13018
|
-
const hi = lift(Math.max(domain[0], domain[1]));
|
|
13019
|
-
const a2 = Math.abs(lift(range[1]) - lift(range[0])) / (hi - lo) / pixelSize;
|
|
13020
|
-
const s = pixelSize === 1 ? "" : `${pixelSize}::INTEGER * `;
|
|
13021
|
-
return (value) => sql`${s}FLOOR(${a2}::DOUBLE * (${toSql(value)} - ${lo}::DOUBLE))::INTEGER`;
|
|
13022
13079
|
}
|
|
13023
13080
|
var NO_INDEX = { from: NaN };
|
|
13024
13081
|
function getIndexColumns(client) {
|