Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
ccbbfa38
Q
Questdb
项目概览
jobily
/
Questdb
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
Questdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ccbbfa38
编写于
11月 08, 2019
作者:
V
Vlad Ilyushchenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GRIFFIN: refactored insert further to inline CairoEngine
上级
2c2481ff
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
13 addition
and
9 deletion
+13
-9
core/src/main/java/io/questdb/cairo/sql/InsertStatement.java
core/src/main/java/io/questdb/cairo/sql/InsertStatement.java
+1
-2
core/src/main/java/io/questdb/griffin/InsertStatementImpl.java
...src/main/java/io/questdb/griffin/InsertStatementImpl.java
+4
-1
core/src/main/java/io/questdb/griffin/SqlCompiler.java
core/src/main/java/io/questdb/griffin/SqlCompiler.java
+1
-1
core/src/test/java/io/questdb/griffin/InsertTest.java
core/src/test/java/io/questdb/griffin/InsertTest.java
+7
-5
未找到文件。
core/src/main/java/io/questdb/cairo/sql/InsertStatement.java
浏览文件 @
ccbbfa38
...
...
@@ -23,7 +23,6 @@
package
io.questdb.cairo.sql
;
import
io.questdb.cairo.CairoEngine
;
import
io.questdb.griffin.SqlExecutionContext
;
public
interface
InsertStatement
{
...
...
@@ -31,5 +30,5 @@ public interface InsertStatement {
long
getStructureVersion
();
InsertMethod
createMethod
(
CairoEngine
engine
,
SqlExecutionContext
executionContext
);
InsertMethod
createMethod
(
SqlExecutionContext
executionContext
);
}
core/src/main/java/io/questdb/griffin/InsertStatementImpl.java
浏览文件 @
ccbbfa38
...
...
@@ -37,16 +37,19 @@ public class InsertStatementImpl implements InsertStatement {
private
final
long
structureVersion
;
private
final
String
tableName
;
private
final
InsertMethodImpl
insertMethod
=
new
InsertMethodImpl
();
private
final
CairoEngine
engine
;
private
SqlExecutionContext
lastUsedContext
;
// todo: recycle these
public
InsertStatementImpl
(
CairoEngine
engine
,
String
tableName
,
VirtualRecord
virtualRecord
,
SqlCompiler
.
RecordToRowCopier
copier
,
Function
timestampFunction
,
long
structureVersion
)
{
this
.
engine
=
engine
;
this
.
tableName
=
tableName
;
this
.
virtualRecord
=
virtualRecord
;
this
.
copier
=
copier
;
...
...
@@ -89,7 +92,7 @@ public class InsertStatementImpl implements InsertStatement {
}
@Override
public
InsertMethod
createMethod
(
CairoEngine
engine
,
SqlExecutionContext
executionContext
)
{
public
InsertMethod
createMethod
(
SqlExecutionContext
executionContext
)
{
if
(
lastUsedContext
!=
executionContext
)
{
initContext
(
executionContext
);
}
...
...
core/src/main/java/io/questdb/griffin/SqlCompiler.java
浏览文件 @
ccbbfa38
...
...
@@ -1183,7 +1183,7 @@ public class SqlCompiler implements Closeable {
VirtualRecord
record
=
new
VirtualRecord
(
valueFunctions
);
RecordToRowCopier
copier
=
assembleRecordToRowCopier
(
asm
,
record
,
metadata
,
columnFilter
);
return
compiledQuery
.
ofInsert
(
new
InsertStatementImpl
(
Chars
.
toString
(
name
.
token
),
record
,
copier
,
timestampFunction
,
structureVersion
));
return
compiledQuery
.
ofInsert
(
new
InsertStatementImpl
(
engine
,
Chars
.
toString
(
name
.
token
),
record
,
copier
,
timestampFunction
,
structureVersion
));
}
catch
(
SqlException
e
)
{
Misc
.
freeObjList
(
valueFunctions
);
throw
e
;
...
...
core/src/test/java/io/questdb/griffin/InsertTest.java
浏览文件 @
ccbbfa38
...
...
@@ -115,7 +115,7 @@ public class InsertTest extends AbstractGriffinTest {
compiler
.
compile
(
"alter table balances drop column ccy"
);
insertStatement
.
createMethod
(
engine
,
sqlExecutionContext
);
insertStatement
.
createMethod
(
sqlExecutionContext
);
}
catch
(
WriterOutOfDateException
ignored
)
{
}
...
...
@@ -135,7 +135,7 @@ public class InsertTest extends AbstractGriffinTest {
Assert
.
assertEquals
(
CompiledQuery
.
INSERT
,
cq
.
getType
());
InsertStatement
insertStatement
=
cq
.
getInsertStatement
();
try
(
InsertMethod
method
=
insertStatement
.
createMethod
(
engine
,
sqlExecutionContext
))
{
try
(
InsertMethod
method
=
insertStatement
.
createMethod
(
sqlExecutionContext
))
{
method
.
execute
();
method
.
commit
();
}
...
...
@@ -145,11 +145,12 @@ public class InsertTest extends AbstractGriffinTest {
bindVariableService
.
setDouble
(
"bal"
,
56.4
);
try
(
InsertMethod
method
=
insertStatement
.
createMethod
(
engine
,
sqlExecutionContext
))
{
try
(
InsertMethod
method
=
insertStatement
.
createMethod
(
sqlExecutionContext
))
{
method
.
execute
();
method
.
commit
();
}
sink
.
clear
();
try
(
TableReader
reader
=
engine
.
getReader
(
sqlExecutionContext
.
getCairoSecurityContext
(),
insertStatement
.
getTableName
()))
{
printer
.
print
(
reader
.
getCursor
(),
reader
.
getMetadata
(),
true
);
}
...
...
@@ -175,7 +176,7 @@ public class InsertTest extends AbstractGriffinTest {
CompiledQuery
cq
=
compiler
.
compile
(
"insert into balances values (1, 'USD', 356.12)"
);
Assert
.
assertEquals
(
CompiledQuery
.
INSERT
,
cq
.
getType
());
InsertStatement
insert
=
cq
.
getInsertStatement
();
try
(
InsertMethod
method
=
insert
.
createMethod
(
engine
,
sqlExecutionContext
))
{
try
(
InsertMethod
method
=
insert
.
createMethod
(
sqlExecutionContext
))
{
method
.
execute
();
method
.
commit
();
}
...
...
@@ -183,6 +184,7 @@ public class InsertTest extends AbstractGriffinTest {
String
expected
=
"cust_id\tccy\tbalance\n"
+
"1\tUSD\t356.120000000000\n"
;
sink
.
clear
();
try
(
TableReader
reader
=
engine
.
getReader
(
sqlExecutionContext
.
getCairoSecurityContext
(),
insert
.
getTableName
()))
{
printer
.
print
(
reader
.
getCursor
(),
reader
.
getMetadata
(),
true
);
TestUtils
.
assertEquals
(
expected
,
sink
);
...
...
@@ -258,7 +260,7 @@ public class InsertTest extends AbstractGriffinTest {
Assert
.
assertEquals
(
CompiledQuery
.
INSERT
,
cq
.
getType
());
InsertStatement
insert
=
cq
.
getInsertStatement
();
try
(
InsertMethod
method
=
insert
.
createMethod
(
engine
,
sqlExecutionContext
))
{
try
(
InsertMethod
method
=
insert
.
createMethod
(
sqlExecutionContext
))
{
// Assert.assertEquals(writer.getStructureVersion(), insert.getStructureVersion());
for
(
int
i
=
0
;
i
<
1_000_000
;
i
++)
{
bindVariableService
.
setInt
(
0
,
rnd
.
nextInt
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录