Skip to content

Commit

Permalink
Refactor TypedFunction, ObjectProcessor, and ObjectProcessorFunctions
Browse files Browse the repository at this point in the history
* io.deephaven.functions: extensions/protobuf -> java/functions
* io.deephaven.processor: extensions/kafka -> java/processor
* io.deephaven.processor.functions: extensions/kafka -> java/processor-functions

Introduced top-level directory `java/`, with the hopes of having it become the directory for new projects ala deephaven#4991
  • Loading branch information
devinrsmith committed Dec 28, 2023
1 parent ecebae9 commit 5b60730
Show file tree
Hide file tree
Showing 53 changed files with 205 additions and 2 deletions.
2 changes: 2 additions & 0 deletions extensions/kafka/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ description 'Kafka: Integrating Engine tables with Kafka'
dependencies {
api project(':engine-table')

api project(':processor')

api 'org.apache.avro:avro:1.11.2'

// Using io.confluent dependencies requires code in the toplevel build.gradle to add their maven repository.
Expand Down
1 change: 1 addition & 0 deletions extensions/protobuf/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {

dependencies {
api project(':qst')
api project(':functions')
api 'com.google.protobuf:protobuf-java:3.24.1'
implementation project(':engine-query-constants')

Expand Down
19 changes: 19 additions & 0 deletions java/functions/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id 'java-library'
id 'io.deephaven.project.register'
}

dependencies {
api project(':qst')

compileOnly depAnnotations

Classpaths.inheritJUnitPlatform(project)
Classpaths.inheritAssertJ(project)
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
}

test {
useJUnitPlatform()
}
1 change: 1 addition & 0 deletions java/functions/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.deephaven.project.ProjectType=JAVA_PUBLIC
16 changes: 16 additions & 0 deletions java/processor-functions/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
id 'java-library'
id 'io.deephaven.project.register'
}


dependencies {
api project(':processor')
api project(':functions')

implementation project(':engine-time')

Classpaths.inheritJUnitClassic(project, 'testImplementation')
Classpaths.inheritSlf4j(project, 'slf4j-simple', 'testRuntimeOnly')
Classpaths.inheritAssertJ(project)
}
1 change: 1 addition & 0 deletions java/processor-functions/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.deephaven.project.ProjectType=JAVA_PUBLIC
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/**
* Copyright (c) 2016-2023 Deephaven Data Labs and Patent Pending
*/
package io.deephaven.processor.functions;

import io.deephaven.chunk.ObjectChunk;
import io.deephaven.chunk.WritableBooleanChunk;
import io.deephaven.chunk.WritableByteChunk;
import io.deephaven.chunk.WritableCharChunk;
import io.deephaven.chunk.WritableDoubleChunk;
import io.deephaven.chunk.WritableFloatChunk;
import io.deephaven.chunk.WritableIntChunk;
import io.deephaven.chunk.WritableLongChunk;
import io.deephaven.chunk.WritableObjectChunk;
import io.deephaven.chunk.WritableShortChunk;
import io.deephaven.functions.ToByteFunction;
import io.deephaven.functions.ToCharFunction;
import io.deephaven.functions.ToFloatFunction;
import io.deephaven.functions.ToShortFunction;

import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.ToDoubleFunction;
import java.util.function.ToIntFunction;
import java.util.function.ToLongFunction;

final class ChunkUtils {

// Copy from io.deephaven.kafka.ingest.ChunkUtils

public static <T> void applyInto(
Predicate<? super T> booleanFunction,
ObjectChunk<? extends T, ?> src,
int srcOffset,
WritableBooleanChunk<?> dest,
int destOffset,
int length) {
for (int i = 0; i < length; ++i) {
dest.set(destOffset + i, booleanFunction.test(src.get(i + srcOffset)));
}
}

public static <T> void applyInto(
ToByteFunction<? super T> byteFunction,
ObjectChunk<? extends T, ?> src,
int srcOffset,
WritableByteChunk<?> dest,
int destOffset,
int length) {
for (int i = 0; i < length; ++i) {
dest.set(destOffset + i, byteFunction.applyAsByte(src.get(srcOffset + i)));
}
}

public static <T> void applyInto(
ToCharFunction<? super T> charFunction,
ObjectChunk<? extends T, ?> src,
int srcOffset,
WritableCharChunk<?> dest,
int destOffset,
int length) {
for (int i = 0; i < length; ++i) {
dest.set(destOffset + i, charFunction.applyAsChar(src.get(srcOffset + i)));
}
}

public static <T> void applyInto(
ToShortFunction<? super T> shortFunction,
ObjectChunk<? extends T, ?> src,
int srcOffset,
WritableShortChunk<?> dest,
int destOffset,
int length) {
for (int i = 0; i < length; ++i) {
dest.set(destOffset + i, shortFunction.applyAsShort(src.get(srcOffset + i)));
}
}

public static <T> void applyInto(
ToIntFunction<? super T> intFunction,
ObjectChunk<? extends T, ?> src,
int srcOffset,
WritableIntChunk<?> dest,
int destOffset,
int length) {
for (int i = 0; i < length; ++i) {
dest.set(destOffset + i, intFunction.applyAsInt(src.get(srcOffset + i)));
}
}

public static <T> void applyInto(
ToLongFunction<? super T> longFunction,
ObjectChunk<? extends T, ?> src,
int srcOffset,
WritableLongChunk<?> dest,
int destOffset,
int length) {
for (int i = 0; i < length; ++i) {
dest.set(destOffset + i, longFunction.applyAsLong(src.get(srcOffset + i)));
}
}

public static <T> void applyInto(
ToFloatFunction<? super T> floatFunction,
ObjectChunk<? extends T, ?> src,
int srcOffset,
WritableFloatChunk<?> dest,
int destOffset,
int length) {
for (int i = 0; i < length; ++i) {
dest.set(destOffset + i, floatFunction.applyAsFloat(src.get(srcOffset + i)));
}
}

public static <T> void applyInto(
ToDoubleFunction<? super T> doubleFunction,
ObjectChunk<? extends T, ?> src,
int srcOffset,
WritableDoubleChunk<?> dest,
int destOffset,
int length) {
for (int i = 0; i < length; ++i) {
dest.set(destOffset + i, doubleFunction.applyAsDouble(src.get(srcOffset + i)));
}
}

public static <T, R> void applyInto(
Function<? super T, ? extends R> objFunction,
ObjectChunk<? extends T, ?> src,
int srcOffset,
WritableObjectChunk<R, ?> dest,
int destOffset,
int length) {
for (int i = 0; i < length; ++i) {
dest.set(destOffset + i, objFunction.apply(src.get(srcOffset + i)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.deephaven.functions.ToPrimitiveFunction;
import io.deephaven.functions.ToShortFunction;
import io.deephaven.functions.TypedFunction;
import io.deephaven.kafka.ingest.ChunkUtils;
import io.deephaven.processor.ObjectProcessor;
import io.deephaven.qst.type.ArrayType;
import io.deephaven.qst.type.BoxedBooleanType;
Expand Down
16 changes: 16 additions & 0 deletions java/processor/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
id 'java-library'
id 'io.deephaven.project.register'
}


dependencies {
api project(':qst')
api project(':engine-chunk')

implementation project(':engine-time')

Classpaths.inheritJUnitClassic(project, 'testImplementation')
Classpaths.inheritSlf4j(project, 'slf4j-simple', 'testRuntimeOnly')
Classpaths.inheritAssertJ(project)
}
1 change: 1 addition & 0 deletions java/processor/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.deephaven.project.ProjectType=JAVA_PUBLIC
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static <T> ObjectProcessor<T> noop(List<Type<?>> outputTypes, boolean fillWithNu
* </tr>
* <tr>
* <td>{@link InstantType}</td>
* <td>{@link ChunkType#Long} ({@link io.deephaven.time.DateTimeUtils#epochNanos(Instant)})</td>
* <td>{@link ChunkType#Long} (io.deephaven.time.DateTimeUtils#epochNanos(Instant))</td>
* </tr>
* <tr>
* <td>All other {@link GenericType}</td>
Expand Down
9 changes: 9 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,15 @@ include ':clock-impl'

include ':sql'

include ':functions'
project(':functions').projectDir = file('java/functions')

include ':processor'
project(':processor').projectDir = file('java/processor')

include ':processor-functions'
project(':processor-functions').projectDir = file('java/processor-functions')

file("${rootDir}/docker/registry").list().each { name ->
if (file("${rootDir}/docker/registry/${name}/build.gradle").exists()) {
include(":docker-${name}")
Expand Down

0 comments on commit 5b60730

Please sign in to comment.