From 66455dbc2466b5dcc20f5bc3eab56964668f446a Mon Sep 17 00:00:00 2001 From: Sh-Zh-7 Date: Fri, 7 Jun 2024 15:51:09 +0800 Subject: [PATCH] Throw `IndexOutOfBound` exception in row implementation. --- .../apache/iotdb/udf/api/utils/RowImpl.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/utils/RowImpl.java b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/utils/RowImpl.java index e0ca3a53fc65..d7d3a8848690 100644 --- a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/utils/RowImpl.java +++ b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/utils/RowImpl.java @@ -45,36 +45,57 @@ public long getTime() { @Override public int getInt(int columnIndex) { + if (columnIndex >= size()) { + throw new IndexOutOfBoundsException("Index out of bound error!"); + } return (int) rowRecord[columnIndex]; } @Override public long getLong(int columnIndex) { + if (columnIndex >= size()) { + throw new IndexOutOfBoundsException("Index out of bound error!"); + } return (long) rowRecord[columnIndex]; } @Override public float getFloat(int columnIndex) { + if (columnIndex >= size()) { + throw new IndexOutOfBoundsException("Index out of bound error!"); + } return (float) rowRecord[columnIndex]; } @Override public double getDouble(int columnIndex) { + if (columnIndex >= size()) { + throw new IndexOutOfBoundsException("Index out of bound error!"); + } return (double) rowRecord[columnIndex]; } @Override public boolean getBoolean(int columnIndex) { + if (columnIndex >= size()) { + throw new IndexOutOfBoundsException("Index out of bound error!"); + } return (boolean) rowRecord[columnIndex]; } @Override public Binary getBinary(int columnIndex) { + if (columnIndex >= size()) { + throw new IndexOutOfBoundsException("Index out of bound error!"); + } return transformToUDFBinary((org.apache.tsfile.utils.Binary) rowRecord[columnIndex]); } @Override public String getString(int columnIndex) { + if (columnIndex >= size()) { + throw new IndexOutOfBoundsException("Index out of bound error!"); + } return rowRecord[columnIndex].toString(); }