use of io.deephaven.web.client.api.LongWrapper in project deephaven-core by deephaven.
the class JsDateTimeFormatTestGwt method assertRoundTrip.
/**
* Helper which takes a string, parses the string, and then formats the long again. The input is checked to match
* the output of the final format call, and the intermediate value is returned for any subsequent checks.
*/
private long assertRoundTrip(String formatString, String input) {
JsDateTimeFormat format = JsDateTimeFormat.getFormat(formatString);
LongWrapper parsed = format.parse(input, null);
assertEquals(input, format.format(parsed, null));
return parsed.getWrapped();
}
use of io.deephaven.web.client.api.LongWrapper in project deephaven-core by deephaven.
the class FilterValue method ofNumber.
@JsMethod(namespace = "dh.FilterValue")
public static FilterValue ofNumber(Object input) {
Objects.requireNonNull(input);
if (input instanceof DateWrapper) {
Literal lit = new Literal();
lit.setNanoTimeValue(((DateWrapper) input).valueOf());
return new FilterValue(lit);
} else if (input instanceof LongWrapper) {
Literal lit = new Literal();
lit.setLongValue(((LongWrapper) input).valueOf());
return new FilterValue(lit);
} else if (Js.typeof(input).equals("number")) {
Literal lit = new Literal();
lit.setDoubleValue(Js.asDouble(input));
return new FilterValue(lit);
} else {
// not sure what the input is, try to toString(), then parse to Double, and use that
Literal lit = new Literal();
lit.setDoubleValue(Double.parseDouble(input.toString()));
return new FilterValue(lit);
}
}
use of io.deephaven.web.client.api.LongWrapper in project deephaven-core by deephaven.
the class FigureSubscription method subscribe.
public void subscribe() {
assert subscription == null;
// Copy the table so we can optionally filter it - we'll need to release this table later
// Assign the promise to the subscription field so we can kill it mid-work
subscription = originalTable.copy(false).then(table -> {
Promise<JsTable> tablePromise = Promise.resolve(table);
// then downsample, subscribe
if (downsampleAxisRange == null) {
// check if there are too many items, and downsampling isn't outright disabled
if (table.getSize() > DownsampleOptions.MAX_SERIES_SIZE) {
if (includedSeries.stream().map(JsSeries::getDownsampleOptions).noneMatch(options -> options == DownsampleOptions.DISABLE)) {
// stop, we can't downsample, we haven't been told to disable, and there are too many items to
// fetch them outright
figure.downsampleNeeded("Disable downsampling to retrieve all items", includedSeries, table.getSize());
// noinspection unchecked
return (Promise<TableSubscription>) (Promise) Promise.reject("Too many items to display, disable downsampling to display this series or size the axes");
} else if (table.getSize() > DownsampleOptions.MAX_SUBSCRIPTION_SIZE) {
figure.downsampleNeeded("Too many items to disable downsampling", includedSeries, table.getSize());
// noinspection unchecked
return (Promise<TableSubscription>) (Promise) Promise.reject("Too many items to disable downsampling");
}
}
// we actually sub to a copy, so that we can close it no matter what when we're done
return subscribe(tablePromise);
} else if (table.getSize() < 2 * (1 + downsampleParams.getyCols().length) * downsampleParams.getPixelCount() * MIN_DOWNSAMPLE_FACTOR) {
// greater than the pixel size. The MIN_DOWNSAMPLE_FACTOR field is used to define "sufficiently greater"
return subscribe(tablePromise);
// TODO revisit this so we can watch the row count and downsample later if needed
} else {
final LongWrapper[] zoomRange;
if (downsampleAxisRange.min != null && downsampleAxisRange.getMax() != null) {
zoomRange = new LongWrapper[] { DateWrapper.of(downsampleAxisRange.getMin()), DateWrapper.of(downsampleAxisRange.getMax()) };
JsLog.info("zoom range provided: ", zoomRange);
} else {
zoomRange = null;
}
CustomEventInit init = CustomEventInit.create();
init.setDetail(includedSeries.toArray());
figure.fireEvent(JsFigure.EVENT_DOWNSAMPLESTARTED, init);
Promise<JsTable> downsampled = tablePromise.then(t -> t.downsample(zoomRange, downsampleParams.getPixelCount(), downsampleAxisRange.getxCol(), downsampleParams.getyCols()).then(resultTable -> Promise.resolve(resultTable), err -> {
figure.downsampleFailed(err.toString(), includedSeries, table.getSize());
if (table.getSize() > DownsampleOptions.MAX_SERIES_SIZE) {
if (includedSeries.stream().map(JsSeries::getDownsampleOptions).noneMatch(options -> options == DownsampleOptions.DISABLE)) {
// noinspection unchecked
return (Promise<JsTable>) (Promise) Promise.reject("");
}
} else if (table.getSize() > DownsampleOptions.MAX_SUBSCRIPTION_SIZE) {
// noinspection unchecked
return (Promise<JsTable>) (Promise) Promise.reject("");
}
return Promise.resolve(table);
}));
return subscribe(downsampled);
}
});
}
Aggregations