Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
822367d2
I
Iotdb
项目概览
apache
/
Iotdb
大约 1 年 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
822367d2
编写于
7月 18, 2017
作者:
L
liukun06
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
metadata check before other operation
上级
2e20e3ea
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
516 addition
and
473 deletion
+516
-473
src/main/java/cn/edu/thu/tsfiledb/metadata/MGraph.java
src/main/java/cn/edu/thu/tsfiledb/metadata/MGraph.java
+6
-6
src/main/java/cn/edu/thu/tsfiledb/metadata/MTree.java
src/main/java/cn/edu/thu/tsfiledb/metadata/MTree.java
+69
-48
src/main/java/cn/edu/thu/tsfiledb/qp/executor/OverflowQPExecutor.java
...a/cn/edu/thu/tsfiledb/qp/executor/OverflowQPExecutor.java
+335
-323
src/main/java/cn/edu/thu/tsfiledb/qp/strategy/LogicalGenerator.java
...ava/cn/edu/thu/tsfiledb/qp/strategy/LogicalGenerator.java
+106
-96
未找到文件。
src/main/java/cn/edu/thu/tsfiledb/metadata/MGraph.java
浏览文件 @
822367d2
...
...
@@ -50,7 +50,7 @@ public class MGraph implements Serializable {
throws
PathErrorException
,
MetadataArgsErrorException
{
String
nodes
[]
=
path
.
trim
().
split
(
"\\."
);
if
(
nodes
.
length
==
0
)
{
throw
new
PathErrorException
(
"Path is null. Path: "
+
path
);
throw
new
PathErrorException
(
String
.
format
(
"Timeseries is null"
)
);
}
return
this
.
mTree
.
addPath
(
path
,
dataType
,
encoding
,
args
);
}
...
...
@@ -61,14 +61,14 @@ public class MGraph implements Serializable {
public
void
addPathToPTree
(
String
path
)
throws
PathErrorException
,
MetadataArgsErrorException
{
String
nodes
[]
=
path
.
trim
().
split
(
"\\."
);
if
(
nodes
.
length
==
0
)
{
throw
new
PathErrorException
(
"
Path is null. Path: "
+
path
);
throw
new
PathErrorException
(
"
Timeseries is null."
);
}
String
rootName
=
path
.
trim
().
split
(
"\\."
)[
0
];
if
(
pTreeMap
.
containsKey
(
rootName
))
{
PTree
pTree
=
pTreeMap
.
get
(
rootName
);
pTree
.
addPath
(
path
);
}
else
{
throw
new
PathErrorException
(
"
Path Root is N
ot Correct. RootName: "
+
rootName
);
throw
new
PathErrorException
(
"
Timeseries's root is n
ot Correct. RootName: "
+
rootName
);
}
}
...
...
@@ -80,7 +80,7 @@ public class MGraph implements Serializable {
public
void
deletePath
(
String
path
)
throws
PathErrorException
{
String
nodes
[]
=
path
.
trim
().
split
(
"\\."
);
if
(
nodes
.
length
==
0
)
{
throw
new
PathErrorException
(
"
Path is null. Path: "
+
path
);
throw
new
PathErrorException
(
"
Timeseries is null"
);
}
String
rootName
=
path
.
trim
().
split
(
"\\."
)[
0
];
if
(
mTree
.
getRoot
().
getName
().
equals
(
rootName
))
{
...
...
@@ -89,7 +89,7 @@ public class MGraph implements Serializable {
PTree
pTree
=
pTreeMap
.
get
(
rootName
);
pTree
.
deletePath
(
path
);
}
else
{
throw
new
PathErrorException
(
"
Path Root is N
ot Correct. RootName: "
+
rootName
);
throw
new
PathErrorException
(
"
Timeseries's root is n
ot Correct. RootName: "
+
rootName
);
}
}
...
...
@@ -142,7 +142,7 @@ public class MGraph implements Serializable {
PTree
pTree
=
pTreeMap
.
get
(
rootName
);
return
pTree
.
getAllLinkedPath
(
path
);
}
throw
new
PathErrorException
(
"
Path Root is N
ot Correct. RootName: "
+
rootName
);
throw
new
PathErrorException
(
"
Timeseries's root is n
ot Correct. RootName: "
+
rootName
);
}
/**
...
...
src/main/java/cn/edu/thu/tsfiledb/metadata/MTree.java
浏览文件 @
822367d2
...
...
@@ -31,17 +31,19 @@ public class MTree implements Serializable {
/**
* Add a path to current Metadata Tree
* @param path Format: root.node.(node)*
*
* @param path
* Format: root.node.(node)*
*/
public
int
addPath
(
String
path
,
String
dataType
,
String
encoding
,
String
[]
args
)
throws
PathErrorException
,
MetadataArgsErrorException
{
int
addCount
=
0
;
if
(
getRoot
()
==
null
)
{
throw
new
PathErrorException
(
"Root
Node is null, P
lease initialize root first"
);
throw
new
PathErrorException
(
"Root
node is null, p
lease initialize root first"
);
}
String
[]
nodeNames
=
path
.
trim
().
split
(
"\\."
);
if
(
nodeNames
.
length
<=
1
||
!
nodeNames
[
0
].
equals
(
getRoot
().
getName
()))
{
throw
new
PathErrorException
(
"Input path not exist. Path: "
+
path
);
throw
new
PathErrorException
(
String
.
format
(
"Timeseries %s is not right."
,
path
)
);
}
MNode
cur
=
getRoot
();
...
...
@@ -54,7 +56,7 @@ public class MTree implements Serializable {
cur
=
cur
.
getChild
(
nodeNames
[
i
]);
}
if
(
cur
.
hasChild
(
nodeNames
[
i
]))
{
throw
new
PathErrorException
(
"Path already exists. Path: "
+
path
);
throw
new
PathErrorException
(
String
.
format
(
"Timeseries %s already exists."
,
path
)
);
}
else
{
TSDataType
dt
=
TSDataType
.
valueOf
(
dataType
);
TSEncoding
ed
=
TSEncoding
.
valueOf
(
encoding
);
...
...
@@ -73,6 +75,7 @@ public class MTree implements Serializable {
/**
* Delete one path from current Metadata Tree
*
* @param path
* Format: root.node.(node)* Notice: Path must be a complete Path
* from root to leaf node.
...
...
@@ -80,14 +83,14 @@ public class MTree implements Serializable {
public
void
deletePath
(
String
path
)
throws
PathErrorException
{
String
[]
nodes
=
path
.
split
(
"\\."
);
if
(
nodes
.
length
==
0
||
!
nodes
[
0
].
equals
(
getRoot
().
getName
()))
{
throw
new
PathErrorException
(
"
Path not correct. Path:
"
+
path
);
throw
new
PathErrorException
(
"
Timeseries %s is not correct.
"
+
path
);
}
MNode
cur
=
getRoot
();
for
(
int
i
=
1
;
i
<
nodes
.
length
;
i
++)
{
if
(!
cur
.
hasChild
(
nodes
[
i
]))
{
throw
new
PathErrorException
(
"
Path
not correct. Node["
+
cur
.
getName
()
+
"] doesn't have child named:"
+
nodes
[
i
]);
"
Timeseries is
not correct. Node["
+
cur
.
getName
()
+
"] doesn't have child named:"
+
nodes
[
i
]);
}
cur
=
cur
.
getChild
(
nodes
[
i
]);
}
...
...
@@ -95,22 +98,25 @@ public class MTree implements Serializable {
}
/**
* Set filename to one node in the Metadata Tree Notice: This method will set
* the {@code MNode.dataFileName} and {@code MNode.isStorageLevel} of current node
* called if and only if {@code MNode.isStorageLevel} is true.
* @param path Format: root.node.(node)*
* Set filename to one node in the Metadata Tree Notice: This method will
* set the {@code MNode.dataFileName} and {@code MNode.isStorageLevel} of
* current node called if and only if {@code MNode.isStorageLevel} is true.
*
* @param path
* Format: root.node.(node)*
*/
private
void
setFileNameToOnePath
(
String
path
)
throws
PathErrorException
{
String
nodes
[]
=
path
.
trim
().
split
(
"\\."
);
if
(
nodes
.
length
==
0
||
!
nodes
[
0
].
equals
(
getRoot
().
getName
()))
{
throw
new
PathErrorException
(
"Input path NOT correct. Path: "
+
path
);
throw
new
PathErrorException
(
String
.
format
(
"Timeseries %s is not correct"
,
path
)
);
}
MNode
cur
=
getRoot
();
for
(
int
i
=
1
;
i
<
nodes
.
length
;
i
++)
{
if
(
cur
.
hasChild
(
nodes
[
i
]))
{
cur
=
cur
.
getChild
(
nodes
[
i
]);
}
else
{
throw
new
PathErrorException
(
"Input path NOT correct. Path: "
+
path
);
throw
new
PathErrorException
(
"Timeseries is not correct. Node["
+
cur
.
getName
()
+
"] doesn't have child named:"
+
nodes
[
i
]);
}
}
...
...
@@ -120,12 +126,14 @@ public class MTree implements Serializable {
/**
* Set storage level for current Metadata Tree.
* @param path Format: root.node.(node)*
*
* @param path
* Format: root.node.(node)*
*/
public
void
setStorageLevel
(
String
path
)
throws
PathErrorException
{
String
nodes
[]
=
path
.
trim
().
split
(
"\\."
);
if
(
nodes
.
length
<=
1
||
!
nodes
[
0
].
equals
(
getRoot
().
getName
()))
{
throw
new
PathErrorException
(
"Root Name NOT correct. Root:"
+
path
);
throw
new
PathErrorException
(
String
.
format
(
"Timeseries %s is not correct"
,
path
)
);
}
int
level
=
0
;
...
...
@@ -135,7 +143,8 @@ public class MTree implements Serializable {
cur
=
cur
.
getChild
(
nodes
[
i
]);
level
++;
}
else
{
throw
new
PathErrorException
(
"Input path NOT correct. Nodes["
+
i
+
"] not correct :"
+
nodes
[
i
]);
throw
new
PathErrorException
(
"Timeseries is not correct. Node["
+
cur
.
getName
()
+
"] doesn't have child named:"
+
nodes
[
i
]);
}
}
...
...
@@ -208,20 +217,21 @@ public class MTree implements Serializable {
cur
=
cur
.
getChild
(
node
[
i
]);
}
if
(!
cur
.
isLeaf
())
{
throw
new
PathErrorException
(
"Input path not end with a leaf node."
);
throw
new
PathErrorException
(
String
.
format
(
"Timeseries %s is not the leaf node"
,
path
)
);
}
return
cur
;
}
/**
* Extract the DeltaObjectType from given path
*
* @return String represents the DeltaObjectId
*/
public
String
getDeltaObjectTypeByPath
(
String
path
)
throws
PathErrorException
{
checkPath
(
path
);
String
[]
nodes
=
path
.
split
(
"\\."
);
if
(
nodes
.
length
<
2
)
{
throw
new
PathErrorException
(
"Input path must has two or more nodes"
);
throw
new
PathErrorException
(
String
.
format
(
"Timeseries %s must have two or more nodes"
,
path
)
);
}
return
nodes
[
0
]
+
"."
+
nodes
[
1
];
}
...
...
@@ -232,12 +242,13 @@ public class MTree implements Serializable {
private
void
checkPath
(
String
path
)
throws
PathErrorException
{
String
[]
nodes
=
path
.
split
(
"\\."
);
if
(
nodes
.
length
<
2
||
!
nodes
[
0
].
equals
(
getRoot
().
getName
()))
{
throw
new
PathErrorException
(
"Input path NOT correct. Path: "
+
path
);
throw
new
PathErrorException
(
String
.
format
(
"Timeseries %s is not correct"
,
path
)
);
}
MNode
cur
=
getRoot
();
for
(
int
i
=
1
;
i
<
nodes
.
length
;
i
++)
{
if
(!
cur
.
hasChild
(
nodes
[
i
]))
{
throw
new
PathErrorException
(
"Input path NOT correct. Path: "
+
path
);
throw
new
PathErrorException
(
"Timeseries is not correct. Node["
+
cur
.
getName
()
+
"] doesn't have child named:"
+
nodes
[
i
]);
}
cur
=
cur
.
getChild
(
nodes
[
i
]);
}
...
...
@@ -251,13 +262,14 @@ public class MTree implements Serializable {
public
String
getFileNameByPath
(
String
path
)
throws
PathErrorException
{
String
[]
nodes
=
path
.
split
(
"\\."
);
if
(
nodes
.
length
==
0
||
!
nodes
[
0
].
equals
(
getRoot
().
getName
()))
{
throw
new
PathErrorException
(
"Input path NOT correct. Path: "
+
path
);
throw
new
PathErrorException
(
String
.
format
(
"Timeseries %s is not correct"
,
path
)
);
}
MNode
cur
=
getRoot
();
for
(
int
i
=
1
;
i
<
nodes
.
length
;
i
++)
{
if
(!
cur
.
hasChild
(
nodes
[
i
]))
{
throw
new
PathErrorException
(
"Input path NOT correct. Path: "
+
path
);
throw
new
PathErrorException
(
"Timeseries is not correct. Node["
+
cur
.
getName
()
+
"] doesn't have child named:"
+
nodes
[
i
]);
}
if
(
cur
.
getDataFileName
()
!=
null
)
{
return
cur
.
getDataFileName
();
...
...
@@ -267,23 +279,26 @@ public class MTree implements Serializable {
if
(
cur
.
getDataFileName
()
!=
null
)
{
return
cur
.
getDataFileName
();
}
throw
new
PathErrorException
(
"Do not set FileLevel for this path: "
+
path
);
throw
new
PathErrorException
(
String
.
format
(
"Timeseries %s does not set storage group, please set storage group first and then do the operation"
,
path
));
}
/**
* Get all paths for given path regular expression Regular expression in
* this method is formed by the amalgamation of path and the character '*'
*
* @return A HashMap whose Keys are separated by the storage file name.
*/
public
HashMap
<
String
,
ArrayList
<
String
>>
getAllPath
(
String
pathReg
)
throws
PathErrorException
{
HashMap
<
String
,
ArrayList
<
String
>>
paths
=
new
HashMap
<>();
String
[]
nodes
=
pathReg
.
split
(
"\\."
);
if
(
nodes
.
length
==
0
||
!
nodes
[
0
].
equals
(
getRoot
().
getName
()))
{
throw
new
PathErrorException
(
"Input path NOT correct. PathReg: "
+
pathReg
);
throw
new
PathErrorException
(
String
.
format
(
"Timeseries %s is not correct"
,
pathReg
)
);
}
if
(!
pathReg
.
equals
(
"root"
))
{
if
(!
findPath
(
getRoot
(),
nodes
,
1
,
""
,
paths
,
false
))
{
throw
new
PathErrorException
(
"Input path NOT correct. PathReg: "
+
pathReg
);
throw
new
PathErrorException
(
String
.
format
(
"Timeseries %s is not correct"
,
pathReg
)
);
}
}
else
{
findPath
(
getRoot
(),
nodes
,
1
,
""
,
paths
,
false
);
...
...
@@ -292,24 +307,25 @@ public class MTree implements Serializable {
return
paths
;
}
public
ArrayList
<
String
>
getAllPathInList
(
String
path
)
throws
PathErrorException
{
public
ArrayList
<
String
>
getAllPathInList
(
String
path
)
throws
PathErrorException
{
ArrayList
<
String
>
res
=
new
ArrayList
<>();
HashMap
<
String
,
ArrayList
<
String
>>
mapRet
=
getAllPath
(
path
);
for
(
ArrayList
<
String
>
value
:
mapRet
.
values
())
{
for
(
ArrayList
<
String
>
value
:
mapRet
.
values
())
{
res
.
addAll
(
value
);
}
return
res
;
}
/**
* Calculate the count of storage-level nodes included in given path
*
* @return The total count of storage-level nodes.
*/
public
int
getFileCountForOneType
(
String
path
)
throws
PathErrorException
{
String
nodes
[]
=
path
.
split
(
"\\."
);
if
(
nodes
.
length
!=
2
||
!
nodes
[
0
].
equals
(
getRoot
().
getName
())
||
!
getRoot
().
hasChild
(
nodes
[
1
]))
{
throw
new
PathErrorException
(
"
Path must be "
+
getRoot
().
getName
()
+
".
X (X is one of the nodes of root's children)"
);
"
Timeseries must be "
+
getRoot
().
getName
()
+
".
X (X is one of the nodes of root's children)"
);
}
return
getFileCountForOneNode
(
getRoot
().
getChild
(
nodes
[
1
]));
}
...
...
@@ -330,6 +346,7 @@ public class MTree implements Serializable {
/**
* Get all DeltaObject type in current Metadata Tree
*
* @return a list contains all distinct DeltaObject type
*/
public
ArrayList
<
String
>
getAllType
()
{
...
...
@@ -344,7 +361,9 @@ public class MTree implements Serializable {
/**
* Get all delta objects for given type
* @param type DeltaObject Type
*
* @param type
* DeltaObject Type
* @return a list contains all delta objects for given type
* @throws PathErrorException
*/
...
...
@@ -372,7 +391,9 @@ public class MTree implements Serializable {
/**
* Get all ColumnSchemas for given delta object type
* @param path A path represented one Delta object
*
* @param path
* A path represented one Delta object
* @return a list contains all column schema
* @throws PathErrorException
*/
...
...
@@ -380,7 +401,7 @@ public class MTree implements Serializable {
String
nodes
[]
=
path
.
split
(
"\\."
);
if
(
nodes
.
length
!=
2
||
!
nodes
[
0
].
equals
(
getRoot
().
getName
())
||
!
getRoot
().
hasChild
(
nodes
[
1
]))
{
throw
new
PathErrorException
(
"
Path must be "
+
getRoot
().
getName
()
+
".
X (X is one of the nodes of root's children)"
);
"
Timeseries must be "
+
getRoot
().
getName
()
+
".
X (X is one of the nodes of root's children)"
);
}
HashMap
<
String
,
ColumnSchema
>
leafMap
=
new
HashMap
<>();
putLeafToLeafMap
(
getRoot
().
getChild
(
nodes
[
1
]),
leafMap
);
...
...
@@ -401,8 +422,8 @@ public class MTree implements Serializable {
}
}
private
boolean
findPath
(
MNode
node
,
String
[]
nodes
,
int
idx
,
String
parent
,
HashMap
<
String
,
ArrayList
<
String
>>
paths
,
boolean
pathExist
)
throws
PathErrorException
{
private
boolean
findPath
(
MNode
node
,
String
[]
nodes
,
int
idx
,
String
parent
,
HashMap
<
String
,
ArrayList
<
String
>>
paths
,
boolean
pathExist
)
{
if
(
node
.
isLeaf
())
{
String
fileName
=
node
.
getDataFileName
();
String
nodePath
=
parent
+
node
;
...
...
@@ -419,10 +440,10 @@ public class MTree implements Serializable {
if
(!
nodeReg
.
equals
(
"*"
))
{
if
(!
node
.
hasChild
(
nodeReg
))
{
// throw new PathErrorException("Path Error in node : " + nodeReg);
// return false;
}
else
{
pathExist
=
findPath
(
node
.
getChild
(
nodeReg
),
nodes
,
idx
+
1
,
parent
+
node
.
getName
()
+
"."
,
paths
,
pathExist
);
pathExist
=
findPath
(
node
.
getChild
(
nodeReg
),
nodes
,
idx
+
1
,
parent
+
node
.
getName
()
+
"."
,
paths
,
pathExist
);
}
}
else
{
for
(
MNode
child
:
node
.
getChildren
().
values
())
{
...
...
@@ -447,35 +468,35 @@ public class MTree implements Serializable {
}
private
String
MNodeToString
(
MNode
node
,
int
tab
)
{
StringBuilder
builder
=
new
StringBuilder
();
StringBuilder
builder
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
tab
;
i
++)
{
builder
.
append
(
space
);
builder
.
append
(
space
);
}
builder
.
append
(
node
.
getName
());
if
(!
node
.
isLeaf
()
&&
node
.
getChildren
().
size
()
>
0
)
{
builder
.
append
(
":{\n"
);
builder
.
append
(
":{\n"
);
int
first
=
0
;
for
(
MNode
child
:
node
.
getChildren
().
values
())
{
if
(
first
==
0
)
{
first
=
1
;
}
else
{
builder
.
append
(
",\n"
);
builder
.
append
(
",\n"
);
}
builder
.
append
(
MNodeToString
(
child
,
tab
+
1
));
}
builder
.
append
(
"\n"
);
for
(
int
i
=
0
;
i
<
tab
;
i
++)
{
builder
.
append
(
space
);
builder
.
append
(
space
);
}
builder
.
append
(
"}"
);
}
else
if
(
node
.
isLeaf
())
{
builder
.
append
(
":{\n"
);
builder
.
append
(
String
.
format
(
"%s DataType: %s,\n"
,
getTabs
(
tab
+
1
),
node
.
getSchema
().
dataType
));
builder
.
append
(
String
.
format
(
"%s Encoding: %s,\n"
,
getTabs
(
tab
+
1
),
node
.
getSchema
().
encoding
));
builder
.
append
(
String
.
format
(
"%s args: %s,\n"
,
getTabs
(
tab
+
1
),
node
.
getSchema
().
getArgsMap
()));
builder
.
append
(
String
.
format
(
"%s FileName: %s \n"
,
getTabs
(
tab
+
1
),
node
.
getDataFileName
()));
builder
.
append
(
getTabs
(
tab
));
builder
.
append
(
"}"
);
builder
.
append
(
":{\n"
);
builder
.
append
(
String
.
format
(
"%s DataType: %s,\n"
,
getTabs
(
tab
+
1
),
node
.
getSchema
().
dataType
));
builder
.
append
(
String
.
format
(
"%s Encoding: %s,\n"
,
getTabs
(
tab
+
1
),
node
.
getSchema
().
encoding
));
builder
.
append
(
String
.
format
(
"%s args: %s,\n"
,
getTabs
(
tab
+
1
),
node
.
getSchema
().
getArgsMap
()));
builder
.
append
(
String
.
format
(
"%s FileName: %s \n"
,
getTabs
(
tab
+
1
),
node
.
getDataFileName
()));
builder
.
append
(
getTabs
(
tab
));
builder
.
append
(
"}"
);
}
return
builder
.
toString
();
}
...
...
src/main/java/cn/edu/thu/tsfiledb/qp/executor/OverflowQPExecutor.java
浏览文件 @
822367d2
此差异已折叠。
点击以展开。
src/main/java/cn/edu/thu/tsfiledb/qp/strategy/LogicalGenerator.java
浏览文件 @
822367d2
...
...
@@ -53,8 +53,9 @@ public class LogicalGenerator {
/**
* input an astNode parsing by {@code antlr} and analyze it.
*
* @throws QueryProcessorException
* @throws ArgsErrorException
* @throws ArgsErrorException
*
*/
private
void
analyze
(
ASTNode
astNode
)
throws
QueryProcessorException
,
ArgsErrorException
{
...
...
@@ -236,40 +237,41 @@ public class LogicalGenerator {
private
void
analyzeInsert
(
ASTNode
astNode
)
throws
QueryProcessorException
{
InsertOperator
InsertOp
=
new
InsertOperator
(
SQLConstant
.
TOK_INSERT
);
initializedOperator
=
InsertOp
;
analyzeSelect
(
astNode
.
getChild
(
0
));
long
timestamp
;
ASTNode
timeChild
;
try
{
timeChild
=
astNode
.
getChild
(
1
).
getChild
(
0
);
if
(
timeChild
.
getToken
().
getType
()
!=
TSParser
.
TOK_TIME
)
{
throw
new
LogicalOperatorException
(
"need keyword 'timestamp'"
);
}
ASTNode
timeValue
=
astNode
.
getChild
(
2
).
getChild
(
0
);
if
(
timeValue
.
getType
()==
TSParser
.
TOK_DATETIME
){
timestamp
=
Long
.
valueOf
(
parseTokenTime
(
timeValue
));
}
else
{
timestamp
=
Long
.
valueOf
(
astNode
.
getChild
(
2
).
getChild
(
0
).
getText
());
}
}
catch
(
NumberFormatException
e
)
{
throw
new
LogicalOperatorException
(
"need a long value in insert clause, but given:"
+
astNode
.
getChild
(
2
).
getChild
(
0
).
getText
());
}
if
(
astNode
.
getChild
(
1
).
getChildCount
()
!=
astNode
.
getChild
(
2
).
getChildCount
())
{
throw
new
QueryProcessorException
(
"length of measurement is NOT EQUAL TO the length of values"
);
}
InsertOp
.
setTime
(
timestamp
);
List
<
String
>
measurementList
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<
astNode
.
getChild
(
1
).
getChildCount
();
i
++)
{
measurementList
.
add
(
astNode
.
getChild
(
1
).
getChild
(
i
).
getText
());
}
InsertOp
.
setMeasurementList
(
measurementList
);
List
<
String
>
valueList
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<
astNode
.
getChild
(
2
).
getChildCount
();
i
++)
{
valueList
.
add
(
astNode
.
getChild
(
2
).
getChild
(
i
).
getText
());
}
InsertOp
.
setValueList
(
valueList
);
}
initializedOperator
=
InsertOp
;
analyzeSelect
(
astNode
.
getChild
(
0
));
long
timestamp
;
ASTNode
timeChild
;
try
{
timeChild
=
astNode
.
getChild
(
1
).
getChild
(
0
);
if
(
timeChild
.
getToken
().
getType
()
!=
TSParser
.
TOK_TIME
)
{
throw
new
LogicalOperatorException
(
"need keyword 'timestamp'"
);
}
ASTNode
timeValue
=
astNode
.
getChild
(
2
).
getChild
(
0
);
if
(
timeValue
.
getType
()
==
TSParser
.
TOK_DATETIME
)
{
timestamp
=
Long
.
valueOf
(
parseTokenTime
(
timeValue
));
}
else
{
timestamp
=
Long
.
valueOf
(
astNode
.
getChild
(
2
).
getChild
(
0
).
getText
());
}
}
catch
(
NumberFormatException
e
)
{
throw
new
LogicalOperatorException
(
"need a long value in insert clause, but given:"
+
astNode
.
getChild
(
2
).
getChild
(
0
).
getText
());
}
if
(
astNode
.
getChild
(
1
).
getChildCount
()
!=
astNode
.
getChild
(
2
).
getChildCount
())
{
throw
new
QueryProcessorException
(
"length of measurement is NOT EQUAL TO the length of values"
);
}
InsertOp
.
setTime
(
timestamp
);
List
<
String
>
measurementList
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<
astNode
.
getChild
(
1
).
getChildCount
();
i
++)
{
measurementList
.
add
(
astNode
.
getChild
(
1
).
getChild
(
i
).
getText
());
}
InsertOp
.
setMeasurementList
(
measurementList
);
List
<
String
>
valueList
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<
astNode
.
getChild
(
2
).
getChildCount
();
i
++)
{
valueList
.
add
(
astNode
.
getChild
(
2
).
getChild
(
i
).
getText
());
}
InsertOp
.
setValueList
(
valueList
);
}
private
void
analyzeUpdate
(
ASTNode
astNode
)
throws
QueryProcessorException
{
if
(
astNode
.
getChildCount
()
!=
3
)
...
...
@@ -458,7 +460,7 @@ public class LogicalGenerator {
int
childCount
=
node
.
getChildCount
();
String
[]
path
=
new
String
[
node
.
getChildCount
()];
for
(
int
i
=
0
;
i
<
childCount
;
i
++)
{
//
path[i] = node.getChild(i).getText().toLowerCase();
//
path[i] = node.getChild(i).getText().toLowerCase();
path
[
i
]
=
node
.
getChild
(
i
).
getText
();
}
return
new
Path
(
new
StringContainer
(
path
,
SystemConstant
.
PATH_SEPARATOR
));
...
...
@@ -469,7 +471,7 @@ public class LogicalGenerator {
sc
.
addTail
(
SQLConstant
.
ROOT
);
int
childCount
=
node
.
getChildCount
();
for
(
int
i
=
0
;
i
<
childCount
;
i
++)
{
//
sc.addTail(node.getChild(i).getText().toLowerCase());
//
sc.addTail(node.getChild(i).getText().toLowerCase());
sc
.
addTail
(
node
.
getChild
(
i
).
getText
());
}
return
new
Path
(
sc
);
...
...
@@ -485,7 +487,8 @@ public class LogicalGenerator {
int
childCount
=
astNode
.
getChildCount
();
// node path should have more than one level and first node level must
// be root
// if (childCount < 3 || !SQLConstant.ROOT.equals(astNode.getChild(1).getText().toLowerCase()))
// if (childCount < 3 ||
// !SQLConstant.ROOT.equals(astNode.getChild(1).getText().toLowerCase()))
if
(
childCount
<
3
||
!
SQLConstant
.
ROOT
.
equals
(
astNode
.
getChild
(
1
).
getText
()))
throw
new
IllegalASTFormatException
(
"data load command: child count < 3\n"
+
astNode
.
dump
());
String
csvPath
=
astNode
.
getChild
(
0
).
getText
();
...
...
@@ -494,7 +497,7 @@ public class LogicalGenerator {
StringContainer
sc
=
new
StringContainer
(
SystemConstant
.
PATH_SEPARATOR
);
sc
.
addTail
(
SQLConstant
.
ROOT
);
for
(
int
i
=
2
;
i
<
childCount
;
i
++)
{
//
String pathNode = astNode.getChild(i).getText().toLowerCase();
//
String pathNode = astNode.getChild(i).getText().toLowerCase();
String
pathNode
=
astNode
.
getChild
(
i
).
getText
();
sc
.
addTail
(
pathNode
);
}
...
...
@@ -640,61 +643,68 @@ public class LogicalGenerator {
initializedOperator
=
authorOperator
;
}
private
void
checkMetadataArgs
(
String
dataType
,
String
encoding
)
throws
MetadataArgsErrorException
{
final
String
RLE
=
"RLE"
;
final
String
PLAIN
=
"PLAIN"
;
final
String
TS_2DIFF
=
"TS_2DIFF"
;
final
String
BITMAP
=
"BITMAP"
;
if
(
dataType
==
null
)
{
throw
new
MetadataArgsErrorException
(
"data type cannot be null"
);
}
switch
(
dataType
)
{
case
"BOOLEAN"
:
if
(
encoding
==
null
||
encoding
.
equals
(
PLAIN
))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s does not support %s"
,
encoding
,
dataType
));
}
break
;
case
"INT32"
:
if
(
encoding
==
null
||
(!
encoding
.
equals
(
PLAIN
)
&&
!
encoding
.
equals
(
RLE
)
&&
!
encoding
.
equals
(
TS_2DIFF
)))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s does not support %s"
,
encoding
,
dataType
));
}
break
;
case
"INT64"
:
if
(
encoding
==
null
||
(!
encoding
.
equals
(
PLAIN
)
&&
!
encoding
.
equals
(
RLE
)
&&
!
encoding
.
equals
(
TS_2DIFF
)))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s does not support %s"
,
encoding
,
dataType
));
}
break
;
case
"FLOAT"
:
if
(
encoding
==
null
||
(!
encoding
.
equals
(
PLAIN
)
&&
!
encoding
.
equals
(
RLE
)
&&
!
encoding
.
equals
(
TS_2DIFF
)))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s does not support %s"
,
encoding
,
dataType
));
}
break
;
case
"DOUBLE"
:
if
(
encoding
==
null
||
(!
encoding
.
equals
(
PLAIN
)
&&
!
encoding
.
equals
(
RLE
)
&&
!
encoding
.
equals
(
TS_2DIFF
)))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s does not support %s"
,
encoding
,
dataType
));
}
break
;
case
"ENUMS"
:
if
(
encoding
==
null
||
(!
encoding
.
equals
(
PLAIN
)
&&
!
encoding
.
equals
(
BITMAP
)))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s does not support %s"
,
encoding
,
dataType
));
}
break
;
case
"BYTE_ARRAY"
:
if
(
encoding
==
null
||
!
encoding
.
equals
(
PLAIN
))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s does not support %s"
,
encoding
,
dataType
));
}
break
;
default
:
throw
new
MetadataArgsErrorException
(
String
.
format
(
"data type %s is not supprot"
,
dataType
));
}
}
private
void
checkMetadataArgs
(
String
dataType
,
String
encoding
)
throws
MetadataArgsErrorException
{
final
String
RLE
=
"RLE"
;
final
String
PLAIN
=
"PLAIN"
;
final
String
TS_2DIFF
=
"TS_2DIFF"
;
final
String
BITMAP
=
"BITMAP"
;
if
(
dataType
==
null
)
{
throw
new
MetadataArgsErrorException
(
"data type cannot be null"
);
}
if
(
encoding
==
null
)
{
throw
new
MetadataArgsErrorException
(
"encoding type cannot be null"
);
}
if
(!
encoding
.
equals
(
RLE
)
&&
!
encoding
.
equals
(
PLAIN
)
&&
!
encoding
.
equals
(
TS_2DIFF
)
&&
!
encoding
.
equals
(
BITMAP
))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s is not support"
,
encoding
));
}
switch
(
dataType
)
{
case
"BOOLEAN"
:
if
(
encoding
.
equals
(
PLAIN
))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s does not support %s"
,
encoding
,
dataType
));
}
break
;
case
"INT32"
:
if
((!
encoding
.
equals
(
PLAIN
)
&&
!
encoding
.
equals
(
RLE
)
&&
!
encoding
.
equals
(
TS_2DIFF
)))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s does not support %s"
,
encoding
,
dataType
));
}
break
;
case
"INT64"
:
if
((!
encoding
.
equals
(
PLAIN
)
&&
!
encoding
.
equals
(
RLE
)
&&
!
encoding
.
equals
(
TS_2DIFF
)))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s does not support %s"
,
encoding
,
dataType
));
}
break
;
case
"FLOAT"
:
if
((!
encoding
.
equals
(
PLAIN
)
&&
!
encoding
.
equals
(
RLE
)
&&
!
encoding
.
equals
(
TS_2DIFF
)))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s does not support %s"
,
encoding
,
dataType
));
}
break
;
case
"DOUBLE"
:
if
((!
encoding
.
equals
(
PLAIN
)
&&
!
encoding
.
equals
(
RLE
)
&&
!
encoding
.
equals
(
TS_2DIFF
)))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s does not support %s"
,
encoding
,
dataType
));
}
break
;
case
"ENUMS"
:
if
((!
encoding
.
equals
(
PLAIN
)
&&
!
encoding
.
equals
(
BITMAP
)))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s does not support %s"
,
encoding
,
dataType
));
}
break
;
case
"BYTE_ARRAY"
:
if
(!
encoding
.
equals
(
PLAIN
))
{
throw
new
MetadataArgsErrorException
(
String
.
format
(
"encoding %s does not support %s"
,
encoding
,
dataType
));
}
break
;
default
:
throw
new
MetadataArgsErrorException
(
String
.
format
(
"data type %s is not supprot"
,
dataType
));
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录