-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5389f16
commit c39adfd
Showing
6 changed files
with
189 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/udf/java/src/main/java/com/risingwave/functions/ScalarFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,46 @@ | ||
package com.risingwave.functions; | ||
|
||
/** | ||
* Base class for a user-defined scalar function. A user-defined scalar function | ||
* maps zero, one, or multiple scalar values to a new scalar value. | ||
* | ||
* <p> | ||
* The behavior of a {@link ScalarFunction} can be defined by implementing a | ||
* custom evaluation method. An evaluation method must be declared publicly and | ||
* named <code>eval</code>. Multiple overloaded methods named <code>eval</code> | ||
* are not supported yet. | ||
* | ||
* <p> | ||
* By default, input and output data types are automatically extracted using | ||
* reflection. | ||
* | ||
* <p> | ||
* The following examples show how to specify a scalar function: | ||
* | ||
* <pre> | ||
* {@code | ||
* // a function that accepts two INT arguments and computes a sum | ||
* class SumFunction extends ScalarFunction { | ||
* public Integer eval(Integer a, Integer b) { | ||
* return a + b; | ||
* } | ||
* } | ||
* | ||
* // a function that returns a struct type | ||
* class StructFunction extends ScalarFunction { | ||
* public static class KeyValue { | ||
* public String key; | ||
* public int value; | ||
* } | ||
* | ||
* public KeyValue eval(int a) { | ||
* KeyValue kv = new KeyValue(); | ||
* kv.key = a.toString(); | ||
* kv.value = a; | ||
* return kv; | ||
* } | ||
* } | ||
* }</pre> | ||
*/ | ||
public abstract class ScalarFunction extends UserDefinedFunction { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/udf/java/src/main/java/com/risingwave/functions/UserDefinedFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
package com.risingwave.functions; | ||
|
||
/** | ||
* Base class for all user-defined functions. | ||
* | ||
* @see ScalarFunction | ||
* @see TableFunction | ||
*/ | ||
public abstract class UserDefinedFunction { | ||
} |