You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by kx...@apache.org on 2023/08/02 14:54:17 UTC
[doris] 05/06: [improvement](jdbc) add `timestamp` put to `datev2` (#21680)
This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
commit cd7ef61b71b739191ecf5dfa9bae97d0b06eef03
Author: lsy3993 <11...@users.noreply.github.com>
AuthorDate: Wed Jul 26 09:10:34 2023 +0800
[improvement](jdbc) add `timestamp` put to `datev2` (#21680)
---
.../java/org/apache/doris/jdbc/JdbcExecutor.java | 25 ++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/JdbcExecutor.java b/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/JdbcExecutor.java
index e2d720d27d..122392bdaa 100644
--- a/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/JdbcExecutor.java
+++ b/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/JdbcExecutor.java
@@ -1138,6 +1138,29 @@ public class JdbcExecutor {
}
}
+ private void timestampPutToInt(Object[] column, boolean isNullable, int numRows, long nullMapAddr,
+ long columnAddr, int startRowForNullable) {
+ if (isNullable) {
+ for (int i = startRowForNullable; i < numRows; i++) {
+ if (column[i] == null) {
+ UdfUtils.UNSAFE.putByte(nullMapAddr + i, (byte) 1);
+ } else {
+ LocalDateTime date = ((java.sql.Timestamp) column[i]).toLocalDateTime();
+ UdfUtils.UNSAFE.putInt(columnAddr + (i * 4L),
+ UdfUtils.convertToDateV2(date.getYear(), date.getMonthValue(),
+ date.getDayOfMonth()));
+ }
+ }
+ } else {
+ for (int i = 0; i < numRows; i++) {
+ LocalDateTime date = ((java.sql.Timestamp) column[i]).toLocalDateTime();
+ UdfUtils.UNSAFE.putLong(columnAddr + (i * 4L),
+ UdfUtils.convertToDateV2(date.getYear(), date.getMonthValue(),
+ date.getDayOfMonth()));
+ }
+ }
+ }
+
public void copyBatchDateV2Result(Object columnObj, boolean isNullable, int numRows, long nullMapAddr,
long columnAddr) {
Object[] column = (Object[]) columnObj;
@@ -1152,6 +1175,8 @@ public class JdbcExecutor {
localDatePutToInt(column, isNullable, numRows, nullMapAddr, columnAddr, firstNotNullIndex);
} else if (column[firstNotNullIndex] instanceof Date) {
datePutToInt(column, isNullable, numRows, nullMapAddr, columnAddr, firstNotNullIndex);
+ } else if (column[firstNotNullIndex] instanceof Timestamp) {
+ timestampPutToInt(column, isNullable, numRows, nullMapAddr, columnAddr, firstNotNullIndex);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org