Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
65e904b7
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
65e904b7
编写于
11月 18, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-225] fix memory leaks.
上级
07bd21e6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
189 deletion
+44
-189
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java
...c/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java
+44
-189
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java
浏览文件 @
65e904b7
...
@@ -224,11 +224,19 @@ public class TSDBResultSetBlockData {
...
@@ -224,11 +224,19 @@ public class TSDBResultSetBlockData {
}
}
private
boolean
isBinaryNull
(
byte
[]
val
,
int
length
)
{
private
boolean
isBinaryNull
(
byte
[]
val
,
int
length
)
{
return
val
[
0
]
==
0xFF
&&
length
==
1
;
if
(
length
!=
1
)
{
return
false
;
}
return
val
[
0
]
==
0xFF
;
}
}
private
boolean
isNcharNull
(
byte
[]
val
,
int
length
)
{
private
boolean
isNcharNull
(
byte
[]
val
,
int
length
)
{
return
(
val
[
0
]
&
val
[
1
]
&
val
[
2
]
&
val
[
3
])
==
0xFF
&&
length
==
4
;
if
(
length
!=
4
)
{
return
false
;
}
return
(
val
[
0
]
&
val
[
1
]
&
val
[
2
]
&
val
[
3
])
==
0xFF
;
}
}
public
int
getInt
(
int
col
)
{
public
int
getInt
(
int
col
)
{
...
@@ -304,109 +312,32 @@ public class TSDBResultSetBlockData {
...
@@ -304,109 +312,32 @@ public class TSDBResultSetBlockData {
}
}
public
long
getLong
(
int
col
)
throws
SQLException
{
public
long
getLong
(
int
col
)
throws
SQLException
{
int
fieldSize
=
this
.
columnMetaDataList
.
get
(
col
).
getColSize
();
Object
obj
=
get
(
col
);
ByteBuffer
bb
=
(
ByteBuffer
)
this
.
colData
.
get
(
col
);
if
(
obj
==
null
)
{
return
0
;
switch
(
this
.
columnMetaDataList
.
get
(
col
).
getColType
())
{
case
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
:
{
byte
val
=
bb
.
get
(
this
.
rowIndex
);
if
(
isBooleanNull
(
val
))
{
return
0
;
}
return
(
val
==
0x0
)
?
0
:
1
;
}
case
TSDBConstants
.
TSDB_DATA_TYPE_TINYINT
:
{
byte
val
=
bb
.
get
(
this
.
rowIndex
);
if
(
isTinyIntNull
(
val
))
{
return
0
;
}
return
val
;
}
case
TSDBConstants
.
TSDB_DATA_TYPE_SMALLINT
:
{
ShortBuffer
sb
=
(
ShortBuffer
)
this
.
colData
.
get
(
col
);
short
val
=
sb
.
get
(
this
.
rowIndex
);
if
(
isSmallIntNull
(
val
))
{
return
0
;
}
return
val
;
}
}
int
type
=
this
.
columnMetaDataList
.
get
(
col
).
getColType
();
switch
(
type
)
{
case
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
:
case
TSDBConstants
.
TSDB_DATA_TYPE_TINYINT
:
case
TSDBConstants
.
TSDB_DATA_TYPE_SMALLINT
:
case
TSDBConstants
.
TSDB_DATA_TYPE_INT
:
{
case
TSDBConstants
.
TSDB_DATA_TYPE_INT
:
{
IntBuffer
ib
=
(
IntBuffer
)
this
.
colData
.
get
(
col
);
return
(
int
)
obj
;
int
val
=
ib
.
get
(
this
.
rowIndex
);
if
(
isIntNull
(
val
))
{
return
0
;
}
return
val
;
}
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
{
LongBuffer
lb
=
(
LongBuffer
)
this
.
colData
.
get
(
col
);
long
val
=
lb
.
get
(
this
.
rowIndex
);
if
(
isBigIntNull
(
val
))
{
return
0
;
}
return
(
long
)
val
;
}
}
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
{
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
{
FloatBuffer
fb
=
(
FloatBuffer
)
this
.
colData
.
get
(
col
);
return
(
long
)
obj
;
float
val
=
fb
.
get
(
this
.
rowIndex
);
if
(
isFloatNull
(
val
))
{
return
0
;
}
return
(
long
)
val
;
}
}
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
case
TSDBConstants
.
TSDB_DATA_TYPE_DOUBLE
:
{
case
TSDBConstants
.
TSDB_DATA_TYPE_DOUBLE
:
{
DoubleBuffer
lb
=
(
DoubleBuffer
)
this
.
colData
.
get
(
col
);
return
((
Double
)
obj
).
longValue
();
double
val
=
lb
.
get
(
this
.
rowIndex
);
if
(
isDoubleNull
(
val
))
{
return
0
;
}
return
(
long
)
val
;
}
}
case
TSDBConstants
.
TSDB_DATA_TYPE_NCHAR
:
case
TSDBConstants
.
TSDB_DATA_TYPE_BINARY
:
{
case
TSDBConstants
.
TSDB_DATA_TYPE_BINARY
:
{
bb
.
position
(
fieldSize
*
this
.
rowIndex
);
return
Long
.
parseLong
((
String
)
obj
);
int
length
=
bb
.
getShort
();
byte
[]
dest
=
new
byte
[
length
];
bb
.
get
(
dest
,
0
,
length
);
if
(
isBinaryNull
(
dest
,
length
))
{
return
0
;
}
return
Long
.
parseLong
(
new
String
(
dest
));
}
case
TSDBConstants
.
TSDB_DATA_TYPE_NCHAR
:
{
bb
.
position
(
fieldSize
*
this
.
rowIndex
);
int
length
=
bb
.
getShort
();
byte
[]
dest
=
new
byte
[
length
];
bb
.
get
(
dest
,
0
,
length
);
if
(
isNcharNull
(
dest
,
length
))
{
return
0
;
}
try
{
return
Long
.
parseLong
(
new
String
(
dest
,
TaosGlobalConfig
.
getCharset
()));
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
...
@@ -424,109 +355,32 @@ public class TSDBResultSetBlockData {
...
@@ -424,109 +355,32 @@ public class TSDBResultSetBlockData {
}
}
public
double
getDouble
(
int
col
)
{
public
double
getDouble
(
int
col
)
{
int
fieldSize
=
this
.
columnMetaDataList
.
get
(
col
).
getColSize
();
Object
obj
=
get
(
col
);
ByteBuffer
bb
=
(
ByteBuffer
)
this
.
colData
.
get
(
col
);
if
(
obj
==
null
)
{
return
0
;
switch
(
this
.
columnMetaDataList
.
get
(
col
).
getColType
())
{
case
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
:
{
byte
val
=
bb
.
get
(
this
.
rowIndex
);
if
(
isBooleanNull
(
val
))
{
return
0
;
}
return
(
val
==
0x0
)
?
0
:
1
;
}
case
TSDBConstants
.
TSDB_DATA_TYPE_TINYINT
:
{
byte
val
=
bb
.
get
(
this
.
rowIndex
);
if
(
isTinyIntNull
(
val
))
{
return
0
;
}
return
val
;
}
case
TSDBConstants
.
TSDB_DATA_TYPE_SMALLINT
:
{
ShortBuffer
sb
=
(
ShortBuffer
)
this
.
colData
.
get
(
col
);
short
val
=
sb
.
get
(
this
.
rowIndex
);
if
(
isSmallIntNull
(
val
))
{
return
0
;
}
return
val
;
}
}
int
type
=
this
.
columnMetaDataList
.
get
(
col
).
getColType
();
switch
(
type
)
{
case
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
:
case
TSDBConstants
.
TSDB_DATA_TYPE_TINYINT
:
case
TSDBConstants
.
TSDB_DATA_TYPE_SMALLINT
:
case
TSDBConstants
.
TSDB_DATA_TYPE_INT
:
{
case
TSDBConstants
.
TSDB_DATA_TYPE_INT
:
{
IntBuffer
ib
=
(
IntBuffer
)
this
.
colData
.
get
(
col
);
return
(
int
)
obj
;
int
val
=
ib
.
get
(
this
.
rowIndex
);
if
(
isIntNull
(
val
))
{
return
0
;
}
return
val
;
}
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
{
LongBuffer
lb
=
(
LongBuffer
)
this
.
colData
.
get
(
col
);
long
val
=
lb
.
get
(
this
.
rowIndex
);
if
(
isBigIntNull
(
val
))
{
return
0
;
}
return
(
long
)
val
;
}
}
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
{
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
{
FloatBuffer
fb
=
(
FloatBuffer
)
this
.
colData
.
get
(
col
);
return
(
long
)
obj
;
float
val
=
fb
.
get
(
this
.
rowIndex
);
if
(
isFloatNull
(
val
))
{
return
0
;
}
return
(
long
)
val
;
}
}
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
case
TSDBConstants
.
TSDB_DATA_TYPE_DOUBLE
:
{
case
TSDBConstants
.
TSDB_DATA_TYPE_DOUBLE
:
{
DoubleBuffer
lb
=
(
DoubleBuffer
)
this
.
colData
.
get
(
col
);
return
(
double
)
obj
;
double
val
=
lb
.
get
(
this
.
rowIndex
);
if
(
isDoubleNull
(
val
))
{
return
0
;
}
return
(
long
)
val
;
}
}
case
TSDBConstants
.
TSDB_DATA_TYPE_NCHAR
:
case
TSDBConstants
.
TSDB_DATA_TYPE_BINARY
:
{
case
TSDBConstants
.
TSDB_DATA_TYPE_BINARY
:
{
bb
.
position
(
fieldSize
*
this
.
rowIndex
);
return
Double
.
parseDouble
((
String
)
obj
);
int
length
=
bb
.
getShort
();
byte
[]
dest
=
new
byte
[
length
];
bb
.
get
(
dest
,
0
,
length
);
if
(
isBinaryNull
(
dest
,
length
))
{
return
0
;
}
return
Double
.
parseDouble
(
new
String
(
dest
));
}
case
TSDBConstants
.
TSDB_DATA_TYPE_NCHAR
:
{
bb
.
position
(
fieldSize
*
this
.
rowIndex
);
int
length
=
bb
.
getShort
();
byte
[]
dest
=
new
byte
[
length
];
bb
.
get
(
dest
,
0
,
length
);
if
(
isNcharNull
(
dest
,
length
))
{
return
0
;
}
try
{
return
Double
.
parseDouble
(
new
String
(
dest
,
TaosGlobalConfig
.
getCharset
()));
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
...
@@ -638,7 +492,8 @@ public class TSDBResultSetBlockData {
...
@@ -638,7 +492,8 @@ public class TSDBResultSetBlockData {
}
}
try
{
try
{
return
new
String
(
dest
,
TaosGlobalConfig
.
getCharset
());
String
ss
=
TaosGlobalConfig
.
getCharset
();
return
new
String
(
dest
,
ss
);
}
catch
(
UnsupportedEncodingException
e
)
{
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录