Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryCompiler Batch Formula Compilation #5070

Merged
merged 21 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions Base/src/main/java/io/deephaven/base/Lazy.java

This file was deleted.

6 changes: 3 additions & 3 deletions Plot/src/main/java/io/deephaven/plot/colors/ColorMaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import io.deephaven.base.verify.Require;
import io.deephaven.gui.color.Color;
import io.deephaven.gui.color.Paint;
import io.deephaven.plot.util.functions.SerializableClosure;
import io.deephaven.plot.util.functions.HasClosure;
import io.deephaven.plot.util.Range;
import groovy.lang.Closure;

Expand Down Expand Up @@ -294,13 +294,13 @@ public static <COLOR extends Paint> Function<Double, Paint> closureMap(final Map
for (final Map.Entry<Closure<Boolean>, COLOR> e : map.entrySet()) {
final Closure<Boolean> closure = e.getKey();
final COLOR color = e.getValue();
final SerializableClosure<Boolean> serializableClosure = new SerializableClosure<>(closure);
final HasClosure<Boolean> hasClosure = new HasClosure<>(closure);
final SerializablePredicate<Double> predicate = new SerializablePredicate<Double>() {
private static final long serialVersionUID = 613420989214281949L;

@Override
public boolean test(Double aDouble) {
return serializableClosure.getClosure().call(aDouble);
return hasClosure.getClosure().call(aDouble);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Wraps a {@link SerializableBiFunction} with the API of a function. <br/>
*/
public class ClosureBiFunction<T, U, R> extends SerializableClosure<R> implements SerializableBiFunction<T, U, R> {
public class ClosureBiFunction<T, U, R> extends HasClosure<R> implements SerializableBiFunction<T, U, R> {
private static final long serialVersionUID = 697974379939190730L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* A serializable closure which maps pair of doubles to doubles.
*/
public class ClosureDoubleBinaryOperator<T extends Number> extends SerializableClosure<T>
public class ClosureDoubleBinaryOperator<T extends Number> extends HasClosure<T>
implements DoubleBinaryOperator {

private static final long serialVersionUID = -6533578879266557626L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* A serializable closure which maps doubles to doubles.
*/
public class ClosureDoubleUnaryOperator<T extends Number> extends SerializableClosure<T>
public class ClosureDoubleUnaryOperator<T extends Number> extends HasClosure<T>
implements DoubleUnaryOperator {

private static final long serialVersionUID = -4092987117189101803L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import groovy.lang.Closure;

/**
* Wraps a {@link SerializableClosure} with the API of a function.
* Wraps a {@link HasClosure} with the API of a function.
*/
public class ClosureFunction<T, R> extends SerializableClosure<R> implements SerializableFunction<T, R> {
public class ClosureFunction<T, R> extends HasClosure<R> implements SerializableFunction<T, R> {

private static final long serialVersionUID = 3693316124178311688L;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.plot.util.functions;

import io.deephaven.base.verify.Require;
import groovy.lang.Closure;

/**
* A serializable closure.
*/
public class HasClosure<T> {

private final Closure<T> closure;

/**
* Creates a SerializableClosure instance with the {@code closure}.
*
* @param closure closure
*/
public HasClosure(final Closure<T> closure) {
Require.neqNull(closure, "closure");
this.closure = closure.dehydrate();
this.closure.setResolveStrategy(Closure.DELEGATE_ONLY);
}

/**
* Gets this SerializableClosure's closure.
*
* @return this SerializableClosure's closure
*/
public Closure<T> getClosure() {
return closure;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.plot.util.functions;

import io.deephaven.base.testing.BaseArrayTestCase;
import groovy.lang.Closure;

public class TestHasClosure extends BaseArrayTestCase {

private final String value = "S";

private final Closure<String> closure = new Closure<String>(null) {
@Override
public String call() {
return value;
}

@Override
public String call(Object... args) {
return value;
}

@Override
public String call(Object arguments) {
return value;
}
};

public void testSerializableClosure() {
HasClosure<String> hasClosure = new ClosureFunction<>(closure);

assertEquals(value, hasClosure.getClosure().call());
assertEquals(value, hasClosure.getClosure().call("T"));
assertEquals(value, hasClosure.getClosure().call("A", "B"));
}
}

This file was deleted.

Loading
Loading