Skip to content

Commit

Permalink
Generate ToChar/Short/ByteFunction interfaces and use in chunk apis (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed Jun 4, 2024
1 parent 2da295f commit 3209be3
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY
// ****** Edit ToCharFunction and run "./gradlew replicatePrimitiveInterfaces" to regenerate
//
// @formatter:off
package io.deephaven.engine.primitive.function;

/**
* Functional interface to apply an operation to an object and produce a {@code byte}.
*
* @param <T> the object type that this function applies to
*/
@FunctionalInterface
public interface ToByteFunction<T> {
/**
* Applies this function to the given argument of type {@link T}.
*
* @param value the argument to the function
* @return the byte result
*/
byte applyAsByte(T value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.engine.primitive.function;

/**
* Functional interface to apply an operation to an object and produce a {@code char}.
*
* @param <T> the object type that this function applies to
*/
@FunctionalInterface
public interface ToCharFunction<T> {
/**
* Applies this function to the given argument of type {@link T}.
*
* @param value the argument to the function
* @return the char result
*/
char applyAsChar(T value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY
// ****** Edit ToCharFunction and run "./gradlew replicatePrimitiveInterfaces" to regenerate
//
// @formatter:off
package io.deephaven.engine.primitive.function;

/**
* Functional interface to apply an operation to an object and produce a {@code float}.
*
* @param <T> the object type that this function applies to
*/
@FunctionalInterface
public interface ToFloatFunction<T> {
/**
* Applies this function to the given argument of type {@link T}.
*
* @param value the argument to the function
* @return the float result
*/
float applyAsFloat(T value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY
// ****** Edit ToCharFunction and run "./gradlew replicatePrimitiveInterfaces" to regenerate
//
// @formatter:off
package io.deephaven.engine.primitive.function;

/**
* Functional interface to apply an operation to an object and produce a {@code short}.
*
* @param <T> the object type that this function applies to
*/
@FunctionalInterface
public interface ToShortFunction<T> {
/**
* Applies this function to the given argument of type {@link T}.
*
* @param value the argument to the function
* @return the short result
*/
short applyAsShort(T value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import io.deephaven.chunk.WritableObjectChunk;
import io.deephaven.chunk.attributes.Values;
import io.deephaven.chunk.util.pools.PoolableChunk;
import io.deephaven.engine.primitive.function.ToByteFunction;
import io.deephaven.engine.rowset.RowSet;
import com.google.common.io.LittleEndianDataOutputStream;
import io.deephaven.UncheckedDeephavenException;
import io.deephaven.extensions.barrage.util.StreamReaderOptions;
import io.deephaven.function.ToByteFunction;
import io.deephaven.util.datastructures.LongSizedDataStructure;
import io.deephaven.chunk.ByteChunk;
import io.deephaven.chunk.WritableByteChunk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import io.deephaven.chunk.WritableObjectChunk;
import io.deephaven.chunk.attributes.Values;
import io.deephaven.chunk.util.pools.PoolableChunk;
import io.deephaven.engine.primitive.function.ToCharFunction;
import io.deephaven.engine.rowset.RowSet;
import com.google.common.io.LittleEndianDataOutputStream;
import io.deephaven.UncheckedDeephavenException;
import io.deephaven.extensions.barrage.util.StreamReaderOptions;
import io.deephaven.function.ToCharFunction;
import io.deephaven.util.datastructures.LongSizedDataStructure;
import io.deephaven.chunk.CharChunk;
import io.deephaven.chunk.WritableCharChunk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// @formatter:off
package io.deephaven.extensions.barrage.chunk;

import java.util.function.ToDoubleFunction;

import io.deephaven.base.verify.Assert;
import io.deephaven.chunk.ObjectChunk;
import io.deephaven.chunk.WritableChunk;
Expand All @@ -17,7 +19,6 @@
import com.google.common.io.LittleEndianDataOutputStream;
import io.deephaven.UncheckedDeephavenException;
import io.deephaven.extensions.barrage.util.StreamReaderOptions;
import io.deephaven.function.ToDoubleFunction;
import io.deephaven.util.datastructures.LongSizedDataStructure;
import io.deephaven.chunk.DoubleChunk;
import io.deephaven.chunk.WritableDoubleChunk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import io.deephaven.chunk.WritableObjectChunk;
import io.deephaven.chunk.attributes.Values;
import io.deephaven.chunk.util.pools.PoolableChunk;
import io.deephaven.engine.primitive.function.ToFloatFunction;
import io.deephaven.engine.rowset.RowSet;
import com.google.common.io.LittleEndianDataOutputStream;
import io.deephaven.UncheckedDeephavenException;
import io.deephaven.extensions.barrage.util.StreamReaderOptions;
import io.deephaven.function.ToFloatFunction;
import io.deephaven.util.datastructures.LongSizedDataStructure;
import io.deephaven.chunk.FloatChunk;
import io.deephaven.chunk.WritableFloatChunk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// @formatter:off
package io.deephaven.extensions.barrage.chunk;

import java.util.function.ToIntFunction;

import io.deephaven.base.verify.Assert;
import io.deephaven.chunk.ObjectChunk;
import io.deephaven.chunk.WritableChunk;
Expand All @@ -17,7 +19,6 @@
import com.google.common.io.LittleEndianDataOutputStream;
import io.deephaven.UncheckedDeephavenException;
import io.deephaven.extensions.barrage.util.StreamReaderOptions;
import io.deephaven.function.ToIntFunction;
import io.deephaven.util.datastructures.LongSizedDataStructure;
import io.deephaven.chunk.IntChunk;
import io.deephaven.chunk.WritableIntChunk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// @formatter:off
package io.deephaven.extensions.barrage.chunk;

import java.util.function.ToLongFunction;

import io.deephaven.base.verify.Assert;
import io.deephaven.chunk.ObjectChunk;
import io.deephaven.chunk.WritableChunk;
Expand All @@ -17,7 +19,6 @@
import com.google.common.io.LittleEndianDataOutputStream;
import io.deephaven.UncheckedDeephavenException;
import io.deephaven.extensions.barrage.util.StreamReaderOptions;
import io.deephaven.function.ToLongFunction;
import io.deephaven.util.datastructures.LongSizedDataStructure;
import io.deephaven.chunk.LongChunk;
import io.deephaven.chunk.WritableLongChunk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import io.deephaven.chunk.WritableObjectChunk;
import io.deephaven.chunk.attributes.Values;
import io.deephaven.chunk.util.pools.PoolableChunk;
import io.deephaven.engine.primitive.function.ToShortFunction;
import io.deephaven.engine.rowset.RowSet;
import com.google.common.io.LittleEndianDataOutputStream;
import io.deephaven.UncheckedDeephavenException;
import io.deephaven.extensions.barrage.util.StreamReaderOptions;
import io.deephaven.function.ToShortFunction;
import io.deephaven.util.datastructures.LongSizedDataStructure;
import io.deephaven.chunk.ShortChunk;
import io.deephaven.chunk.WritableShortChunk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public class ReplicateBarrageUtils {
public static void main(final String[] args) throws IOException {
ReplicatePrimitiveCode.charToAllButBoolean("replicateBarrageUtils",
CHUNK_PACKAGE + "/CharChunkInputStreamGenerator.java");
fixupChunkInputStreamGen(CHUNK_PACKAGE + "/IntChunkInputStreamGenerator.java", "Int");
fixupChunkInputStreamGen(CHUNK_PACKAGE + "/LongChunkInputStreamGenerator.java", "Long");
fixupChunkInputStreamGen(CHUNK_PACKAGE + "/DoubleChunkInputStreamGenerator.java", "Double");

ReplicatePrimitiveCode.charToAllButBoolean("replicateBarrageUtils",
CHUNK_PACKAGE + "/array/CharArrayExpansionKernel.java");

Expand All @@ -39,4 +43,13 @@ private static void fixupVectorExpansionKernel(final @NotNull String path, final
lines = addImport(lines, "import java.util.function." + type + "Consumer;");
FileUtils.writeLines(file, lines);
}

private static void fixupChunkInputStreamGen(final @NotNull String path, final @NotNull String type)
throws IOException {
final File file = new File(path);
List<String> lines = FileUtils.readLines(file, Charset.defaultCharset());
lines = removeImport(lines, "import io.deephaven.engine.primitive.function.To" + type + "Function;");
lines = addImport(lines, "import java.util.function.To" + type + "Function;");
FileUtils.writeLines(file, lines);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ public class ReplicatePrimitiveInterfaces {
private static final String INT_ITERATOR_PATH =
"engine/primitive/src/main/java/io/deephaven/engine/primitive/iterator/CloseablePrimitiveIteratorOfInt.java";

private static final String TO_CHAR_PATH =
"engine/primitive/src/main/java/io/deephaven/engine/primitive/function/ToCharFunction.java";

public static void main(String[] args) throws IOException {
{
charToShortAndByte(TASK, CHAR_CONSUMER_PATH);
charToFloat(TASK, CHAR_CONSUMER_PATH, null);
}
{
charToShortAndByte(TASK, TO_CHAR_PATH);
charToFloat(TASK, TO_CHAR_PATH, null);
}
{
charToShortAndByte(TASK, CHAR_TO_INT_PATH);
final String floatToIntPath = charToFloat(TASK, CHAR_TO_INT_PATH, null);
Expand Down

0 comments on commit 3209be3

Please sign in to comment.