Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
88f3d08b
Q
Questdb
项目概览
jobily
/
Questdb
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
88f3d08b
编写于
11月 18, 2019
作者:
V
Vlad Ilyushchenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: empty line execution (spaces) #84
上级
526f5af7
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
84 addition
and
78 deletion
+84
-78
core/src/main/java/io/questdb/griffin/SqlCompiler.java
core/src/main/java/io/questdb/griffin/SqlCompiler.java
+59
-56
core/src/test/java/io/questdb/cairo/AbstractCairoTest.java
core/src/test/java/io/questdb/cairo/AbstractCairoTest.java
+1
-2
core/src/test/java/io/questdb/cairo/TableWriterTest.java
core/src/test/java/io/questdb/cairo/TableWriterTest.java
+6
-7
core/src/test/java/io/questdb/cutlass/http/IODispatcherTest.java
...c/test/java/io/questdb/cutlass/http/IODispatcherTest.java
+1
-2
core/src/test/java/io/questdb/cutlass/line/udp/LinuxLineProtoReceiverTest.java
.../questdb/cutlass/line/udp/LinuxLineProtoReceiverTest.java
+1
-2
core/src/test/java/io/questdb/griffin/FunctionParserTest.java
.../src/test/java/io/questdb/griffin/FunctionParserTest.java
+1
-2
core/src/test/java/io/questdb/griffin/SqlCompilerTest.java
core/src/test/java/io/questdb/griffin/SqlCompilerTest.java
+14
-5
core/src/test/java/io/questdb/griffin/SqlParserTest.java
core/src/test/java/io/questdb/griffin/SqlParserTest.java
+1
-2
未找到文件。
core/src/main/java/io/questdb/griffin/SqlCompiler.java
浏览文件 @
88f3d08b
...
...
@@ -45,31 +45,6 @@ public class SqlCompiler implements Closeable {
public
static
final
ObjList
<
String
>
sqlControlSymbols
=
new
ObjList
<>(
8
);
private
final
static
Log
LOG
=
LogFactory
.
getLog
(
SqlCompiler
.
class
);
private
static
final
IntList
castGroups
=
new
IntList
();
static
{
castGroups
.
extendAndSet
(
ColumnType
.
BOOLEAN
,
2
);
castGroups
.
extendAndSet
(
ColumnType
.
BYTE
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
SHORT
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
CHAR
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
INT
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
LONG
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
FLOAT
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
DOUBLE
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
DATE
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
TIMESTAMP
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
STRING
,
3
);
castGroups
.
extendAndSet
(
ColumnType
.
SYMBOL
,
3
);
castGroups
.
extendAndSet
(
ColumnType
.
BINARY
,
4
);
sqlControlSymbols
.
add
(
"("
);
sqlControlSymbols
.
add
(
";"
);
sqlControlSymbols
.
add
(
")"
);
sqlControlSymbols
.
add
(
","
);
sqlControlSymbols
.
add
(
"/*"
);
sqlControlSymbols
.
add
(
"*/"
);
sqlControlSymbols
.
add
(
"--"
);
}
private
final
SqlOptimiser
optimiser
;
private
final
SqlParser
parser
;
private
final
ObjectPool
<
ExpressionNode
>
sqlNodePool
;
...
...
@@ -96,7 +71,6 @@ public class SqlCompiler implements Closeable {
private
final
ExecutableMethod
createTableMethod
=
this
::
createTable
;
private
final
TextLoader
textLoader
;
private
final
FilesFacade
ff
;
public
SqlCompiler
(
CairoEngine
engine
)
{
this
(
engine
,
null
);
}
...
...
@@ -171,6 +145,41 @@ public class SqlCompiler implements Closeable {
}
}
@Override
public
void
close
()
{
Misc
.
free
(
path
);
Misc
.
free
(
textLoader
);
}
public
CompiledQuery
compile
(
CharSequence
query
)
throws
SqlException
{
return
compile
(
query
,
DefaultSqlExecutionContext
.
INSTANCE
);
}
@NotNull
public
CompiledQuery
compile
(
@NotNull
CharSequence
query
,
@NotNull
SqlExecutionContext
executionContext
)
throws
SqlException
{
clear
();
//
// these are quick executions that do not require building of a model
//
lexer
.
of
(
query
);
final
CharSequence
tok
=
SqlUtil
.
fetchNext
(
lexer
);
if
(
tok
==
null
)
{
throw
SqlException
.
$
(
0
,
"empty query"
);
}
final
KeywordBasedExecutor
executor
=
keywordBasedExecutors
.
get
(
tok
);
if
(
executor
==
null
)
{
return
compileUsingModel
(
executionContext
);
}
return
executor
.
execute
(
executionContext
);
}
public
CairoEngine
getEngine
()
{
return
engine
;
}
// Creates data type converter.
// INT and LONG NaN values are cast to their representation rather than Double or Float NaN.
private
static
RecordToRowCopier
assembleRecordToRowCopier
(
BytecodeAssembler
asm
,
ColumnTypes
from
,
RecordMetadata
to
,
ColumnFilter
toColumnFilter
)
{
...
...
@@ -632,36 +641,6 @@ public class SqlCompiler implements Closeable {
return
tok
;
}
@Override
public
void
close
()
{
Misc
.
free
(
path
);
Misc
.
free
(
textLoader
);
}
public
CompiledQuery
compile
(
CharSequence
query
)
throws
SqlException
{
return
compile
(
query
,
DefaultSqlExecutionContext
.
INSTANCE
);
}
@NotNull
public
CompiledQuery
compile
(
@NotNull
CharSequence
query
,
@NotNull
SqlExecutionContext
executionContext
)
throws
SqlException
{
clear
();
//
// these are quick executions that do not require building of a model
//
lexer
.
of
(
query
);
final
CharSequence
tok
=
SqlUtil
.
fetchNext
(
lexer
);
final
KeywordBasedExecutor
executor
=
keywordBasedExecutors
.
get
(
tok
);
if
(
executor
==
null
)
{
return
compileUsingModel
(
executionContext
);
}
return
executor
.
execute
(
executionContext
);
}
public
CairoEngine
getEngine
()
{
return
engine
;
}
private
CompiledQuery
alterTable
(
SqlExecutionContext
executionContext
)
throws
SqlException
{
CharSequence
tok
;
expectKeyword
(
lexer
,
"table"
);
...
...
@@ -1591,4 +1570,28 @@ public class SqlCompiler implements Closeable {
return
this
;
}
}
static
{
castGroups
.
extendAndSet
(
ColumnType
.
BOOLEAN
,
2
);
castGroups
.
extendAndSet
(
ColumnType
.
BYTE
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
SHORT
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
CHAR
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
INT
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
LONG
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
FLOAT
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
DOUBLE
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
DATE
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
TIMESTAMP
,
1
);
castGroups
.
extendAndSet
(
ColumnType
.
STRING
,
3
);
castGroups
.
extendAndSet
(
ColumnType
.
SYMBOL
,
3
);
castGroups
.
extendAndSet
(
ColumnType
.
BINARY
,
4
);
sqlControlSymbols
.
add
(
"("
);
sqlControlSymbols
.
add
(
";"
);
sqlControlSymbols
.
add
(
")"
);
sqlControlSymbols
.
add
(
","
);
sqlControlSymbols
.
add
(
"/*"
);
sqlControlSymbols
.
add
(
"*/"
);
sqlControlSymbols
.
add
(
"--"
);
}
}
core/src/test/java/io/questdb/cairo/AbstractCairoTest.java
浏览文件 @
88f3d08b
...
...
@@ -26,7 +26,6 @@ package io.questdb.cairo;
import
io.questdb.cairo.sql.RecordCursor
;
import
io.questdb.cairo.sql.RecordMetadata
;
import
io.questdb.cutlass.json.JsonException
;
import
io.questdb.log.Log
;
import
io.questdb.log.LogFactory
;
import
io.questdb.std.Files
;
...
...
@@ -50,7 +49,7 @@ public class AbstractCairoTest {
protected
static
CairoConfiguration
configuration
;
@BeforeClass
public
static
void
setUp
()
throws
JsonException
{
public
static
void
setUp
()
{
// it is necessary to initialise logger before tests start
// logger doesn't relinquish memory until JVM stops
// which causes memory leak detector to fail should logger be
...
...
core/src/test/java/io/questdb/cairo/TableWriterTest.java
浏览文件 @
88f3d08b
...
...
@@ -26,7 +26,6 @@ package io.questdb.cairo;
import
io.questdb.cairo.sql.Record
;
import
io.questdb.cairo.sql.RecordCursor
;
import
io.questdb.cutlass.json.JsonException
;
import
io.questdb.log.Log
;
import
io.questdb.log.LogFactory
;
import
io.questdb.std.*
;
...
...
@@ -2408,7 +2407,7 @@ public class TableWriterTest extends AbstractCairoTest {
}
}
private
void
create
(
FilesFacade
ff
,
int
partitionBy
,
int
N
)
throws
JsonException
{
private
void
create
(
FilesFacade
ff
,
int
partitionBy
,
int
N
)
{
try
(
TableModel
model
=
new
TableModel
(
new
DefaultCairoConfiguration
(
root
)
{
@Override
public
FilesFacade
getFilesFacade
()
{
...
...
@@ -2484,11 +2483,11 @@ public class TableWriterTest extends AbstractCairoTest {
return
ts
;
}
long
populateTable
(
FilesFacade
ff
)
throws
NumericException
,
JsonException
{
long
populateTable
(
FilesFacade
ff
)
throws
NumericException
{
return
populateTable
(
ff
,
PartitionBy
.
DAY
);
}
long
populateTable
(
FilesFacade
ff
,
int
partitionBy
)
throws
NumericException
,
JsonException
{
long
populateTable
(
FilesFacade
ff
,
int
partitionBy
)
throws
NumericException
{
int
N
=
10000
;
long
used
=
Unsafe
.
getMemUsed
();
long
fileCount
=
ff
.
getOpenFileCount
();
...
...
@@ -2499,7 +2498,7 @@ public class TableWriterTest extends AbstractCairoTest {
return
ts
;
}
private
long
populateTable0
(
FilesFacade
ff
,
int
N
)
throws
NumericException
,
JsonException
{
private
long
populateTable0
(
FilesFacade
ff
,
int
N
)
throws
NumericException
{
try
(
TableWriter
writer
=
new
TableWriter
(
new
DefaultCairoConfiguration
(
root
)
{
@Override
public
FilesFacade
getFilesFacade
()
{
...
...
@@ -2675,7 +2674,7 @@ public class TableWriterTest extends AbstractCairoTest {
});
}
private
long
testAppendNulls
(
Rnd
rnd
,
long
ts
)
throws
JsonException
{
private
long
testAppendNulls
(
Rnd
rnd
,
long
ts
)
{
final
int
blobLen
=
64
*
1024
;
long
blob
=
Unsafe
.
malloc
(
blobLen
);
try
(
TableWriter
writer
=
new
TableWriter
(
new
DefaultCairoConfiguration
(
root
)
{
...
...
@@ -3117,7 +3116,7 @@ public class TableWriterTest extends AbstractCairoTest {
});
}
private
void
testTruncateRecoverableFailure
(
FilesFacade
ff
)
throws
NumericException
,
JsonException
{
private
void
testTruncateRecoverableFailure
(
FilesFacade
ff
)
throws
NumericException
{
final
int
N
=
1000
;
create
(
ff
,
PartitionBy
.
DAY
,
N
*
2
);
Rnd
rnd
=
new
Rnd
();
...
...
core/src/test/java/io/questdb/cutlass/http/IODispatcherTest.java
浏览文件 @
88f3d08b
...
...
@@ -31,7 +31,6 @@ import io.questdb.cutlass.http.processors.JsonQueryProcessor;
import
io.questdb.cutlass.http.processors.StaticContentProcessor
;
import
io.questdb.cutlass.http.processors.StaticContentProcessorConfiguration
;
import
io.questdb.cutlass.http.processors.TextImportProcessor
;
import
io.questdb.cutlass.json.JsonException
;
import
io.questdb.log.Log
;
import
io.questdb.log.LogFactory
;
import
io.questdb.mp.*
;
...
...
@@ -284,7 +283,7 @@ public class IODispatcherTest {
}
@Test
public
void
testHttpLong256AndCharImport
()
throws
JsonException
{
public
void
testHttpLong256AndCharImport
()
{
// this script uploads text file:
// 0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060,a
// 0x19f1df2c7ee6b464720ad28e903aeda1a5ad8780afc22f0b960827bd4fcf656d,b
...
...
core/src/test/java/io/questdb/cutlass/line/udp/LinuxLineProtoReceiverTest.java
浏览文件 @
88f3d08b
...
...
@@ -26,7 +26,6 @@ package io.questdb.cutlass.line.udp;
import
io.questdb.cairo.*
;
import
io.questdb.cairo.security.AllowAllCairoSecurityContext
;
import
io.questdb.cutlass.json.JsonException
;
import
io.questdb.mp.Job
;
import
io.questdb.mp.SOCountDownLatch
;
import
io.questdb.mp.Worker
;
...
...
@@ -204,7 +203,7 @@ public class LinuxLineProtoReceiverTest extends AbstractCairoTest {
assertReceive
(
configuration
,
factory
);
}
private
void
assertConstructorFail
(
LineUdpReceiverConfiguration
receiverCfg
,
ReceiverFactory
factory
)
throws
JsonException
{
private
void
assertConstructorFail
(
LineUdpReceiverConfiguration
receiverCfg
,
ReceiverFactory
factory
)
{
try
(
CairoEngine
engine
=
new
CairoEngine
(
new
DefaultCairoConfiguration
(
root
),
null
))
{
try
{
factory
.
createReceiver
(
receiverCfg
,
engine
,
AllowAllCairoSecurityContext
.
INSTANCE
);
...
...
core/src/test/java/io/questdb/griffin/FunctionParserTest.java
浏览文件 @
88f3d08b
...
...
@@ -27,7 +27,6 @@ package io.questdb.griffin;
import
io.questdb.cairo.*
;
import
io.questdb.cairo.sql.Function
;
import
io.questdb.cairo.sql.Record
;
import
io.questdb.cutlass.json.JsonException
;
import
io.questdb.griffin.engine.functions.*
;
import
io.questdb.griffin.engine.functions.bool.InStrFunctionFactory
;
import
io.questdb.griffin.engine.functions.bool.NotFunctionFactory
;
...
...
@@ -931,7 +930,7 @@ public class FunctionParserTest extends BaseFunctionFactoryTest {
}
@Test
public
void
testNoArgFunction
()
throws
SqlException
,
JsonException
{
public
void
testNoArgFunction
()
throws
SqlException
{
functions
.
add
(
new
SysdateFunctionFactory
());
functions
.
add
(
new
ToStrDateFunctionFactory
());
FunctionParser
functionParser
=
new
FunctionParser
(
...
...
core/src/test/java/io/questdb/griffin/SqlCompilerTest.java
浏览文件 @
88f3d08b
...
...
@@ -28,7 +28,6 @@ import io.questdb.cairo.*;
import
io.questdb.cairo.security.AllowAllCairoSecurityContext
;
import
io.questdb.cairo.sql.RecordCursor
;
import
io.questdb.cairo.sql.RecordCursorFactory
;
import
io.questdb.cutlass.json.JsonException
;
import
io.questdb.griffin.engine.functions.rnd.SharedRandom
;
import
io.questdb.log.Log
;
import
io.questdb.log.LogFactory
;
...
...
@@ -96,7 +95,7 @@ public class SqlCompilerTest extends AbstractGriffinTest {
}
@Test
public
void
testCannotCreateTable
()
throws
JsonException
{
public
void
testCannotCreateTable
()
{
FilesFacade
ff
=
new
FilesFacadeImpl
()
{
@Override
...
...
@@ -1808,7 +1807,7 @@ public class SqlCompilerTest extends AbstractGriffinTest {
TestUtils
.
assertMemoryLeak
(
new
TestUtils
.
LeakProneCode
()
{
@Override
public
void
run
()
throws
JsonException
{
public
void
run
()
{
String
sql
=
"create table y as ("
+
"select * from random_cursor("
+
" 10000,"
+
// record count
...
...
@@ -1865,7 +1864,7 @@ public class SqlCompilerTest extends AbstractGriffinTest {
TestUtils
.
assertMemoryLeak
(
new
TestUtils
.
LeakProneCode
()
{
@Override
public
void
run
()
throws
JsonException
{
public
void
run
()
{
String
sql
=
"create table y as ("
+
"select * from random_cursor("
+
" 10000,"
+
// record count
...
...
@@ -3085,6 +3084,16 @@ public class SqlCompilerTest extends AbstractGriffinTest {
}
}
@Test
public
void
testEmptyQuery
()
{
try
{
compiler
.
compile
(
" "
);
}
catch
(
SqlException
e
)
{
Assert
.
assertEquals
(
0
,
e
.
getPosition
());
TestUtils
.
assertContains
(
e
.
getFlyweightMessage
(),
"empty query"
);
}
}
private
void
assertCast
(
String
expectedData
,
String
expectedMeta
,
String
sql
)
throws
SqlException
{
compiler
.
compile
(
sql
);
try
(
TableReader
reader
=
engine
.
getReader
(
AllowAllCairoSecurityContext
.
INSTANCE
,
"y"
,
TableUtils
.
ANY_TABLE_VERSION
))
{
...
...
@@ -3349,7 +3358,7 @@ public class SqlCompilerTest extends AbstractGriffinTest {
}
}
private
void
assertInsertAsSelectIOError
(
AtomicBoolean
inError
,
FilesFacade
ff
)
throws
SqlException
,
JsonException
{
private
void
assertInsertAsSelectIOError
(
AtomicBoolean
inError
,
FilesFacade
ff
)
throws
SqlException
{
DefaultCairoConfiguration
configuration
=
new
DefaultCairoConfiguration
(
root
)
{
@Override
public
FilesFacade
getFilesFacade
()
{
...
...
core/src/test/java/io/questdb/griffin/SqlParserTest.java
浏览文件 @
88f3d08b
...
...
@@ -26,7 +26,6 @@ package io.questdb.griffin;
import
io.questdb.cairo.*
;
import
io.questdb.cairo.security.AllowAllCairoSecurityContext
;
import
io.questdb.cutlass.json.JsonException
;
import
io.questdb.griffin.model.ExecutionModel
;
import
io.questdb.griffin.model.QueryModel
;
import
io.questdb.std.*
;
...
...
@@ -4836,7 +4835,7 @@ public class SqlParserTest extends AbstractGriffinTest {
}
@Test
public
void
testTableNameCannotOpen
()
throws
JsonException
{
public
void
testTableNameCannotOpen
()
{
final
FilesFacade
ff
=
new
FilesFacadeImpl
()
{
@Override
public
long
openRO
(
LPSZ
name
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录