Skip to content

Commit c33a319

Browse files
authored
Merge pull request #241 from taosdata/3.0
merge to main
2 parents dee0528 + d348fd6 commit c33a319

49 files changed

Lines changed: 3038 additions & 1662 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.taosdata.jdbc</groupId>
55
<artifactId>taos-jdbcdriver</artifactId>
6-
<version>3.5.4-SNAPSHOT</version>
6+
<version>3.6.0</version>
77

88
<packaging>jar</packaging>
99
<name>JDBCDriver</name>
@@ -75,6 +75,20 @@
7575
<version>${junit.version}</version>
7676
<scope>test</scope>
7777
</dependency>
78+
79+
<!-- <dependency>-->
80+
<!-- <groupId>org.slf4j</groupId>-->
81+
<!-- <artifactId>slf4j-api</artifactId>-->
82+
<!-- <version>1.7.25</version>-->
83+
<!-- </dependency>-->
84+
85+
<!-- &lt;!&ndash; logback依赖 &ndash;&gt;-->
86+
<!-- <dependency>-->
87+
<!-- <groupId>ch.qos.logback</groupId>-->
88+
<!-- <artifactId>logback-classic</artifactId>-->
89+
<!-- <version>1.2.3</version>-->
90+
<!-- </dependency>-->
91+
7892
</dependencies>
7993

8094
<build>

src/main/java/com/taosdata/jdbc/AbstractDriver.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
import com.taosdata.jdbc.enums.WSFunction;
88
import com.taosdata.jdbc.rs.ConnectionParam;
99
import com.taosdata.jdbc.utils.JsonUtil;
10-
import com.taosdata.jdbc.utils.ReqId;
1110
import com.taosdata.jdbc.utils.StringUtils;
12-
import com.taosdata.jdbc.utils.Utils;
13-
import com.taosdata.jdbc.ws.*;
11+
import com.taosdata.jdbc.ws.FutureResponse;
12+
import com.taosdata.jdbc.ws.InFlightRequest;
13+
import com.taosdata.jdbc.ws.Transport;
14+
import com.taosdata.jdbc.ws.WSConnection;
1415
import com.taosdata.jdbc.ws.entity.*;
1516
import org.slf4j.LoggerFactory;
1617

src/main/java/com/taosdata/jdbc/AbstractResultSet.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.taosdata.jdbc;
22

3+
import com.taosdata.jdbc.utils.Utils;
4+
35
import java.io.InputStream;
46
import java.io.Reader;
57
import java.math.BigDecimal;
@@ -13,9 +15,6 @@ public abstract class AbstractResultSet extends WrapperImpl implements ResultSet
1315
private int fetchSize;
1416
protected boolean wasNull;
1517
protected int timestampPrecision;
16-
17-
private static final ForkJoinPool forkJoinPool = new ForkJoinPool();
18-
1918
public void setTimestampPrecision(int timestampPrecision) {
2019
this.timestampPrecision = timestampPrecision;
2120
}
@@ -31,7 +30,7 @@ protected void checkAvailability(int columnIndex, int bounds) throws SQLExceptio
3130

3231

3332
protected ForkJoinPool getForkJoinPool(){
34-
return forkJoinPool;
33+
return Utils.getForkJoinPool();
3534
}
3635

3736
@Override

src/main/java/com/taosdata/jdbc/BlockData.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package com.taosdata.jdbc;
22

33
import com.taosdata.jdbc.rs.RestfulResultSet;
4-
import com.taosdata.jdbc.utils.DataTypeConverUtil;
54
import com.taosdata.jdbc.utils.DateTimeUtils;
5+
import com.taosdata.jdbc.utils.DecimalUtil;
66

7+
import java.math.BigDecimal;
78
import java.nio.ByteBuffer;
89
import java.sql.SQLException;
910
import java.time.Instant;
@@ -68,6 +69,7 @@ public void handleData() {
6869
for (int i = 0; i < columns; i++) {
6970
List<Object> col = new ArrayList<>(numOfRows);
7071
int type = fields.get(i).getTaosType();
72+
int scale = fields.get(i).getScale();
7173
switch (type) {
7274
case TSDB_DATA_TYPE_BOOL:
7375
case TSDB_DATA_TYPE_TINYINT:
@@ -218,6 +220,24 @@ public void handleData() {
218220
}
219221
break;
220222
}
223+
case TSDB_DATA_TYPE_DECIMAL128:
224+
case TSDB_DATA_TYPE_DECIMAL64:
225+
int dataLen = type == TSDB_DATA_TYPE_DECIMAL128 ? 16 : 8;
226+
length = bitMapOffset;
227+
byte[] tmp = new byte[bitMapOffset];
228+
buffer.get(tmp);
229+
for (int j = 0; j < numOfRows; j++) {
230+
byte[] tb = new byte[dataLen];
231+
buffer.get(tb);
232+
233+
if (isNull(tmp, j)) {
234+
col.add(null);
235+
} else {
236+
BigDecimal t = DecimalUtil.getBigDecimal(tb, scale);
237+
col.add(t);
238+
}
239+
}
240+
break;
221241
default:
222242
// unknown type, do nothing
223243
col.add(null);

src/main/java/com/taosdata/jdbc/TSDBConstants.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ public abstract class TSDBConstants {
5757
public static final int TSDB_DATA_TYPE_UBIGINT = 14; //unsigned bigint
5858
public static final int TSDB_DATA_TYPE_JSON = 15; //json
5959
public static final int TSDB_DATA_TYPE_VARBINARY = 16; //varbinary
60+
public static final int TSDB_DATA_TYPE_DECIMAL128 = 17; //decimal128
61+
public static final int TSDB_DATA_TYPE_BLOB = 18; //blob
62+
public static final int TSDB_DATA_TYPE_MEDIUMBLOB = 19; //
6063
public static final int TSDB_DATA_TYPE_GEOMETRY = 20; //geometry
64+
public static final int TSDB_DATA_TYPE_DECIMAL64 = 21; //decimal64
6165

6266
// nchar column max length
6367
public static final int maxFieldSize = 16 * 1024;
@@ -77,6 +81,10 @@ public abstract class TSDBConstants {
7781
public static final int DOUBLE_PRECISION = 22;
7882
public static final int TIMESTAMP_MS_PRECISION = 23;
7983
public static final int TIMESTAMP_US_PRECISION = 26;
84+
85+
public static final int DECIMAL128_PRECISION = 38;
86+
public static final int DECIMAL64_PRECISION = 18;
87+
8088
// scale for data types, this is used for metadata
8189
public static final int FLOAT_SCALE = 31;
8290
public static final int DOUBLE_SCALE = 31;

src/main/java/com/taosdata/jdbc/TSDBDriver.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ public class TSDBDriver extends AbstractDriver {
121121
public static final String PROPERTY_KEY_DISABLE_SSL_CERT_VALIDATION = "disableSSLCertValidation";
122122
public static final String PROPERTY_KEY_APP_IP = "app_ip";
123123
public static final String PROPERTY_KEY_APP_NAME = "app_name";
124+
public static final String PROPERTY_KEY_COPY_DATA = "copyData";
125+
public static final String PROPERTY_KEY_BATCH_SIZE_BY_ROW = "batchSizeByRow";
126+
public static final String PROPERTY_KEY_CACHE_SIZE_BY_ROW = "cacheSizeByRow";
127+
public static final String PROPERTY_KEY_BACKEND_WRITE_THREAD_NUM = "backendWriteThreadNum";
128+
public static final String PROPERTY_KEY_STRICT_CHECK = "strictCheck";
129+
public static final String PROPERTY_KEY_RETRY_TIMES = "retryTimes";
130+
public static final String PROPERTY_KEY_ASYNC_WRITE = "asyncWrite";
124131

125132

126133
/**

src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public class TSDBErrorNumbers {
6262
public static final int ERROR_TMQ_SEEK_OFFSET = 0x2379; // consumer create error
6363
public static final int ERROR_TMQ_VGROUP_NOT_FOUND = 0x237a; // consumer create error
6464

65+
66+
public static final int ERROR_FW_WRITE_ERROR = 0x2390; // fast writer write error
67+
6568
private static final Set<Integer> errorNumbers = new HashSet<>();
6669

6770
static {

src/main/java/com/taosdata/jdbc/TSDBResultSetMetaData.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.taosdata.jdbc;
22

33
import com.taosdata.jdbc.enums.DataType;
4-
import com.taosdata.jdbc.utils.DataTypeUtil;
54

65
import java.sql.ResultSetMetaData;
76
import java.sql.SQLException;
@@ -156,7 +155,7 @@ public boolean isDefinitelyWritable(int column) throws SQLException {
156155
}
157156

158157
public String getColumnClassName(int column) throws SQLException {
159-
int columnType = getColumnType(column);
160-
return DataTypeUtil.getColumnClassName(columnType);
158+
int type = this.colMetaDataList.get(column - 1).getColType();
159+
return DataType.convertTaosType2DataType(type).getClassName();
161160
}
162161
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.taosdata.jdbc.common;
2+
3+
public class Column {
4+
private final Object data;
5+
// taos data type
6+
private final int type;
7+
8+
public Object getData() {
9+
return data;
10+
}
11+
12+
public int getType() {
13+
return type;
14+
}
15+
16+
public int getIndex() {
17+
return index;
18+
}
19+
20+
private final int index;
21+
22+
public Column(Object data, int type, int index) {
23+
this.data = data;
24+
this.type = type;
25+
this.index = index;
26+
}
27+
}

0 commit comments

Comments
 (0)