Search in sources :

Example 1 with LongWrapper

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();
}
Also used : LongWrapper(io.deephaven.web.client.api.LongWrapper)

Example 2 with LongWrapper

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);
    }
}
Also used : Literal(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.Literal) LongWrapper(io.deephaven.web.client.api.LongWrapper) DateWrapper(io.deephaven.web.client.api.DateWrapper) JsMethod(jsinterop.annotations.JsMethod)

Example 3 with LongWrapper

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);
        }
    });
}
Also used : java.util(java.util) TableSubscription(io.deephaven.web.client.api.subscription.TableSubscription) SubscriptionTableData(io.deephaven.web.client.api.subscription.SubscriptionTableData) JsTable(io.deephaven.web.client.api.JsTable) JsLog(io.deephaven.web.client.fu.JsLog) LongWrapper(io.deephaven.web.client.api.LongWrapper) CustomEventInit(elemental2.dom.CustomEventInit) Promise(elemental2.promise.Promise) CustomEvent(elemental2.dom.CustomEvent) Collectors(java.util.stream.Collectors) DateWrapper(io.deephaven.web.client.api.DateWrapper) Promise(elemental2.promise.Promise) JsTable(io.deephaven.web.client.api.JsTable) LongWrapper(io.deephaven.web.client.api.LongWrapper) CustomEventInit(elemental2.dom.CustomEventInit) TableSubscription(io.deephaven.web.client.api.subscription.TableSubscription)

Aggregations

LongWrapper (io.deephaven.web.client.api.LongWrapper)3 DateWrapper (io.deephaven.web.client.api.DateWrapper)2 CustomEvent (elemental2.dom.CustomEvent)1 CustomEventInit (elemental2.dom.CustomEventInit)1 Promise (elemental2.promise.Promise)1 Literal (io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.Literal)1 JsTable (io.deephaven.web.client.api.JsTable)1 SubscriptionTableData (io.deephaven.web.client.api.subscription.SubscriptionTableData)1 TableSubscription (io.deephaven.web.client.api.subscription.TableSubscription)1 JsLog (io.deephaven.web.client.fu.JsLog)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 JsMethod (jsinterop.annotations.JsMethod)1