Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
6ff4d7e5
I
Iotdb
项目概览
apache
/
Iotdb
11 个月 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
6ff4d7e5
编写于
6月 26, 2023
作者:
I
Itami Sho
提交者:
GitHub
6月 26, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[IOTDB-6025] iotdb-api: fix bugs & smells reported by SonarCloud (#10318)
上级
e7a6433d
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
203 addition
and
103 deletion
+203
-103
iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/IPropertiesLoader.java
...java/org/apache/iotdb/external/api/IPropertiesLoader.java
+3
-2
iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/thrift/JudgableServerContext.java
...ache/iotdb/external/api/thrift/JudgableServerContext.java
+7
-2
iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/thrift/ServerContextFactory.java
...pache/iotdb/external/api/thrift/ServerContextFactory.java
+1
-0
iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/access/Row.java
...i/src/main/java/org/apache/iotdb/pipe/api/access/Row.java
+5
-6
iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/event/dml/insertion/TabletInsertionEvent.java
...db/pipe/api/event/dml/insertion/TabletInsertionEvent.java
+4
-4
iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/event/dml/insertion/TsFileInsertionEvent.java
...db/pipe/api/event/dml/insertion/TsFileInsertionEvent.java
+1
-1
iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/type/Binary.java
.../src/main/java/org/apache/iotdb/pipe/api/type/Binary.java
+2
-1
iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/type/Type.java
...pi/src/main/java/org/apache/iotdb/pipe/api/type/Type.java
+9
-9
iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/SubscriptionConfiguration.java
...che/iotdb/subscription/api/SubscriptionConfiguration.java
+3
-1
iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/consumer/Consumer.java
.../org/apache/iotdb/subscription/api/consumer/Consumer.java
+10
-2
iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/strategy/SubscriptionStrategy.java
...iotdb/subscription/api/strategy/SubscriptionStrategy.java
+5
-1
iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/strategy/disorder/IntolerableStrategy.java
...bscription/api/strategy/disorder/IntolerableStrategy.java
+3
-1
iotdb-api/trigger-api/src/main/java/org/apache/iotdb/trigger/api/Trigger.java
...i/src/main/java/org/apache/iotdb/trigger/api/Trigger.java
+2
-0
iotdb-api/trigger-api/src/main/java/org/apache/iotdb/trigger/api/enums/FailureStrategy.java
...a/org/apache/iotdb/trigger/api/enums/FailureStrategy.java
+1
-0
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/UDF.java
...i/udf-api/src/main/java/org/apache/iotdb/udf/api/UDF.java
+6
-2
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/UDTF.java
.../udf-api/src/main/java/org/apache/iotdb/udf/api/UDTF.java
+13
-6
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/access/Row.java
...pi/src/main/java/org/apache/iotdb/udf/api/access/Row.java
+9
-1
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/config/UDTFConfigurations.java
...e/iotdb/udf/api/customizer/config/UDTFConfigurations.java
+6
-4
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/parameter/UDFParameterValidator.java
...b/udf/api/customizer/parameter/UDFParameterValidator.java
+4
-0
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/AccessStrategy.java
...che/iotdb/udf/api/customizer/strategy/AccessStrategy.java
+30
-6
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/MappableRowByRowAccessStrategy.java
...i/customizer/strategy/MappableRowByRowAccessStrategy.java
+11
-9
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/RowByRowAccessStrategy.java
...b/udf/api/customizer/strategy/RowByRowAccessStrategy.java
+8
-6
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SessionTimeWindowAccessStrategy.java
.../customizer/strategy/SessionTimeWindowAccessStrategy.java
+2
-0
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SlidingSizeWindowAccessStrategy.java
.../customizer/strategy/SlidingSizeWindowAccessStrategy.java
+9
-7
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SlidingTimeWindowAccessStrategy.java
.../customizer/strategy/SlidingTimeWindowAccessStrategy.java
+31
-22
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/StateWindowAccessStrategy.java
...df/api/customizer/strategy/StateWindowAccessStrategy.java
+5
-0
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/type/Binary.java
...i/src/main/java/org/apache/iotdb/udf/api/type/Binary.java
+3
-1
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/type/Type.java
...api/src/main/java/org/apache/iotdb/udf/api/type/Type.java
+10
-9
未找到文件。
iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/IPropertiesLoader.java
浏览文件 @
6ff4d7e5
...
...
@@ -16,17 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
package
org.apache.iotdb.external.api
;
import
java.util.Properties
;
/**
* An interface to load properties from external properties file to override the default
* configurations
* configurations
.
*/
public
interface
IPropertiesLoader
{
/**
* Load Properties from specific file
* Load Properties from specific file
.
*
* @return a property list with values in file.
*/
...
...
iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/thrift/JudgableServerContext.java
浏览文件 @
6ff4d7e5
...
...
@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package
org.apache.iotdb.external.api.thrift
;
import
org.apache.thrift.server.ServerContext
;
...
...
@@ -29,7 +30,11 @@ public interface JudgableServerContext extends ServerContext {
*/
boolean
whenConnect
();
/** @return false if we do not allow this connection */
/**
* this method will be called when a client disconnects to the IoTDB server.
*
* @return false if we do not allow this connection
*/
boolean
whenDisconnect
();
@Override
...
...
@@ -40,5 +45,5 @@ public interface JudgableServerContext extends ServerContext {
@Override
default
boolean
isWrapperFor
(
Class
<?>
iface
)
{
return
false
;
}
;
}
}
iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/thrift/ServerContextFactory.java
浏览文件 @
6ff4d7e5
...
...
@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package
org.apache.iotdb.external.api.thrift
;
import
org.apache.thrift.protocol.TProtocol
;
...
...
iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/access/Row.java
浏览文件 @
6ff4d7e5
...
...
@@ -24,7 +24,6 @@ import org.apache.iotdb.pipe.api.type.Binary;
import
org.apache.iotdb.pipe.api.type.Type
;
import
org.apache.iotdb.tsfile.read.common.Path
;
import
java.io.IOException
;
import
java.util.List
;
public
interface
Row
{
...
...
@@ -54,7 +53,7 @@ public interface Row {
* @param columnIndex index of the specified column
* @return the long value at the specified column in this row
*/
long
getLong
(
int
columnIndex
)
throws
IOException
;
long
getLong
(
int
columnIndex
);
/**
* Returns the float value at the specified column in this row.
...
...
@@ -131,7 +130,7 @@ public interface Row {
boolean
isNull
(
int
columnIndex
);
/**
* Returns the number of columns (excluding the timestamp column)
* Returns the number of columns (excluding the timestamp column)
.
*
* @return the number of columns (excluding the timestamp column)
*/
...
...
@@ -141,20 +140,20 @@ public interface Row {
* Returns the actual column index of the given column name.
*
* @param columnName the column name in Path form
* @throws PipeParameterNotValidException if the given column name is not existed in the Row
* @return the actual column index of the given column name
* @throws PipeParameterNotValidException if the given column name is not existed in the Row
*/
int
getColumnIndex
(
Path
columnName
)
throws
PipeParameterNotValidException
;
/**
* Returns the column data types in the Row
* Returns the column data types in the Row
.
*
* @return the column data types in the Row
*/
List
<
Type
>
getColumnTypes
();
/**
* Returns the device id of the Row
* Returns the device id of the Row
.
*
* @return the device id of the Row
*/
...
...
iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/event/dml/insertion/TabletInsertionEvent.java
浏览文件 @
6ff4d7e5
...
...
@@ -32,16 +32,16 @@ public interface TabletInsertionEvent extends Event {
/**
* The consumer processes the data row by row and collects the results by RowCollector.
*
* @return
Iterable<TabletInsertionEvent> a list of new TabletInsertionEvent contains the results
* collected by the RowCollector
* @return
{@code Iterable<TabletInsertionEvent>} a list of new TabletInsertionEvent contains the
*
results
collected by the RowCollector
*/
Iterable
<
TabletInsertionEvent
>
processRowByRow
(
BiConsumer
<
Row
,
RowCollector
>
consumer
);
/**
* The consumer processes the Tablet directly and collects the results by RowCollector.
*
* @return
Iterable<TabletInsertionEvent> a list of new TabletInsertionEvent contains the results
* collected by the RowCollector
* @return
{@code Iterable<TabletInsertionEvent>} a list of new TabletInsertionEvent contains the
*
results
collected by the RowCollector
*/
Iterable
<
TabletInsertionEvent
>
processTablet
(
BiConsumer
<
Tablet
,
RowCollector
>
consumer
);
}
iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/event/dml/insertion/TsFileInsertionEvent.java
浏览文件 @
6ff4d7e5
...
...
@@ -30,7 +30,7 @@ public interface TsFileInsertionEvent extends Event {
/**
* The method is used to convert the TsFileInsertionEvent into several TabletInsertionEvents.
*
* @return
the list of TsFile
InsertionEvent
* @return
{@code Iterable<TabletInsertionEvent>} the list of Tablet
InsertionEvent
*/
Iterable
<
TabletInsertionEvent
>
toTabletInsertionEvents
();
}
iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/type/Binary.java
浏览文件 @
6ff4d7e5
...
...
@@ -21,6 +21,7 @@ package org.apache.iotdb.pipe.api.type;
import
java.io.Serializable
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Arrays
;
/**
...
...
@@ -31,7 +32,7 @@ public class Binary implements Comparable<Binary>, Serializable {
private
static
final
long
serialVersionUID
=
1250049718612917815L
;
public
static
final
String
STRING_ENCODING
=
"UTF-8"
;
public
static
final
Charset
STRING_CHARSET
=
Charset
.
forName
(
STRING_ENCODING
)
;
public
static
final
Charset
STRING_CHARSET
=
StandardCharsets
.
UTF_8
;
private
final
byte
[]
values
;
...
...
iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/type/Type.java
浏览文件 @
6ff4d7e5
...
...
@@ -20,31 +20,31 @@
package
org.apache.iotdb.pipe.api.type
;
public
enum
Type
{
/*
*
BOOLEAN */
/* BOOLEAN */
BOOLEAN
((
byte
)
0
),
/*
*
INT32 */
/* INT32 */
INT32
((
byte
)
1
),
/*
*
INT64 */
/* INT64 */
INT64
((
byte
)
2
),
/*
*
FLOAT */
/* FLOAT */
FLOAT
((
byte
)
3
),
/*
*
DOUBLE */
/* DOUBLE */
DOUBLE
((
byte
)
4
),
/*
*
TEXT */
/* TEXT */
TEXT
((
byte
)
5
);
private
final
byte
t
ype
;
private
final
byte
dataT
ype
;
Type
(
byte
type
)
{
this
.
t
ype
=
type
;
this
.
dataT
ype
=
type
;
}
public
byte
getType
()
{
return
t
ype
;
return
dataT
ype
;
}
}
iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/SubscriptionConfiguration.java
浏览文件 @
6ff4d7e5
...
...
@@ -33,7 +33,9 @@ public class SubscriptionConfiguration {
private
DisorderHandlingStrategy
disorderHandlingStrategy
;
private
TopicsStrategy
topicStrategy
;
private
SubscriptionConfiguration
()
{}
private
SubscriptionConfiguration
()
{
// allowed to be constructed by builder
}
private
void
check
()
throws
SubscriptionException
{
if
(
host
==
null
)
{
...
...
iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/consumer/Consumer.java
浏览文件 @
6ff4d7e5
...
...
@@ -25,10 +25,18 @@ import java.util.List;
public
interface
Consumer
extends
AutoCloseable
{
/** Open the subscription. */
/**
* Open the subscription.
*
* @throws SubscriptionException if the subscription cannot be opened
*/
void
openSubscription
()
throws
SubscriptionException
;
/** Close the subscription. */
/**
* Close the subscription.
*
* @throws SubscriptionException if the subscription cannot be closed
*/
void
closeSubscription
()
throws
SubscriptionException
;
/**
...
...
iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/strategy/SubscriptionStrategy.java
浏览文件 @
6ff4d7e5
...
...
@@ -24,6 +24,10 @@ import org.apache.iotdb.subscription.api.exception.SubscriptionStrategyNotValidE
/** Subscription strategy interface. */
public
interface
SubscriptionStrategy
{
/** @throws SubscriptionStrategyNotValidException if invalid strategy is set */
/**
* Check if the strategy is valid.
*
* @throws SubscriptionStrategyNotValidException if invalid strategy is set
*/
void
check
()
throws
SubscriptionStrategyNotValidException
;
}
iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/strategy/disorder/IntolerableStrategy.java
浏览文件 @
6ff4d7e5
...
...
@@ -28,5 +28,7 @@ public class IntolerableStrategy extends DisorderHandlingStrategy {
}
@Override
public
void
check
()
throws
SubscriptionStrategyNotValidException
{}
public
void
check
()
throws
SubscriptionStrategyNotValidException
{
// do nothing
}
}
iotdb-api/trigger-api/src/main/java/org/apache/iotdb/trigger/api/Trigger.java
浏览文件 @
6ff4d7e5
...
...
@@ -67,6 +67,8 @@ public interface Trigger {
}
/**
* This method will be called when a trigger is fired.
*
* @param tablet see {@link Tablet} for detailed information of data structure. Data that is
* inserted will be constructed as a Tablet and you can define process logic with {@link
* Tablet}.
...
...
iotdb-api/trigger-api/src/main/java/org/apache/iotdb/trigger/api/enums/FailureStrategy.java
浏览文件 @
6ff4d7e5
...
...
@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package
org.apache.iotdb.trigger.api.enums
;
import
org.apache.iotdb.trigger.api.Trigger
;
...
...
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/UDF.java
浏览文件 @
6ff4d7e5
...
...
@@ -33,8 +33,12 @@ public interface UDF {
* @throws Exception if any parameter is not valid
*/
@SuppressWarnings
(
"squid:S112"
)
default
void
validate
(
UDFParameterValidator
validator
)
throws
Exception
{}
default
void
validate
(
UDFParameterValidator
validator
)
throws
Exception
{
// do nothing
}
/** This method is mainly used to release the resources used in the UDF. */
default
void
beforeDestroy
()
{}
default
void
beforeDestroy
()
{
// do nothing
}
}
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/UDTF.java
浏览文件 @
6ff4d7e5
...
...
@@ -46,7 +46,7 @@ import org.apache.iotdb.udf.api.customizer.strategy.SlidingTimeWindowAccessStrat
* PointCollector)}
* </ul>
*
* In the life cycle of a UDTF instance, the calling sequence of each method is as follows:
*
<p>
In the life cycle of a UDTF instance, the calling sequence of each method is as follows:
*
* <p>1. {@link UDTF#validate(UDFParameterValidator)} 2. {@link UDTF#beforeStart(UDFParameters,
* UDTFConfigurations)} 3. {@link UDTF#transform(RowWindow, PointCollector)} or {@link
...
...
@@ -91,7 +91,9 @@ public interface UDTF extends UDF {
* @see RowByRowAccessStrategy
*/
@SuppressWarnings
(
"squid:S112"
)
default
void
transform
(
Row
row
,
PointCollector
collector
)
throws
Exception
{}
default
void
transform
(
Row
row
,
PointCollector
collector
)
throws
Exception
{
// do nothing
}
/**
* When the user specifies {@link SlidingSizeWindowAccessStrategy} or {@link
...
...
@@ -106,7 +108,9 @@ public interface UDTF extends UDF {
* @see SlidingTimeWindowAccessStrategy
*/
@SuppressWarnings
(
"squid:S112"
)
default
void
transform
(
RowWindow
rowWindow
,
PointCollector
collector
)
throws
Exception
{}
default
void
transform
(
RowWindow
rowWindow
,
PointCollector
collector
)
throws
Exception
{
// do nothing
}
/**
* When the user specifies {@link MappableRowByRowAccessStrategy} to access the original data in
...
...
@@ -115,6 +119,7 @@ public interface UDTF extends UDF {
*
* @param row original input data row (aligned by time)
* @throws Exception the user can throw errors if necessary
* @throws UnsupportedOperationException if the user does not override this method
* @see MappableRowByRowAccessStrategy
*/
default
Object
transform
(
Row
row
)
throws
Exception
{
...
...
@@ -122,13 +127,15 @@ public interface UDTF extends UDF {
}
/**
* This method will be called once after all {@link UDTF#transform(Row, PointCollector) calls or
* {@link UDTF#transform(RowWindow, PointCollector) calls have been executed. In a single UDF
* This method will be called once after all {@link UDTF#transform(Row, PointCollector)
}
calls or
* {@link UDTF#transform(RowWindow, PointCollector)
}
calls have been executed. In a single UDF
* query, this method will and will only be called once.
*
* @param collector used to collect output data points
* @throws Exception the user can throw errors if necessary
*/
@SuppressWarnings
(
"squid:S112"
)
default
void
terminate
(
PointCollector
collector
)
throws
Exception
{}
default
void
terminate
(
PointCollector
collector
)
throws
Exception
{
// do nothing
}
}
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/access/Row.java
浏览文件 @
6ff4d7e5
...
...
@@ -30,6 +30,7 @@ public interface Row {
* Returns the timestamp of this row.
*
* @return timestamp
* @throws IOException if an I/O error occurs
*/
long
getTime
()
throws
IOException
;
...
...
@@ -40,6 +41,7 @@ public interface Row {
*
* @param columnIndex index of the specified column
* @return the int value at the specified column in this row
* @throws IOException if an I/O error occurs
*/
int
getInt
(
int
columnIndex
)
throws
IOException
;
...
...
@@ -50,6 +52,7 @@ public interface Row {
*
* @param columnIndex index of the specified column
* @return the long value at the specified column in this row
* @throws IOException if an I/O error occurs
*/
long
getLong
(
int
columnIndex
)
throws
IOException
;
...
...
@@ -60,6 +63,7 @@ public interface Row {
*
* @param columnIndex index of the specified column
* @return the float value at the specified column in this row
* @throws IOException if an I/O error occurs
*/
float
getFloat
(
int
columnIndex
)
throws
IOException
;
...
...
@@ -71,6 +75,7 @@ public interface Row {
*
* @param columnIndex index of the specified column
* @return the double value at the specified column in this row
* @throws IOException if an I/O error occurs
*/
double
getDouble
(
int
columnIndex
)
throws
IOException
;
...
...
@@ -82,6 +87,7 @@ public interface Row {
*
* @param columnIndex index of the specified column
* @return the boolean value at the specified column in this row
* @throws IOException if an I/O error occurs
*/
boolean
getBoolean
(
int
columnIndex
)
throws
IOException
;
...
...
@@ -92,6 +98,7 @@ public interface Row {
*
* @param columnIndex index of the specified column
* @return the Binary value at the specified column in this row
* @throws IOException if an I/O error occurs
*/
Binary
getBinary
(
int
columnIndex
)
throws
IOException
;
...
...
@@ -102,6 +109,7 @@ public interface Row {
*
* @param columnIndex index of the specified column
* @return the String value at the specified column in this row
* @throws IOException if an I/O error occurs
*/
String
getString
(
int
columnIndex
)
throws
IOException
;
...
...
@@ -122,7 +130,7 @@ public interface Row {
boolean
isNull
(
int
columnIndex
);
/**
* Returns the number of columns
* Returns the number of columns
.
*
* @return the number of columns
*/
...
...
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/config/UDTFConfigurations.java
浏览文件 @
6ff4d7e5
...
...
@@ -34,16 +34,18 @@ import java.time.ZoneId;
/**
* Used in {@link UDTF#beforeStart(UDFParameters, UDTFConfigurations)}.
* <p>
* Supports calling methods in a chain.
* <p>
* Sample code:
*
* <p>Supports calling methods in a chain.
*
* <p>Sample code:
*
* <pre>{@code
* @Override
* public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) {
* configurations
* .setOutputDataType(TSDataType.INT64)
* .setAccessStrategy(new RowByRowAccessStrategy());
* }
* }</pre>
*/
public
class
UDTFConfigurations
extends
UDFConfigurations
{
...
...
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/parameter/UDFParameterValidator.java
浏览文件 @
6ff4d7e5
...
...
@@ -59,6 +59,8 @@ public class UDFParameterValidator {
*
* @param index index of the specified column
* @param expectedDataType the expected data type
* @throws UDFException there are two exceptions that may be thrown:
* UDFInputSeriesIndexNotValidException and UDFInputSeriesDataTypeNotValidException
* @throws UDFInputSeriesIndexNotValidException if the index of the specified column is out of
* bound
* @throws UDFInputSeriesDataTypeNotValidException if the data type of the input series at the
...
...
@@ -82,6 +84,8 @@ public class UDFParameterValidator {
*
* @param index index of the specified column
* @param expectedDataTypes the expected data types
* @throws UDFException there are two exceptions that may be thrown:
* UDFInputSeriesIndexNotValidException and UDFInputSeriesDataTypeNotValidException
* @throws UDFInputSeriesIndexNotValidException if the index of the specified column is out of
* bound
* @throws UDFInputSeriesDataTypeNotValidException if the data type of the input series at the
...
...
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/AccessStrategy.java
浏览文件 @
6ff4d7e5
...
...
@@ -31,22 +31,46 @@ public interface AccessStrategy {
enum
AccessStrategyType
{
/** @see MappableRowByRowAccessStrategy */
/**
* Represents the access strategy type for mappable row-by-row access.
*
* @see MappableRowByRowAccessStrategy
*/
MAPPABLE_ROW_BY_ROW
,
/** @see RowByRowAccessStrategy */
/**
* Represents the access strategy type for row-by-row access.
*
* @see RowByRowAccessStrategy
*/
ROW_BY_ROW
,
/** @see SlidingTimeWindowAccessStrategy */
/**
* Represents the access strategy type for sliding time window access.
*
* @see SlidingTimeWindowAccessStrategy
*/
SLIDING_TIME_WINDOW
,
/** @see SlidingSizeWindowAccessStrategy */
/**
* Represents the access strategy type for sliding size window access.
*
* @see SlidingSizeWindowAccessStrategy
*/
SLIDING_SIZE_WINDOW
,
/** @see SessionTimeWindowAccessStrategy */
/**
* Represents the access strategy type for session time window access.
*
* @see SessionTimeWindowAccessStrategy
*/
SESSION_TIME_WINDOW
,
/** @see StateWindowAccessStrategy */
/**
* Represents the access strategy type for state window access.
*
* @see StateWindowAccessStrategy
*/
STATE_WINDOW
}
...
...
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/MappableRowByRowAccessStrategy.java
浏览文件 @
6ff4d7e5
...
...
@@ -26,21 +26,23 @@ import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
/**
* Used in {@link UDTF#beforeStart(UDFParameters, UDTFConfigurations)}.
* <p>
* When the access strategy of a UDTF is set to an instance of this class, the method {@link
* UDTF#transform(Row)} of the UDTF will be called to transform the original data.
* You need to override the method in your own UDTF class.
* <p>
* Each call of the method {@link UDTF#transform(Row)} processes only one row
* (aligned by time) of the original data and can generate any number of data points.
* <p>
* Sample code:
*
* <p>When the access strategy of a UDTF is set to an instance of this class, the method {@link
* UDTF#transform(Row)} of the UDTF will be called to transform the original data. You need to
* override the method in your own UDTF class.
*
* <p>Each call of the method {@link UDTF#transform(Row)} processes only one row (aligned by time)
* of the original data and can generate any number of data points.
*
* <p>Sample code:
*
* <pre>{@code
* @Override
* public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) {
* configurations
* .setOutputDataType(TSDataType.INT64)
* .setAccessStrategy(new MappableRowByRowAccessStrategy());
* }
* }</pre>
*
* @see UDTF
...
...
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/RowByRowAccessStrategy.java
浏览文件 @
6ff4d7e5
...
...
@@ -27,21 +27,23 @@ import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
/**
* Used in {@link UDTF#beforeStart(UDFParameters, UDTFConfigurations)}.
*
<p>
* When the access strategy of a UDTF is set to an instance of this class, the method {@link
*
*
<p>
When the access strategy of a UDTF is set to an instance of this class, the method {@link
* UDTF#transform(Row, PointCollector)} of the UDTF will be called to transform the original data.
* You need to override the method in your own UDTF class.
*
<p>
* Each call of the method {@link UDTF#transform(Row, PointCollector)} processes only one row
*
*
<p>
Each call of the method {@link UDTF#transform(Row, PointCollector)} processes only one row
* (aligned by time) of the original data and can generate any number of data points.
* <p>
* Sample code:
*
* <p>Sample code:
*
* <pre>{@code
* @Override
* public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) {
* configurations
* .setOutputDataType(TSDataType.INT64)
* .setAccessStrategy(new RowByRowAccessStrategy());
* }
* }</pre>
*
* @see UDTF
...
...
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SessionTimeWindowAccessStrategy.java
浏览文件 @
6ff4d7e5
...
...
@@ -30,6 +30,8 @@ public class SessionTimeWindowAccessStrategy implements AccessStrategy {
private
ZoneId
zoneId
;
/**
* Display window begin, display window end and sessionTimeGap will be set by the parameters.
*
* @param displayWindowBegin displayWindowBegin < displayWindowEnd
* @param displayWindowEnd displayWindowBegin < displayWindowEnd
* @param sessionTimeGap 0 <= sessionTimeGap
...
...
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SlidingSizeWindowAccessStrategy.java
浏览文件 @
6ff4d7e5
...
...
@@ -27,23 +27,25 @@ import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
/**
* Used in {@link UDTF#beforeStart(UDFParameters, UDTFConfigurations)}.
*
<p>
* When the access strategy of a UDTF is set to an instance of this class, the method {@link
*
*
<p>
When the access strategy of a UDTF is set to an instance of this class, the method {@link
* UDTF#transform(RowWindow, PointCollector)} of the UDTF will be called to transform the original
* data. You need to override the method in your own UDTF class.
*
<p>
* Sliding size window is a kind of size-based window. Except for the last call, each call of the
*
*
<p>
Sliding size window is a kind of size-based window. Except for the last call, each call of the
* method {@link UDTF#transform(RowWindow, PointCollector)} processes a window with {@code
* windowSize} rows (aligned by time) of the original data and can generate any number of data
* points.
* <p>
* Sample code:
*
* <p>Sample code:
*
* <pre>{@code
* @Override
* public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) {
* configurations
* .setOutputDataType(TSDataType.INT32)
* .setAccessStrategy(new SlidingSizeWindowAccessStrategy(10000)); // window size
* }
* }</pre>
*
* @see UDTF
...
...
@@ -72,7 +74,7 @@ public class SlidingSizeWindowAccessStrategy implements AccessStrategy {
* <li>(7, 102, 'error')
* </ul>
*
* Set windowSize to 2 and set slidingStep to 3, windows will be generated as below: Window 0:
*
<p>
Set windowSize to 2 and set slidingStep to 3, windows will be generated as below: Window 0:
* [(1, 100, null ), (2, 100, null)] Window 1: [(4, 100, 'error'), (5, 100, null)] Window 2: [(7,
* 102, 'error')]
*
...
...
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SlidingTimeWindowAccessStrategy.java
浏览文件 @
6ff4d7e5
...
...
@@ -29,29 +29,30 @@ import java.time.ZoneId;
/**
* Used in {@link UDTF#beforeStart(UDFParameters, UDTFConfigurations)}.
*
<p>
* When the access strategy of a UDTF is set to an instance of this class, the method {@link
*
*
<p>
When the access strategy of a UDTF is set to an instance of this class, the method {@link
* UDTF#transform(RowWindow, PointCollector)} of the UDTF will be called to transform the original
* data. You need to override the method in your own UDTF class.
*
<p>
* Sliding time window is a kind of time-based window. To partition the raw query data set into
*
*
<p>
Sliding time window is a kind of time-based window. To partition the raw query data set into
* sliding time windows, you need to give the following 4 parameters:
* <p>
* <li> display window begin: determines the start time of the first window
* <li> display window end: if the start time of current window + sliding step > display window
* end, then current window is the last window that your UDTF can process
* <li> time interval: determines the time range of a window
* <li> sliding step: the start time of the next window = the start time of current window +
* sliding step
* <p>
* Each call of the method {@link UDTF#transform(RowWindow, PointCollector)} processes one time
* window and can generate any number of data points. Note that the transform method will still be
* called when there is no data point in a window. Note that the time range of the last few windows
* may be less than the specified time interval.
* <p>
* Sample code:
* <p>Style 1:
* <pre>{@code
* <li>display window begin: determines the start time of the first window
* <li>display window end: if the start time of current window + sliding step > display window end,
* then current window is the last window that your UDTF can process
* <li>time interval: determines the time range of a window
* <li>sliding step: the start time of the next window = the start time of current window + sliding
* step
*
* <p>Each call of the method {@link UDTF#transform(RowWindow, PointCollector)} processes one
* time window and can generate any number of data points. Note that the transform method will
* still be called when there is no data point in a window. Note that the time range of the last
* few windows may be less than the specified time interval.
*
* <p>Sample code:
*
* <p>Style 1:
*
* <pre>{@code
* @Override
* public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) {
* configurations.setAccessStrategy(new SlidingTimeWindowAccessStrategy(
...
...
@@ -59,9 +60,12 @@ import java.time.ZoneId;
* parameters.getLong(50), // sliding step
* parameters.getLong(0), // display window begin
* parameters.getLong(10000))); // display window end
* }
* }</pre>
* <p>Style 2 (deprecated since v0.14):
* <pre>{@code
*
* <p>Style 2 (deprecated since v0.14):
*
* <pre>{@code
* @Override
* public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) {
* configurations.setAccessStrategy(new SlidingTimeWindowAccessStrategy(
...
...
@@ -69,6 +73,7 @@ import java.time.ZoneId;
* parameters.getLong("7d"), // sliding step
* parameters.getLong("2020-01-01T00:00:00"), // display window begin
* parameters.getLong("2020-06-01T00:00:00"))); // display window end
* }
* }</pre>
*
* @see UDTF
...
...
@@ -95,6 +100,7 @@ public class SlidingTimeWindowAccessStrategy implements AccessStrategy {
* @param displayWindowEndString display window end in string. format: 2011-12-03T10:15:30 or
* 2011-12-03T10:15:30+01:00.
* @throws UnsupportedOperationException deprecated since v0.14
* @deprecated use {@link #SlidingTimeWindowAccessStrategy(long, long, long, long)} instead.
*/
@Deprecated
public
SlidingTimeWindowAccessStrategy
(
...
...
@@ -117,6 +123,7 @@ public class SlidingTimeWindowAccessStrategy implements AccessStrategy {
* @param slidingStepString sliding step in string. examples: 12d8m9ns, 1y1mo, etc. supported
* units: y, mo, w, d, h, m, s, ms, us, ns.
* @throws UnsupportedOperationException deprecated since v0.14
* @deprecated use {@link #SlidingTimeWindowAccessStrategy(long, long)} instead.
*/
@Deprecated
public
SlidingTimeWindowAccessStrategy
(
String
timeIntervalString
,
String
slidingStepString
)
{
...
...
@@ -139,6 +146,8 @@ public class SlidingTimeWindowAccessStrategy implements AccessStrategy {
}
/**
* Display window begin and display window end will be set by the parameters.
*
* @param timeInterval 0 < timeInterval
* @param slidingStep 0 < slidingStep
* @param displayWindowBegin displayWindowBegin < displayWindowEnd
...
...
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/StateWindowAccessStrategy.java
浏览文件 @
6ff4d7e5
...
...
@@ -30,6 +30,8 @@ public class StateWindowAccessStrategy implements AccessStrategy {
private
ZoneId
zoneId
;
/**
* Display window begin, display window end and delta will be set by the parameters.
*
* @param displayWindowBegin displayWindowBegin < displayWindowEnd
* @param displayWindowEnd displayWindowBegin < displayWindowEnd
* @param delta delta >= 0
...
...
@@ -41,6 +43,9 @@ public class StateWindowAccessStrategy implements AccessStrategy {
}
/**
* Display window begin and display window end will be set by the parameters. delta default equals
* 0.
*
* @param displayWindowBegin displayWindowBegin < displayWindowEnd
* @param displayWindowEnd displayWindowBegin < displayWindowEnd
*/
...
...
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/type/Binary.java
浏览文件 @
6ff4d7e5
...
...
@@ -16,10 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
package
org.apache.iotdb.udf.api.type
;
import
java.io.Serializable
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Arrays
;
/**
...
...
@@ -30,7 +32,7 @@ public class Binary implements Comparable<Binary>, Serializable {
private
static
final
long
serialVersionUID
=
1250049718612917815L
;
public
static
final
String
STRING_ENCODING
=
"UTF-8"
;
public
static
final
Charset
STRING_CHARSET
=
Charset
.
forName
(
STRING_ENCODING
)
;
public
static
final
Charset
STRING_CHARSET
=
StandardCharsets
.
UTF_8
;
private
final
byte
[]
values
;
...
...
iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/type/Type.java
浏览文件 @
6ff4d7e5
...
...
@@ -16,35 +16,36 @@
* specific language governing permissions and limitations
* under the License.
*/
package
org.apache.iotdb.udf.api.type
;
/** A substitution class for TsDataType in UDF APIs. */
public
enum
Type
{
/*
*
BOOLEAN */
/* BOOLEAN */
BOOLEAN
((
byte
)
0
),
/*
*
INT32 */
/* INT32 */
INT32
((
byte
)
1
),
/*
*
INT64 */
/* INT64 */
INT64
((
byte
)
2
),
/*
*
FLOAT */
/* FLOAT */
FLOAT
((
byte
)
3
),
/*
*
DOUBLE */
/* DOUBLE */
DOUBLE
((
byte
)
4
),
/*
*
TEXT */
/* TEXT */
TEXT
((
byte
)
5
);
private
final
byte
t
ype
;
private
final
byte
dataT
ype
;
Type
(
byte
type
)
{
this
.
t
ype
=
type
;
this
.
dataT
ype
=
type
;
}
public
byte
getType
()
{
return
t
ype
;
return
dataT
ype
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录