This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 6ff4d7e52a1 [IOTDB-6025] iotdb-api: fix bugs & smells reported by
SonarCloud (#10318)
6ff4d7e52a1 is described below
commit 6ff4d7e52a1858c402cd4ae8a9216bcb9b9c6f60
Author: Itami Sho <[email protected]>
AuthorDate: Mon Jun 26 17:51:29 2023 +0800
[IOTDB-6025] iotdb-api: fix bugs & smells reported by SonarCloud (#10318)
---
.../iotdb/external/api/IPropertiesLoader.java | 5 +-
.../external/api/thrift/JudgableServerContext.java | 9 +++-
.../external/api/thrift/ServerContextFactory.java | 1 +
.../java/org/apache/iotdb/pipe/api/access/Row.java | 11 ++---
.../event/dml/insertion/TabletInsertionEvent.java | 8 ++--
.../event/dml/insertion/TsFileInsertionEvent.java | 2 +-
.../org/apache/iotdb/pipe/api/type/Binary.java | 3 +-
.../java/org/apache/iotdb/pipe/api/type/Type.java | 18 ++++----
.../api/SubscriptionConfiguration.java | 4 +-
.../iotdb/subscription/api/consumer/Consumer.java | 12 ++++-
.../api/strategy/SubscriptionStrategy.java | 6 ++-
.../api/strategy/disorder/IntolerableStrategy.java | 4 +-
.../java/org/apache/iotdb/trigger/api/Trigger.java | 2 +
.../iotdb/trigger/api/enums/FailureStrategy.java | 1 +
.../main/java/org/apache/iotdb/udf/api/UDF.java | 8 +++-
.../main/java/org/apache/iotdb/udf/api/UDTF.java | 19 +++++---
.../java/org/apache/iotdb/udf/api/access/Row.java | 10 +++-
.../api/customizer/config/UDTFConfigurations.java | 10 ++--
.../parameter/UDFParameterValidator.java | 4 ++
.../api/customizer/strategy/AccessStrategy.java | 36 ++++++++++++---
.../strategy/MappableRowByRowAccessStrategy.java | 20 ++++----
.../strategy/RowByRowAccessStrategy.java | 14 +++---
.../strategy/SessionTimeWindowAccessStrategy.java | 2 +
.../strategy/SlidingSizeWindowAccessStrategy.java | 16 ++++---
.../strategy/SlidingTimeWindowAccessStrategy.java | 53 +++++++++++++---------
.../strategy/StateWindowAccessStrategy.java | 5 ++
.../java/org/apache/iotdb/udf/api/type/Binary.java | 4 +-
.../java/org/apache/iotdb/udf/api/type/Type.java | 19 ++++----
28 files changed, 203 insertions(+), 103 deletions(-)
diff --git
a/iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/IPropertiesLoader.java
b/iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/IPropertiesLoader.java
index a19a10ec2d6..582b4b7ca00 100644
---
a/iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/IPropertiesLoader.java
+++
b/iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/IPropertiesLoader.java
@@ -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.
*/
diff --git
a/iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/thrift/JudgableServerContext.java
b/iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/thrift/JudgableServerContext.java
index a8020da2679..89a94dd7534 100644
---
a/iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/thrift/JudgableServerContext.java
+++
b/iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/thrift/JudgableServerContext.java
@@ -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;
- };
+ }
}
diff --git
a/iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/thrift/ServerContextFactory.java
b/iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/thrift/ServerContextFactory.java
index 048a93ca8f2..adf36dee499 100644
---
a/iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/thrift/ServerContextFactory.java
+++
b/iotdb-api/external-api/src/main/java/org/apache/iotdb/external/api/thrift/ServerContextFactory.java
@@ -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;
diff --git
a/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/access/Row.java
b/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/access/Row.java
index c27ed608e2e..333502da43b 100644
--- a/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/access/Row.java
+++ b/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/access/Row.java
@@ -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
*/
diff --git
a/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/event/dml/insertion/TabletInsertionEvent.java
b/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/event/dml/insertion/TabletInsertionEvent.java
index 09b129a9cc4..4f3ecad35e4 100644
---
a/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/event/dml/insertion/TabletInsertionEvent.java
+++
b/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/event/dml/insertion/TabletInsertionEvent.java
@@ -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);
}
diff --git
a/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/event/dml/insertion/TsFileInsertionEvent.java
b/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/event/dml/insertion/TsFileInsertionEvent.java
index a3e44fd55ed..298bf803b54 100644
---
a/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/event/dml/insertion/TsFileInsertionEvent.java
+++
b/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/event/dml/insertion/TsFileInsertionEvent.java
@@ -30,7 +30,7 @@ public interface TsFileInsertionEvent extends Event {
/**
* The method is used to convert the TsFileInsertionEvent into several
TabletInsertionEvents.
*
- * @return the list of TsFileInsertionEvent
+ * @return {@code Iterable<TabletInsertionEvent>} the list of
TabletInsertionEvent
*/
Iterable<TabletInsertionEvent> toTabletInsertionEvents();
}
diff --git
a/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/type/Binary.java
b/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/type/Binary.java
index bdf871bf849..3a878f58a62 100644
---
a/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/type/Binary.java
+++
b/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/type/Binary.java
@@ -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;
diff --git
a/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/type/Type.java
b/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/type/Type.java
index 362355bcbca..85a4390eae4 100644
--- a/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/type/Type.java
+++ b/iotdb-api/pipe-api/src/main/java/org/apache/iotdb/pipe/api/type/Type.java
@@ -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 type;
+ private final byte dataType;
Type(byte type) {
- this.type = type;
+ this.dataType = type;
}
public byte getType() {
- return type;
+ return dataType;
}
}
diff --git
a/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/SubscriptionConfiguration.java
b/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/SubscriptionConfiguration.java
index 836202d0cdc..3372f9e2804 100644
---
a/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/SubscriptionConfiguration.java
+++
b/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/SubscriptionConfiguration.java
@@ -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) {
diff --git
a/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/consumer/Consumer.java
b/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/consumer/Consumer.java
index bd042d9927c..7ae0cf78285 100644
---
a/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/consumer/Consumer.java
+++
b/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/consumer/Consumer.java
@@ -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;
/**
diff --git
a/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/strategy/SubscriptionStrategy.java
b/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/strategy/SubscriptionStrategy.java
index 0fbfe56dad7..57352c95818 100644
---
a/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/strategy/SubscriptionStrategy.java
+++
b/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/strategy/SubscriptionStrategy.java
@@ -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;
}
diff --git
a/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/strategy/disorder/IntolerableStrategy.java
b/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/strategy/disorder/IntolerableStrategy.java
index e358974b9e2..6ea3ccf52af 100644
---
a/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/strategy/disorder/IntolerableStrategy.java
+++
b/iotdb-api/subscription-api/src/main/java/org/apache/iotdb/subscription/api/strategy/disorder/IntolerableStrategy.java
@@ -28,5 +28,7 @@ public class IntolerableStrategy extends
DisorderHandlingStrategy {
}
@Override
- public void check() throws SubscriptionStrategyNotValidException {}
+ public void check() throws SubscriptionStrategyNotValidException {
+ // do nothing
+ }
}
diff --git
a/iotdb-api/trigger-api/src/main/java/org/apache/iotdb/trigger/api/Trigger.java
b/iotdb-api/trigger-api/src/main/java/org/apache/iotdb/trigger/api/Trigger.java
index eb8f7f0a610..e693dcca2e6 100644
---
a/iotdb-api/trigger-api/src/main/java/org/apache/iotdb/trigger/api/Trigger.java
+++
b/iotdb-api/trigger-api/src/main/java/org/apache/iotdb/trigger/api/Trigger.java
@@ -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}.
diff --git
a/iotdb-api/trigger-api/src/main/java/org/apache/iotdb/trigger/api/enums/FailureStrategy.java
b/iotdb-api/trigger-api/src/main/java/org/apache/iotdb/trigger/api/enums/FailureStrategy.java
index 6f3faf342ed..7f32f7c1e88 100644
---
a/iotdb-api/trigger-api/src/main/java/org/apache/iotdb/trigger/api/enums/FailureStrategy.java
+++
b/iotdb-api/trigger-api/src/main/java/org/apache/iotdb/trigger/api/enums/FailureStrategy.java
@@ -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;
diff --git a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/UDF.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/UDF.java
index 10e5d0da242..03860c558b1 100644
--- a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/UDF.java
+++ b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/UDF.java
@@ -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
+ }
}
diff --git a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/UDTF.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/UDTF.java
index b5cf68c0464..c10fa516a66 100644
--- a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/UDTF.java
+++ b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/UDTF.java
@@ -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
+ }
}
diff --git
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/access/Row.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/access/Row.java
index 118dd9c7794..ea04fe00858 100644
--- a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/access/Row.java
+++ b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/access/Row.java
@@ -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
*/
diff --git
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/config/UDTFConfigurations.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/config/UDTFConfigurations.java
index 00e62121d80..6ca701b2ca8 100644
---
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/config/UDTFConfigurations.java
+++
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/config/UDTFConfigurations.java
@@ -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 {
diff --git
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/parameter/UDFParameterValidator.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/parameter/UDFParameterValidator.java
index 1f0e0a136c3..c7ea934f9e6 100644
---
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/parameter/UDFParameterValidator.java
+++
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/parameter/UDFParameterValidator.java
@@ -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
diff --git
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/AccessStrategy.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/AccessStrategy.java
index a6ff2345366..70d688bfd51 100644
---
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/AccessStrategy.java
+++
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/AccessStrategy.java
@@ -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
}
diff --git
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/MappableRowByRowAccessStrategy.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/MappableRowByRowAccessStrategy.java
index 4a87f657239..f4a1c2c3787 100644
---
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/MappableRowByRowAccessStrategy.java
+++
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/MappableRowByRowAccessStrategy.java
@@ -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
diff --git
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/RowByRowAccessStrategy.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/RowByRowAccessStrategy.java
index 2b11e6eb773..dadc743964d 100644
---
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/RowByRowAccessStrategy.java
+++
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/RowByRowAccessStrategy.java
@@ -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
diff --git
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SessionTimeWindowAccessStrategy.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SessionTimeWindowAccessStrategy.java
index 2b2478ad558..70cf394dfec 100644
---
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SessionTimeWindowAccessStrategy.java
+++
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SessionTimeWindowAccessStrategy.java
@@ -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
diff --git
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SlidingSizeWindowAccessStrategy.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SlidingSizeWindowAccessStrategy.java
index 63b363d4375..a3e67861163 100644
---
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SlidingSizeWindowAccessStrategy.java
+++
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SlidingSizeWindowAccessStrategy.java
@@ -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')]
*
diff --git
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SlidingTimeWindowAccessStrategy.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SlidingTimeWindowAccessStrategy.java
index dba7be139a7..19eb5df9854 100644
---
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SlidingTimeWindowAccessStrategy.java
+++
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/SlidingTimeWindowAccessStrategy.java
@@ -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
diff --git
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/StateWindowAccessStrategy.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/StateWindowAccessStrategy.java
index 73c89143ef8..f749d3c3a7c 100644
---
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/StateWindowAccessStrategy.java
+++
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/customizer/strategy/StateWindowAccessStrategy.java
@@ -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
*/
diff --git
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/type/Binary.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/type/Binary.java
index 991646dea18..e2b3ef85701 100644
--- a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/type/Binary.java
+++ b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/type/Binary.java
@@ -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;
diff --git
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/type/Type.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/type/Type.java
index cd4a096680a..4a595b60518 100644
--- a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/type/Type.java
+++ b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/type/Type.java
@@ -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 type;
+ private final byte dataType;
Type(byte type) {
- this.type = type;
+ this.dataType = type;
}
public byte getType() {
- return type;
+ return dataType;
}
}