Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
9dc2f3da
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,发现更多精彩内容 >>
提交
9dc2f3da
编写于
5月 25, 2019
作者:
V
Vlad Ilyushchenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GRIFFIN: minor API refactoring
上级
345ddf24
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
366 addition
and
347 deletion
+366
-347
core/src/main/java/com/questdb/cairo/TableWriter.java
core/src/main/java/com/questdb/cairo/TableWriter.java
+4
-0
core/src/main/java/com/questdb/cairo/sql/RecordCursorFactory.java
.../main/java/com/questdb/cairo/sql/RecordCursorFactory.java
+4
-0
core/src/main/java/com/questdb/griffin/SqlCompiler.java
core/src/main/java/com/questdb/griffin/SqlCompiler.java
+9
-5
core/src/test/java/com/questdb/cairo/CairoTestUtils.java
core/src/test/java/com/questdb/cairo/CairoTestUtils.java
+2
-2
core/src/test/java/com/questdb/cairo/TableReadFailTest.java
core/src/test/java/com/questdb/cairo/TableReadFailTest.java
+3
-3
core/src/test/java/com/questdb/cairo/TableReaderTailRecordCursorTest.java
...va/com/questdb/cairo/TableReaderTailRecordCursorTest.java
+3
-3
core/src/test/java/com/questdb/cairo/TableReaderTest.java
core/src/test/java/com/questdb/cairo/TableReaderTest.java
+9
-9
core/src/test/java/com/questdb/cairo/TableWriterTest.java
core/src/test/java/com/questdb/cairo/TableWriterTest.java
+8
-8
core/src/test/java/com/questdb/cairo/map/FastMapTest.java
core/src/test/java/com/questdb/cairo/map/FastMapTest.java
+2
-2
core/src/test/java/com/questdb/cairo/map/RecordValueSinkFactoryTest.java
...ava/com/questdb/cairo/map/RecordValueSinkFactoryTest.java
+3
-3
core/src/test/java/com/questdb/cairo/pool/ReaderPoolTest.java
.../src/test/java/com/questdb/cairo/pool/ReaderPoolTest.java
+3
-3
core/src/test/java/com/questdb/cairo/pool/WriterPoolTest.java
.../src/test/java/com/questdb/cairo/pool/WriterPoolTest.java
+2
-2
core/src/test/java/com/questdb/cutlass/text/TextLoaderTest.java
...rc/test/java/com/questdb/cutlass/text/TextLoaderTest.java
+38
-39
core/src/test/java/com/questdb/griffin/AbstractGriffinTest.java
...rc/test/java/com/questdb/griffin/AbstractGriffinTest.java
+1
-1
core/src/test/java/com/questdb/griffin/AlterTableAddColumnTest.java
...est/java/com/questdb/griffin/AlterTableAddColumnTest.java
+2
-2
core/src/test/java/com/questdb/griffin/ExpressionParserTest.java
...c/test/java/com/questdb/griffin/ExpressionParserTest.java
+2
-2
core/src/test/java/com/questdb/griffin/SqlCodeGeneratorTest.java
...c/test/java/com/questdb/griffin/SqlCodeGeneratorTest.java
+3
-3
core/src/test/java/com/questdb/griffin/SqlCompilerTest.java
core/src/test/java/com/questdb/griffin/SqlCompilerTest.java
+75
-69
core/src/test/java/com/questdb/griffin/SqlParserTest.java
core/src/test/java/com/questdb/griffin/SqlParserTest.java
+184
-182
core/src/test/java/com/questdb/griffin/WhereClauseParserTest.java
.../test/java/com/questdb/griffin/WhereClauseParserTest.java
+2
-2
core/src/test/java/com/questdb/griffin/engine/functions/eq/EqStrFunctionFactoryTest.java
...griffin/engine/functions/eq/EqStrFunctionFactoryTest.java
+2
-2
core/src/test/java/com/questdb/griffin/engine/functions/rnd/RndBinFunctionFactoryTest.java
...iffin/engine/functions/rnd/RndBinFunctionFactoryTest.java
+2
-2
core/src/test/java/com/questdb/griffin/engine/groupby/SampleByTest.java
...java/com/questdb/griffin/engine/groupby/SampleByTest.java
+3
-3
未找到文件。
core/src/main/java/com/questdb/cairo/TableWriter.java
浏览文件 @
9dc2f3da
...
...
@@ -445,6 +445,10 @@ public class TableWriter implements Closeable {
return
rowFunction
.
newRow
(
timestamp
);
}
public
Row
newRow
()
{
return
newRow
(
0L
);
}
public
void
removeColumn
(
CharSequence
name
)
{
checkDistressed
();
...
...
core/src/main/java/com/questdb/cairo/sql/RecordCursorFactory.java
浏览文件 @
9dc2f3da
...
...
@@ -34,6 +34,10 @@ public interface RecordCursorFactory extends Closeable {
RecordCursor
getCursor
(
BindVariableService
bindVariableService
);
default
RecordCursor
getCursor
()
{
return
getCursor
(
null
);
}
RecordMetadata
getMetadata
();
boolean
isRandomAccessCursor
();
...
...
core/src/main/java/com/questdb/griffin/SqlCompiler.java
浏览文件 @
9dc2f3da
...
...
@@ -65,12 +65,13 @@ public class SqlCompiler implements Closeable {
private
final
TableStructureAdapter
tableStructureAdapter
=
new
TableStructureAdapter
();
private
final
ExecutableMethod
createTableMethod
=
this
::
createTable
;
public
SqlCompiler
(
CairoEngine
engine
,
CairoConfiguration
configuration
)
{
this
(
engine
,
configuration
,
null
);
public
SqlCompiler
(
CairoEngine
engine
)
{
this
(
engine
,
null
);
}
public
SqlCompiler
(
CairoEngine
engine
,
CairoConfiguration
configuration
,
@Nullable
CairoWorkScheduler
workScheduler
)
{
public
SqlCompiler
(
CairoEngine
engine
,
@Nullable
CairoWorkScheduler
workScheduler
)
{
this
.
engine
=
engine
;
this
.
configuration
=
engine
.
getConfiguration
();
this
.
workScheduler
=
workScheduler
;
this
.
sqlNodePool
=
new
ObjectPool
<>(
ExpressionNode
.
FACTORY
,
configuration
.
getSqlExpressionPoolCapacity
());
this
.
queryColumnPool
=
new
ObjectPool
<>(
QueryColumn
.
FACTORY
,
configuration
.
getSqlColumnPoolCapacity
());
...
...
@@ -82,7 +83,6 @@ public class SqlCompiler implements Closeable {
this
.
lexer
=
new
GenericLexer
(
configuration
.
getSqlLexerPoolCapacity
());
final
FunctionParser
functionParser
=
new
FunctionParser
(
configuration
,
ServiceLoader
.
load
(
FunctionFactory
.
class
));
this
.
codeGenerator
=
new
SqlCodeGenerator
(
engine
,
configuration
,
functionParser
);
this
.
configuration
=
configuration
;
configureLexer
(
lexer
);
...
...
@@ -137,6 +137,10 @@ public class SqlCompiler implements Closeable {
Misc
.
free
(
sqlCache
);
}
public
RecordCursorFactory
compile
(
CharSequence
query
)
throws
SqlException
{
return
compile
(
query
,
null
);
}
public
RecordCursorFactory
compile
(
CharSequence
query
,
BindVariableService
bindVariableService
)
throws
SqlException
{
//
...
...
@@ -876,7 +880,7 @@ public class SqlCompiler implements Closeable {
private
void
copyUnordered
(
RecordCursor
cursor
,
TableWriter
writer
,
RecordToRowCopier
ccopier
)
{
final
Record
record
=
cursor
.
getRecord
();
while
(
cursor
.
hasNext
())
{
TableWriter
.
Row
row
=
writer
.
newRow
(
0
);
TableWriter
.
Row
row
=
writer
.
newRow
();
ccopier
.
copy
(
record
,
row
);
row
.
append
();
}
...
...
core/src/test/java/com/questdb/cairo/CairoTestUtils.java
浏览文件 @
9dc2f3da
...
...
@@ -5,7 +5,7 @@
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-201
8
Appsicle
* Copyright (C) 2014-201
9
Appsicle
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
...
...
@@ -65,7 +65,7 @@ public class CairoTestUtils {
try
(
TableWriter
writer
=
new
TableWriter
(
AbstractCairoTest
.
configuration
,
"x"
))
{
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
TableWriter
.
Row
row
=
writer
.
newRow
(
0
);
TableWriter
.
Row
row
=
writer
.
newRow
();
row
.
putByte
(
0
,
rnd
.
nextByte
());
row
.
putShort
(
1
,
rnd
.
nextShort
());
...
...
core/src/test/java/com/questdb/cairo/TableReadFailTest.java
浏览文件 @
9dc2f3da
...
...
@@ -5,7 +5,7 @@
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-201
8
Appsicle
* Copyright (C) 2014-201
9
Appsicle
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
...
...
@@ -85,7 +85,7 @@ public class TableReadFailTest extends AbstractCairoTest {
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
r
=
w
.
newRow
(
0
);
TableWriter
.
Row
r
=
w
.
newRow
();
r
.
putInt
(
0
,
rnd
.
nextInt
());
r
.
putLong
(
1
,
rnd
.
nextLong
());
r
.
append
();
...
...
@@ -144,7 +144,7 @@ public class TableReadFailTest extends AbstractCairoTest {
try
(
TableWriter
w
=
new
TableWriter
(
configuration
,
"x"
))
{
// add more data
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
r
=
w
.
newRow
(
0
);
TableWriter
.
Row
r
=
w
.
newRow
();
r
.
putInt
(
0
,
rnd
.
nextInt
());
r
.
putLong
(
1
,
rnd
.
nextLong
());
r
.
append
();
...
...
core/src/test/java/com/questdb/cairo/TableReaderTailRecordCursorTest.java
浏览文件 @
9dc2f3da
...
...
@@ -40,7 +40,7 @@ import java.util.concurrent.atomic.AtomicInteger;
public
class
TableReaderTailRecordCursorTest
extends
AbstractCairoTest
{
private
final
static
Engine
engine
=
new
Engine
(
configuration
);
private
final
static
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
);
private
final
static
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
);
private
final
static
BindVariableService
bindVariableService
=
new
BindVariableService
();
@Test
...
...
@@ -214,7 +214,7 @@ public class TableReaderTailRecordCursorTest extends AbstractCairoTest {
final
int
n
=
1000
;
TestUtils
.
assertMemoryLeak
(()
->
{
try
{
compiler
.
compile
(
"create table xyz (sequence INT, event BINARY, ts LONG, stamp TIMESTAMP) timestamp(stamp) partition by "
+
PartitionBy
.
toString
(
partitionBy
)
,
null
);
compiler
.
compile
(
"create table xyz (sequence INT, event BINARY, ts LONG, stamp TIMESTAMP) timestamp(stamp) partition by "
+
PartitionBy
.
toString
(
partitionBy
));
try
(
TableWriter
writer
=
engine
.
getWriter
(
"xyz"
))
{
long
ts
=
0
;
...
...
@@ -275,7 +275,7 @@ public class TableReaderTailRecordCursorTest extends AbstractCairoTest {
final
int
n
=
1000
;
TestUtils
.
assertMemoryLeak
(()
->
{
try
{
compiler
.
compile
(
"create table xyz (sequence INT, event BINARY, ts LONG, stamp TIMESTAMP) timestamp(stamp) partition by "
+
PartitionBy
.
toString
(
partitionBy
)
,
null
);
compiler
.
compile
(
"create table xyz (sequence INT, event BINARY, ts LONG, stamp TIMESTAMP) timestamp(stamp) partition by "
+
PartitionBy
.
toString
(
partitionBy
));
try
(
TableWriter
writer
=
engine
.
getWriter
(
"xyz"
))
{
long
ts
=
0
;
...
...
core/src/test/java/com/questdb/cairo/TableReaderTest.java
浏览文件 @
9dc2f3da
...
...
@@ -1589,7 +1589,7 @@ public class TableReaderTest extends AbstractCairoTest {
startBarrier
.
await
();
try
(
TableWriter
writer
=
new
TableWriter
(
configuration
,
"w"
))
{
for
(
int
i
=
0
;
i
<
N
*
scale
;
i
++)
{
TableWriter
.
Row
row
=
writer
.
newRow
(
0
);
TableWriter
.
Row
row
=
writer
.
newRow
();
row
.
putLong
(
0
,
list
.
getQuick
(
i
%
N
));
row
.
append
();
writer
.
commit
();
...
...
@@ -1682,7 +1682,7 @@ public class TableReaderTest extends AbstractCairoTest {
Rnd
rnd
=
new
Rnd
();
try
(
TableWriter
writer
=
new
TableWriter
(
configuration
,
"x"
))
{
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
r
=
writer
.
newRow
(
0
);
TableWriter
.
Row
r
=
writer
.
newRow
();
r
.
putLong
(
0
,
rnd
.
nextLong
());
r
.
append
();
}
...
...
@@ -1711,7 +1711,7 @@ public class TableReaderTest extends AbstractCairoTest {
try
(
TableWriter
writer
=
new
TableWriter
(
configuration
,
"all"
))
{
int
col
=
writer
.
getMetadata
().
getColumnIndex
(
"str"
);
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
r
=
writer
.
newRow
(
0
);
TableWriter
.
Row
r
=
writer
.
newRow
();
CharSequence
chars
=
rnd
.
nextChars
(
15
);
r
.
putStr
(
col
,
chars
,
2
,
10
);
r
.
append
();
...
...
@@ -1721,7 +1721,7 @@ public class TableReaderTest extends AbstractCairoTest {
// add more rows for good measure and rollback
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
r
=
writer
.
newRow
(
0
);
TableWriter
.
Row
r
=
writer
.
newRow
();
CharSequence
chars
=
rnd
.
nextChars
(
15
);
r
.
putStr
(
col
,
chars
,
2
,
10
);
r
.
append
();
...
...
@@ -2053,7 +2053,7 @@ public class TableReaderTest extends AbstractCairoTest {
}
try
(
TableWriter
writer
=
new
TableWriter
(
configuration
,
"tab"
))
{
TableWriter
.
Row
r
=
writer
.
newRow
(
0
);
TableWriter
.
Row
r
=
writer
.
newRow
();
r
.
putSym
(
0
,
"hello"
);
r
.
append
();
...
...
@@ -2393,7 +2393,7 @@ public class TableReaderTest extends AbstractCairoTest {
// populate table and delete column
try
(
TableWriter
writer
=
new
TableWriter
(
configuration
,
"x"
))
{
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
row
=
writer
.
newRow
(
0
);
TableWriter
.
Row
row
=
writer
.
newRow
();
row
.
putStr
(
0
,
rnd
.
nextChars
(
10
));
row
.
putStr
(
1
,
rnd
.
nextChars
(
15
));
row
.
append
();
...
...
@@ -2496,7 +2496,7 @@ public class TableReaderTest extends AbstractCairoTest {
// populate table and delete column
try
(
TableWriter
writer
=
new
TableWriter
(
configuration
,
"x"
))
{
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
row
=
writer
.
newRow
(
0
);
TableWriter
.
Row
row
=
writer
.
newRow
();
row
.
putSym
(
0
,
rnd
.
nextChars
(
10
));
row
.
putStr
(
1
,
rnd
.
nextChars
(
15
));
row
.
append
();
...
...
@@ -2529,7 +2529,7 @@ public class TableReaderTest extends AbstractCairoTest {
writer
.
addColumn
(
"b"
,
ColumnType
.
STRING
);
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
row
=
writer
.
newRow
(
0
);
TableWriter
.
Row
row
=
writer
.
newRow
();
row
.
putSym
(
0
,
rnd
.
nextChars
(
10
));
row
.
putStr
(
1
,
rnd
.
nextChars
(
15
));
row
.
append
();
...
...
@@ -3013,7 +3013,7 @@ public class TableReaderTest extends AbstractCairoTest {
private
void
appendTwoSymbols
(
TableWriter
writer
,
Rnd
rnd
)
{
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
TableWriter
.
Row
row
=
writer
.
newRow
(
0
);
TableWriter
.
Row
row
=
writer
.
newRow
();
row
.
putSym
(
0
,
rnd
.
nextChars
(
10
));
row
.
putSym
(
1
,
rnd
.
nextChars
(
15
));
row
.
append
();
...
...
core/src/test/java/com/questdb/cairo/TableWriterTest.java
浏览文件 @
9dc2f3da
...
...
@@ -604,7 +604,7 @@ public class TableWriterTest extends AbstractCairoTest {
try
(
TableWriter
w
=
new
TableWriter
(
configuration
,
"x"
))
{
final
Rnd
rnd
=
new
Rnd
();
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
r
=
w
.
newRow
(
0
);
TableWriter
.
Row
r
=
w
.
newRow
();
r
.
putSym
(
0
,
rnd
.
nextChars
(
3
));
r
.
putStr
(
1
,
rnd
.
nextChars
(
10
));
r
.
append
();
...
...
@@ -619,7 +619,7 @@ public class TableWriterTest extends AbstractCairoTest {
}
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
r
=
w
.
newRow
(
0
);
TableWriter
.
Row
r
=
w
.
newRow
();
r
.
putSym
(
0
,
rnd
.
nextChars
(
3
));
r
.
putStr
(
1
,
rnd
.
nextChars
(
10
));
r
.
append
();
...
...
@@ -646,7 +646,7 @@ public class TableWriterTest extends AbstractCairoTest {
try
(
TableWriter
w
=
new
TableWriter
(
configuration
,
"x"
))
{
final
Rnd
rnd
=
new
Rnd
();
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
r
=
w
.
newRow
(
0
);
TableWriter
.
Row
r
=
w
.
newRow
();
r
.
putSym
(
0
,
rnd
.
nextChars
(
3
));
r
.
putStr
(
1
,
rnd
.
nextChars
(
10
));
r
.
append
();
...
...
@@ -661,7 +661,7 @@ public class TableWriterTest extends AbstractCairoTest {
}
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
r
=
w
.
newRow
(
0
);
TableWriter
.
Row
r
=
w
.
newRow
();
r
.
putSym
(
0
,
rnd
.
nextChars
(
3
));
r
.
putStr
(
1
,
rnd
.
nextChars
(
10
));
r
.
append
();
...
...
@@ -2278,7 +2278,7 @@ public class TableWriterTest extends AbstractCairoTest {
Rnd
rnd
=
new
Rnd
();
try
(
TableWriter
writer
=
new
TableWriter
(
configuration
,
name
))
{
for
(
int
i
=
0
;
i
<
1000000
;
i
++)
{
TableWriter
.
Row
r
=
writer
.
newRow
(
0
);
TableWriter
.
Row
r
=
writer
.
newRow
();
r
.
putStr
(
0
,
rnd
.
nextChars
(
5
));
r
.
append
();
}
...
...
@@ -2367,7 +2367,7 @@ public class TableWriterTest extends AbstractCairoTest {
int
price
=
writer
.
getColumnIndex
(
"price"
);
for
(
int
i
=
0
;
i
<
10000
;
i
++)
{
TableWriter
.
Row
r
=
writer
.
newRow
(
0
);
TableWriter
.
Row
r
=
writer
.
newRow
();
r
.
putInt
(
productId
,
rnd
.
nextPositiveInt
());
r
.
putStr
(
productName
,
rnd
.
nextString
(
10
));
r
.
putSym
(
supplier
,
rnd
.
nextString
(
4
));
...
...
@@ -2824,7 +2824,7 @@ public class TableWriterTest extends AbstractCairoTest {
boolean
fail
=
rnd
.
nextBoolean
();
if
(
fail
)
{
try
{
writer
.
newRow
(
0
);
writer
.
newRow
();
Assert
.
fail
();
}
catch
(
CairoException
ignore
)
{
failureCount
++;
...
...
@@ -3016,7 +3016,7 @@ public class TableWriterTest extends AbstractCairoTest {
Assert
.
assertEquals
(
cacheFlag
,
writer
.
isSymbolMapWriterCached
(
0
));
Assert
.
assertNotEquals
(
cacheFlag
,
writer
.
isSymbolMapWriterCached
(
2
));
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
r
=
writer
.
newRow
(
0
);
TableWriter
.
Row
r
=
writer
.
newRow
();
r
.
putSym
(
0
,
rnd
.
nextChars
(
5
));
r
.
putStr
(
1
,
rnd
.
nextChars
(
10
));
r
.
append
();
...
...
core/src/test/java/com/questdb/cairo/map/FastMapTest.java
浏览文件 @
9dc2f3da
...
...
@@ -5,7 +5,7 @@
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-201
8
Appsicle
* Copyright (C) 2014-201
9
Appsicle
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
...
...
@@ -845,7 +845,7 @@ public class FastMapTest extends AbstractCairoTest {
try
(
TableWriter
writer
=
new
TableWriter
(
configuration
,
"x"
))
{
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
TableWriter
.
Row
row
=
writer
.
newRow
(
0
);
TableWriter
.
Row
row
=
writer
.
newRow
();
row
.
putByte
(
0
,
rnd
.
nextByte
());
row
.
putShort
(
1
,
rnd
.
nextShort
());
...
...
core/src/test/java/com/questdb/cairo/map/RecordValueSinkFactoryTest.java
浏览文件 @
9dc2f3da
...
...
@@ -5,7 +5,7 @@
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-201
8
Appsicle
* Copyright (C) 2014-201
9
Appsicle
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
...
...
@@ -57,7 +57,7 @@ public class RecordValueSinkFactoryTest extends AbstractCairoTest {
try
(
TableWriter
writer
=
new
TableWriter
(
configuration
,
"all"
))
{
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
row
=
writer
.
newRow
(
0
);
TableWriter
.
Row
row
=
writer
.
newRow
();
row
.
putInt
(
0
,
rnd
.
nextInt
());
row
.
putShort
(
1
,
rnd
.
nextShort
());
row
.
putByte
(
2
,
rnd
.
nextByte
());
...
...
@@ -141,7 +141,7 @@ public class RecordValueSinkFactoryTest extends AbstractCairoTest {
try
(
TableWriter
writer
=
new
TableWriter
(
configuration
,
"all"
))
{
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
TableWriter
.
Row
row
=
writer
.
newRow
(
0
);
TableWriter
.
Row
row
=
writer
.
newRow
();
row
.
putInt
(
0
,
rnd
.
nextInt
());
row
.
putShort
(
1
,
rnd
.
nextShort
());
row
.
putByte
(
2
,
rnd
.
nextByte
());
...
...
core/src/test/java/com/questdb/cairo/pool/ReaderPoolTest.java
浏览文件 @
9dc2f3da
...
...
@@ -5,7 +5,7 @@
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-201
8
Appsicle
* Copyright (C) 2014-201
9
Appsicle
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
...
...
@@ -252,7 +252,7 @@ public class ReaderPoolTest extends AbstractCairoTest {
try
(
TableWriter
w
=
new
TableWriter
(
configuration
,
names
[
i
]))
{
for
(
int
k
=
0
;
k
<
10
;
k
++)
{
TableWriter
.
Row
r
=
w
.
newRow
(
0
);
TableWriter
.
Row
r
=
w
.
newRow
();
r
.
putDate
(
0
,
dataRnd
.
nextLong
());
r
.
append
();
}
...
...
@@ -544,7 +544,7 @@ public class ReaderPoolTest extends AbstractCairoTest {
try
(
TableWriter
w
=
new
TableWriter
(
configuration
,
names
[
i
]))
{
for
(
int
k
=
0
;
k
<
10
;
k
++)
{
TableWriter
.
Row
r
=
w
.
newRow
(
0
);
TableWriter
.
Row
r
=
w
.
newRow
();
r
.
putDate
(
0
,
dataRnd
.
nextLong
());
r
.
append
();
}
...
...
core/src/test/java/com/questdb/cairo/pool/WriterPoolTest.java
浏览文件 @
9dc2f3da
...
...
@@ -5,7 +5,7 @@
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-201
8
Appsicle
* Copyright (C) 2014-201
9
Appsicle
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
...
...
@@ -456,7 +456,7 @@ public class WriterPoolTest extends AbstractCairoTest {
TableWriter
writer
=
new
TableWriter
(
configuration
,
"x"
,
null
,
false
,
DefaultLifecycleManager
.
INSTANCE
);
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
TableWriter
.
Row
row
=
writer
.
newRow
(
0
);
TableWriter
.
Row
row
=
writer
.
newRow
();
row
.
putDate
(
0
,
i
);
row
.
append
();
}
...
...
core/src/test/java/com/questdb/cutlass/text/TextLoaderTest.java
浏览文件 @
9dc2f3da
...
...
@@ -50,7 +50,7 @@ import java.nio.charset.StandardCharsets;
public class TextLoaderTest extends AbstractCairoTest {
private static final Engine engine = new Engine(configuration);
private static final SqlCompiler compiler = new SqlCompiler(engine
, configuration
);
private static final SqlCompiler compiler = new SqlCompiler(engine);
private static final ByteManipulator ENTITY_MANIPULATOR = (index, len, b) -> b;
@AfterClass
...
...
@@ -465,7 +465,7 @@ public class TextLoaderTest extends AbstractCairoTest {
", h long" +
", i boolean" +
", k long" +
", t timestamp)"
, null
);
", t timestamp)");
configureLoaderDefaults(textLoader, (byte) -1, Atomicity.SKIP_ROW, true);
try (TableWriter ignore = engine.getWriter("test")) {
...
...
@@ -1538,7 +1538,7 @@ public class TextLoaderTest extends AbstractCairoTest {
", h long" +
", i boolean" +
", k long" +
", t timestamp)"
, null
);
", t timestamp)");
configureLoaderDefaults(textLoader, (byte) -1, Atomicity.SKIP_ROW, true);
playText(
...
...
@@ -1991,29 +1991,6 @@ public class TextLoaderTest extends AbstractCairoTest {
});
}
@Test
public void testWriteToExistingCannotConvertDate() throws Exception {
assertNoLeak(textLoader -> {
String csv = "abcd,10\n" +
"efg,45\n" +
"werop,90\n";
// we would mis-detect type and have no date parser to try loading data with
String expected = "a\tb\n" +
"abcd\t\n" +
"efg\t\n" +
"werop\t\n";
compiler.compile("create table test(a string, b date)", null);
configureLoaderDefaults(textLoader);
playText(textLoader, csv, 1024,
expected,
"{\"columnCount\":2,\"columns\":[{\"index\":0,\"name\":\"a\",\"type\":\"STRING\"},{\"index\":1,\"name\":\"b\",\"type\":\"DATE\"}],\"timestampIndex\":-1}",
3,
3);
});
}
@Test
public void testWriteIntToBlob() throws Exception {
assertNoLeak(textLoader -> {
...
...
@@ -2026,7 +2003,7 @@ public class TextLoaderTest extends AbstractCairoTest {
"efg\t45\t\n" +
"werop\t90\t\n";
compiler.compile("create table test(a string, d binary)"
, null
);
compiler.compile("create table test(a string, d binary)");
configureLoaderDefaults(textLoader);
try {
playText(textLoader, csv, 1024,
...
...
@@ -2042,28 +2019,28 @@ public class TextLoaderTest extends AbstractCairoTest {
}
@Test
public void testWriteTo
TableWithBlob
() throws Exception {
public void testWriteTo
ExistingCannotConvertDate
() throws Exception {
assertNoLeak(textLoader -> {
String csv = "abcd,10\n" +
"efg,45\n" +
"werop,90\n";
String expected = "a\tb\td\n" +
"abcd\t10\t\n" +
"efg\t45\t\n" +
"werop\t90\t\n";
// we would mis-detect type and have no date parser to try loading data with
String expected = "a\tb\n" +
"abcd\t\n" +
"efg\t\n" +
"werop\t\n";
compiler.compile("create table test(a string, b
int, d binary)", null
);
compiler.compile("create table test(a string, b
date)"
);
configureLoaderDefaults(textLoader);
playText(textLoader, csv, 1024,
expected,
"{\"columnCount\":
3,\"columns\":[{\"index\":0,\"name\":\"a\",\"type\":\"STRING\"},{\"index\":1,\"name\":\"b\",\"type\":\"INT\"},{\"index\":2,\"name\":\"d\",\"type\":\"BINARY
\"}],\"timestampIndex\":-1}",
"{\"columnCount\":
2,\"columns\":[{\"index\":0,\"name\":\"a\",\"type\":\"STRING\"},{\"index\":1,\"name\":\"b\",\"type\":\"DATE
\"}],\"timestampIndex\":-1}",
3,
3);
});
}
@Test
public void testWriteToExistingCannotConvertTimestamp() throws Exception {
assertNoLeak(textLoader -> {
...
...
@@ -2077,7 +2054,7 @@ public class TextLoaderTest extends AbstractCairoTest {
"efg\t\n" +
"werop\t\n";
compiler.compile("create table test(a string, b timestamp)"
, null
);
compiler.compile("create table test(a string, b timestamp)");
configureLoaderDefaults(textLoader);
playText(textLoader, csv, 1024,
expected,
...
...
@@ -2103,7 +2080,7 @@ public class TextLoaderTest extends AbstractCairoTest {
"CMP2,2,4770,2.85092033445835,2015-02-08T19:15:09.000Z,2015-02-08 19:15:09,02/08/2015,253,TRUE,33766814\n" +
"CMP1,5,4938,4.42754498450086,2015-02-09T19:15:09.000Z,2015-02-09 19:15:09,02/09/2015,7817,FALSE,61983099\n";
compiler.compile("create table test(a int, b int)"
, null
);
compiler.compile("create table test(a int, b int)");
configureLoaderDefaults(textLoader);
try {
playText0(textLoader, csv, 1024, ENTITY_MANIPULATOR);
...
...
@@ -2114,6 +2091,28 @@ public class TextLoaderTest extends AbstractCairoTest {
});
}
@Test
public void testWriteToTableWithBlob() throws Exception {
assertNoLeak(textLoader -> {
String csv = "abcd,10\n" +
"efg,45\n" +
"werop,90\n";
String expected = "a\tb\td\n" +
"abcd\t10\t\n" +
"efg\t45\t\n" +
"werop\t90\t\n";
compiler.compile("create table test(a string, b int, d binary)");
configureLoaderDefaults(textLoader);
playText(textLoader, csv, 1024,
expected,
"{\"columnCount\":3,\"columns\":[{\"index\":0,\"name\":\"a\",\"type\":\"STRING\"},{\"index\":1,\"name\":\"b\",\"type\":\"INT\"},{\"index\":2,\"name\":\"d\",\"type\":\"BINARY\"}],\"timestampIndex\":-1}",
3,
3);
});
}
@Test
public void testWriteToExistingTableTooManyColumns() throws Exception {
assertNoLeak(textLoader -> {
...
...
@@ -2194,8 +2193,8 @@ public class TextLoaderTest extends AbstractCairoTest {
private void assertTable(String expected) throws IOException, SqlException {
try (
RecordCursorFactory factory = compiler.compile("test"
, null
);
RecordCursor cursor = factory.getCursor(
null
)
RecordCursorFactory factory = compiler.compile("test");
RecordCursor cursor = factory.getCursor()
) {
sink.clear();
printer.print(cursor, factory.getMetadata(), true);
...
...
core/src/test/java/com/questdb/griffin/AbstractGriffinTest.java
浏览文件 @
9dc2f3da
...
...
@@ -87,7 +87,7 @@ public class AbstractGriffinTest extends AbstractCairoTest {
@BeforeClass
public
static
void
setUp2
()
{
engine
=
new
Engine
(
configuration
);
compiler
=
new
SqlCompiler
(
engine
,
configuration
);
compiler
=
new
SqlCompiler
(
engine
);
sqlExecutionContext
=
new
TestExecutionContext
(
compiler
.
getCodeGenerator
());
}
...
...
core/src/test/java/com/questdb/griffin/AlterTableAddColumnTest.java
浏览文件 @
9dc2f3da
...
...
@@ -5,7 +5,7 @@
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-201
8
Appsicle
* Copyright (C) 2014-201
9
Appsicle
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
...
...
@@ -152,7 +152,7 @@ public class AlterTableAddColumnTest extends AbstractGriffinTest {
};
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
Assert
.
assertNull
(
compiler
.
compile
(
"alter table x add column meh symbol cache"
,
bindVariableService
));
try
(
TableReader
reader
=
engine
.
getReader
(
"x"
,
TableUtils
.
ANY_TABLE_VERSION
))
{
...
...
core/src/test/java/com/questdb/griffin/ExpressionParserTest.java
浏览文件 @
9dc2f3da
...
...
@@ -5,7 +5,7 @@
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-201
8
Appsicle
* Copyright (C) 2014-201
9
Appsicle
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
...
...
@@ -31,7 +31,7 @@ import org.junit.Assert;
import
org.junit.Test
;
public
class
ExpressionParserTest
extends
AbstractCairoTest
{
private
final
static
SqlCompiler
compiler
=
new
SqlCompiler
(
new
Engine
(
configuration
)
,
configuration
);
private
final
static
SqlCompiler
compiler
=
new
SqlCompiler
(
new
Engine
(
configuration
));
private
final
static
RpnBuilder
rpnBuilder
=
new
RpnBuilder
();
@Test
...
...
core/src/test/java/com/questdb/griffin/SqlCodeGeneratorTest.java
浏览文件 @
9dc2f3da
...
...
@@ -5,7 +5,7 @@
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-201
8
Appsicle
* Copyright (C) 2014-201
9
Appsicle
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
...
...
@@ -69,7 +69,7 @@ public class SqlCodeGeneratorTest extends AbstractGriffinTest {
try
(
Engine
engine
=
new
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
)
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
)
)
{
compiler
.
compile
(
"create table y as (x), cast(col as symbol cache)"
,
bindVariableService
);
...
...
@@ -1119,7 +1119,7 @@ public class SqlCodeGeneratorTest extends AbstractGriffinTest {
};
try
(
Engine
engine
=
new
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
))
{
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
try
{
compiler
.
compile
((
"create table x as "
+
"("
+
...
...
core/src/test/java/com/questdb/griffin/SqlCompilerTest.java
浏览文件 @
9dc2f3da
...
...
@@ -5,7 +5,7 @@
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-201
8
Appsicle
* Copyright (C) 2014-201
9
Appsicle
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
...
...
@@ -50,7 +50,7 @@ import java.util.concurrent.atomic.AtomicInteger;
public
class
SqlCompilerTest
extends
AbstractCairoTest
{
private
final
static
Engine
engine
=
new
Engine
(
configuration
);
private
final
static
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
);
private
final
static
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
);
private
final
static
BindVariableService
bindVariableService
=
new
BindVariableService
();
private
final
static
Path
path
=
new
Path
();
...
...
@@ -118,7 +118,7 @@ public class SqlCompilerTest extends AbstractCairoTest {
};
CairoEngine
engine
=
new
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
);
try
{
compiler
.
compile
(
"create table x (a int)"
,
bindVariableService
);
...
...
@@ -1831,7 +1831,10 @@ public class SqlCompilerTest extends AbstractCairoTest {
}
};
try
(
Engine
engine
=
new
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
))
{
try
(
Engine
engine
=
new
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
)
)
{
try
{
compiler
.
compile
(
sql
,
bindVariableService
);
Assert
.
fail
();
...
...
@@ -1888,7 +1891,7 @@ public class SqlCompilerTest extends AbstractCairoTest {
}
};
try
(
Engine
engine
=
new
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
))
{
try
(
Engine
engine
=
new
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
try
{
compiler
.
compile
(
sql
,
bindVariableService
);
Assert
.
fail
();
...
...
@@ -2238,18 +2241,19 @@ public class SqlCompilerTest extends AbstractCairoTest {
};
TestUtils
.
assertMemoryLeak
(()
->
{
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
))
{
try
{
compiler
.
compile
(
"create table x as (select to_int(x) c, abs(rnd_int() % 650) a from long_sequence(5000000))"
,
bindVariableService
);
Assert
.
fail
();
}
catch
(
SqlException
e
)
{
TestUtils
.
assertContains
(
e
.
getMessage
(),
"Could not create table. See log for details"
);
}
Assert
.
assertEquals
(
0
,
engine
.
getBusyReaderCount
());
Assert
.
assertEquals
(
0
,
engine
.
getBusyWriterCount
());
try
(
Engine
engine
=
new
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
)
)
{
try
{
compiler
.
compile
(
"create table x as (select to_int(x) c, abs(rnd_int() % 650) a from long_sequence(5000000))"
,
bindVariableService
);
Assert
.
fail
();
}
catch
(
SqlException
e
)
{
TestUtils
.
assertContains
(
e
.
getMessage
(),
"Could not create table. See log for details"
);
}
Assert
.
assertEquals
(
0
,
engine
.
getBusyReaderCount
());
Assert
.
assertEquals
(
0
,
engine
.
getBusyWriterCount
());
}
});
}
...
...
@@ -2260,7 +2264,7 @@ public class SqlCompilerTest extends AbstractCairoTest {
try
(
TableWriter
writer
=
engine
.
getWriter
(
"доходы"
))
{
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
TableWriter
.
Row
row
=
writer
.
newRow
(
0
);
TableWriter
.
Row
row
=
writer
.
newRow
();
row
.
putInt
(
0
,
i
);
row
.
append
();
}
...
...
@@ -2935,7 +2939,7 @@ public class SqlCompilerTest extends AbstractCairoTest {
return
super
.
getReader
(
tableName
,
version
);
}
})
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
compiler
.
compile
(
"create table x (a INT, b INT)"
,
bindVariableService
);
compiler
.
compile
(
"create table y as (select rnd_int() int1, rnd_int() int2 from long_sequence(10))"
,
bindVariableService
);
...
...
@@ -3016,58 +3020,59 @@ public class SqlCompilerTest extends AbstractCairoTest {
@Test
public
void
testRaceToCreateEmptyTable
()
throws
InterruptedException
{
SqlCompiler
compiler2
=
new
SqlCompiler
(
engine
,
configuration
);
AtomicInteger
index
=
new
AtomicInteger
();
AtomicInteger
success
=
new
AtomicInteger
();
try
(
SqlCompiler
compiler2
=
new
SqlCompiler
(
engine
))
{
AtomicInteger
index
=
new
AtomicInteger
();
AtomicInteger
success
=
new
AtomicInteger
();
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
CyclicBarrier
barrier
=
new
CyclicBarrier
(
2
);
CountDownLatch
haltLatch
=
new
CountDownLatch
(
2
);
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
CyclicBarrier
barrier
=
new
CyclicBarrier
(
2
);
CountDownLatch
haltLatch
=
new
CountDownLatch
(
2
);
index
.
set
(-
1
);
success
.
set
(
0
);
index
.
set
(-
1
);
success
.
set
(
0
);
new
Thread
(()
->
{
try
{
barrier
.
await
();
compiler
.
compile
(
"create table x (a INT, b FLOAT)"
,
bindVariableService
);
index
.
set
(
0
);
success
.
incrementAndGet
();
}
catch
(
Exception
ignore
)
{
new
Thread
(()
->
{
try
{
barrier
.
await
();
compiler
.
compile
(
"create table x (a INT, b FLOAT)"
,
bindVariableService
);
index
.
set
(
0
);
success
.
incrementAndGet
();
}
catch
(
Exception
ignore
)
{
// e.printStackTrace();
}
finally
{
haltLatch
.
countDown
();
}
}).
start
();
}
finally
{
haltLatch
.
countDown
();
}
}).
start
();
new
Thread
(()
->
{
try
{
barrier
.
await
();
compiler2
.
compile
(
"create table x (a STRING, b DOUBLE)"
,
bindVariableService
);
index
.
set
(
1
);
success
.
incrementAndGet
();
}
catch
(
Exception
ignore
)
{
new
Thread
(()
->
{
try
{
barrier
.
await
();
compiler2
.
compile
(
"create table x (a STRING, b DOUBLE)"
,
bindVariableService
);
index
.
set
(
1
);
success
.
incrementAndGet
();
}
catch
(
Exception
ignore
)
{
// e.printStackTrace();
}
finally
{
haltLatch
.
countDown
();
}
}).
start
();
}
finally
{
haltLatch
.
countDown
();
}
}).
start
();
Assert
.
assertTrue
(
haltLatch
.
await
(
5
,
TimeUnit
.
SECONDS
));
Assert
.
assertTrue
(
haltLatch
.
await
(
5
,
TimeUnit
.
SECONDS
));
Assert
.
assertEquals
(
1
,
success
.
get
());
Assert
.
assertNotEquals
(-
1
,
index
.
get
());
Assert
.
assertEquals
(
1
,
success
.
get
());
Assert
.
assertNotEquals
(-
1
,
index
.
get
());
try
(
TableReader
reader
=
engine
.
getReader
(
"x"
,
TableUtils
.
ANY_TABLE_VERSION
))
{
sink
.
clear
();
reader
.
getMetadata
().
toJson
(
sink
);
if
(
index
.
get
()
==
0
)
{
TestUtils
.
assertEquals
(
"{\"columnCount\":2,\"columns\":[{\"index\":0,\"name\":\"a\",\"type\":\"INT\"},{\"index\":1,\"name\":\"b\",\"type\":\"FLOAT\"}],\"timestampIndex\":-1}"
,
sink
);
}
else
{
TestUtils
.
assertEquals
(
"{\"columnCount\":2,\"columns\":[{\"index\":0,\"name\":\"a\",\"type\":\"STRING\"},{\"index\":1,\"name\":\"b\",\"type\":\"DOUBLE\"}],\"timestampIndex\":-1}"
,
sink
);
try
(
TableReader
reader
=
engine
.
getReader
(
"x"
,
TableUtils
.
ANY_TABLE_VERSION
))
{
sink
.
clear
();
reader
.
getMetadata
().
toJson
(
sink
);
if
(
index
.
get
()
==
0
)
{
TestUtils
.
assertEquals
(
"{\"columnCount\":2,\"columns\":[{\"index\":0,\"name\":\"a\",\"type\":\"INT\"},{\"index\":1,\"name\":\"b\",\"type\":\"FLOAT\"}],\"timestampIndex\":-1}"
,
sink
);
}
else
{
TestUtils
.
assertEquals
(
"{\"columnCount\":2,\"columns\":[{\"index\":0,\"name\":\"a\",\"type\":\"STRING\"},{\"index\":1,\"name\":\"b\",\"type\":\"DOUBLE\"}],\"timestampIndex\":-1}"
,
sink
);
}
}
engine
.
remove
(
path
,
"x"
);
}
engine
.
remove
(
path
,
"x"
);
}
}
...
...
@@ -3385,18 +3390,19 @@ public class SqlCompilerTest extends AbstractCairoTest {
}
})
{
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
);
compiler
.
compile
(
sql
,
bindVariableService
);
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
compiler
.
compile
(
sql
,
bindVariableService
);
Assert
.
assertTrue
(
fiddler
.
isHappy
());
Assert
.
assertTrue
(
fiddler
.
isHappy
());
try
(
TableReader
reader
=
engine
.
getReader
(
"Y"
,
TableUtils
.
ANY_TABLE_VERSION
))
{
sink
.
clear
();
reader
.
getMetadata
().
toJson
(
sink
);
TestUtils
.
assertEquals
(
expectedMetadata
,
sink
);
}
try
(
TableReader
reader
=
engine
.
getReader
(
"Y"
,
TableUtils
.
ANY_TABLE_VERSION
))
{
sink
.
clear
();
reader
.
getMetadata
().
toJson
(
sink
);
TestUtils
.
assertEquals
(
expectedMetadata
,
sink
);
}
Assert
.
assertEquals
(
0
,
engine
.
getBusyReaderCount
());
Assert
.
assertEquals
(
0
,
engine
.
getBusyReaderCount
());
}
}
}
...
...
@@ -3423,7 +3429,7 @@ public class SqlCompilerTest extends AbstractCairoTest {
};
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
compiler
.
compile
(
"create table x (a INT, b INT)"
,
bindVariableService
);
try
{
...
...
core/src/test/java/com/questdb/griffin/SqlParserTest.java
浏览文件 @
9dc2f3da
...
...
@@ -95,21 +95,6 @@ public class SqlParserTest extends AbstractGriffinTest {
);
}
@Test
public
void
testSpliceJoin
()
throws
SqlException
{
assertQuery
(
"select-choose"
+
" t.timestamp timestamp,"
+
" t.tag tag,"
+
" q.timestamp timestamp1"
+
" from ("
+
"trades t timestamp (timestamp) splice join quotes q timestamp (timestamp) post-join-where tag = null)"
,
"trades t splice join quotes q where tag = null"
,
modelOf
(
"trades"
).
timestamp
().
col
(
"tag"
,
ColumnType
.
SYMBOL
),
modelOf
(
"quotes"
).
timestamp
()
);
}
@Test
public
void
testAsOfJoinColumnAliasNull
()
throws
SqlException
{
assertQuery
(
...
...
@@ -138,34 +123,6 @@ public class SqlParserTest extends AbstractGriffinTest {
);
}
@Test
public
void
testSpliceJoinColumnAliasNull
()
throws
SqlException
{
assertQuery
(
"select-choose customerId, kk, count"
+
" from "
+
"("
+
"("
+
"select-group-by customerId, kk, count() count"
+
" from "
+
"("
+
"select-choose c.customerId customerId, o.customerId kk"
+
" from "
+
"(customers c"
+
" splice join orders o"
+
" on o.customerId = c.customerId"
+
" post-join-where o.customerId = null"
+
")"
+
")"
+
") _xQdbA1 limit 10"
+
")"
,
"(select c.customerId, o.customerId kk, count() from customers c"
+
" splice join orders o on c.customerId = o.customerId) "
+
" where kk = null limit 10"
,
modelOf
(
"customers"
).
col
(
"customerId"
,
ColumnType
.
INT
),
modelOf
(
"orders"
).
col
(
"customerId"
,
ColumnType
.
INT
)
);
}
@Test
public
void
testAsOfJoinOrder
()
throws
Exception
{
assertQuery
(
...
...
@@ -186,26 +143,6 @@ public class SqlParserTest extends AbstractGriffinTest {
modelOf
(
"orders"
).
col
(
"customerId"
,
ColumnType
.
SYMBOL
));
}
@Test
public
void
testSpliceJoinOrder
()
throws
Exception
{
assertQuery
(
"select-choose"
+
" c.customerId customerId,"
+
" e.employeeId employeeId,"
+
" o.customerId customerId1"
+
" from ("
+
"customers c"
+
" splice join employees e on e.employeeId = c.customerId"
+
" join orders o on o.customerId = c.customerId"
+
")"
,
"customers c"
+
" splice join employees e on c.customerId = e.employeeId"
+
" join orders o on c.customerId = o.customerId"
,
modelOf
(
"customers"
).
col
(
"customerId"
,
ColumnType
.
SYMBOL
),
modelOf
(
"employees"
).
col
(
"employeeId"
,
ColumnType
.
STRING
),
modelOf
(
"orders"
).
col
(
"customerId"
,
ColumnType
.
SYMBOL
));
}
@Test
public
void
testAsOfJoinSubQuery
()
throws
Exception
{
// execution order must be (src: SQL Server)
...
...
@@ -256,56 +193,6 @@ public class SqlParserTest extends AbstractGriffinTest {
);
}
@Test
public
void
testSpliceJoinSubQuery
()
throws
Exception
{
// execution order must be (src: SQL Server)
// 1. FROM
// 2. ON
// 3. JOIN
// 4. WHERE
// 5. GROUP BY
// 6. WITH CUBE or WITH ROLLUP
// 7. HAVING
// 8. SELECT
// 9. DISTINCT
// 10. ORDER BY
// 11. TOP
//
// which means "where" clause for "e" table has to be explicitly as post-join-where
assertQuery
(
"select-choose"
+
" c.customerId customerId,"
+
" e.blah blah,"
+
" e.lastName lastName,"
+
" e.employeeId employeeId,"
+
" e.timestamp timestamp,"
+
" o.customerId customerId1"
+
" from ("
+
"customers c"
+
" splice join"
+
" (select-virtual"
+
" '1' blah,"
+
" lastName,"
+
" employeeId,"
+
" timestamp"
+
" from (employees)"
+
" order by lastName) e on e.employeeId = c.customerId post-join-where e.lastName = 'x' and e.blah = 'y'"
+
" join orders o on o.customerId = c.customerId"
+
")"
,
"customers c"
+
" splice join (select '1' blah, lastName, employeeId, timestamp from employees order by lastName) e on c.customerId = e.employeeId"
+
" join orders o on c.customerId = o.customerId where e.lastName = 'x' and e.blah = 'y'"
,
modelOf
(
"customers"
)
.
col
(
"customerId"
,
ColumnType
.
SYMBOL
),
modelOf
(
"employees"
)
.
col
(
"employeeId"
,
ColumnType
.
STRING
)
.
col
(
"lastName"
,
ColumnType
.
STRING
)
.
col
(
"timestamp"
,
ColumnType
.
TIMESTAMP
),
modelOf
(
"orders"
)
.
col
(
"customerId"
,
ColumnType
.
SYMBOL
)
);
}
@Test
public
void
testAsOfJoinSubQuerySimpleAlias
()
throws
Exception
{
assertQuery
(
...
...
@@ -340,40 +227,6 @@ public class SqlParserTest extends AbstractGriffinTest {
);
}
@Test
public
void
testSpliceJoinSubQuerySimpleAlias
()
throws
Exception
{
assertQuery
(
"select-choose"
+
" c.customerId customerId,"
+
" a.blah blah,"
+
" a.lastName lastName,"
+
" a.customerId customerId1,"
+
" a.timestamp timestamp"
+
" from "
+
"("
+
"customers c"
+
" splice join ("
+
"select-virtual"
+
" '1' blah,"
+
" lastName,"
+
" customerId,"
+
" timestamp"
+
" from ("
+
"select-choose"
+
" lastName,"
+
" employeeId customerId,"
+
" timestamp from (employees)) order by lastName) a on a.customerId = c.customerId)"
,
"customers c"
+
" splice join (select '1' blah, lastName, employeeId customerId, timestamp from employees order by lastName) a on (customerId)"
,
modelOf
(
"customers"
)
.
col
(
"customerId"
,
ColumnType
.
SYMBOL
),
modelOf
(
"employees"
)
.
col
(
"employeeId"
,
ColumnType
.
STRING
)
.
col
(
"lastName"
,
ColumnType
.
STRING
)
.
col
(
"timestamp"
,
ColumnType
.
TIMESTAMP
)
);
}
@Test
public
void
testAsOfJoinSubQuerySimpleNoAlias
()
throws
Exception
{
assertQuery
(
...
...
@@ -398,30 +251,6 @@ public class SqlParserTest extends AbstractGriffinTest {
);
}
@Test
public
void
testSpliceJoinSubQuerySimpleNoAlias
()
throws
Exception
{
assertQuery
(
"select-choose"
+
" c.customerId customerId,"
+
" _xQdbA1.blah blah,"
+
" _xQdbA1.lastName lastName,"
+
" _xQdbA1.customerId customerId1,"
+
" _xQdbA1.timestamp timestamp"
+
" from ("
+
"customers c"
+
" splice join (select-virtual '1' blah, lastName, customerId, timestamp"
+
" from (select-choose lastName, employeeId customerId, timestamp"
+
" from (employees)) order by lastName) _xQdbA1 on _xQdbA1.customerId = c.customerId)"
,
"customers c"
+
" splice join (select '1' blah, lastName, employeeId customerId, timestamp from employees order by lastName) on (customerId)"
,
modelOf
(
"customers"
).
col
(
"customerId"
,
ColumnType
.
SYMBOL
),
modelOf
(
"employees"
)
.
col
(
"employeeId"
,
ColumnType
.
STRING
)
.
col
(
"lastName"
,
ColumnType
.
STRING
)
.
col
(
"timestamp"
,
ColumnType
.
TIMESTAMP
)
);
}
@Test
public
void
testBlockCommentAtMiddle
()
throws
Exception
{
assertQuery
(
...
...
@@ -4182,6 +4011,177 @@ public class SqlParserTest extends AbstractGriffinTest {
modelOf
(
"tab"
).
col
(
"x"
,
ColumnType
.
INT
).
col
(
"y"
,
ColumnType
.
INT
));
}
@Test
public
void
testSpliceJoin
()
throws
SqlException
{
assertQuery
(
"select-choose"
+
" t.timestamp timestamp,"
+
" t.tag tag,"
+
" q.timestamp timestamp1"
+
" from ("
+
"trades t timestamp (timestamp) splice join quotes q timestamp (timestamp) post-join-where tag = null)"
,
"trades t splice join quotes q where tag = null"
,
modelOf
(
"trades"
).
timestamp
().
col
(
"tag"
,
ColumnType
.
SYMBOL
),
modelOf
(
"quotes"
).
timestamp
()
);
}
@Test
public
void
testSpliceJoinColumnAliasNull
()
throws
SqlException
{
assertQuery
(
"select-choose customerId, kk, count"
+
" from "
+
"("
+
"("
+
"select-group-by customerId, kk, count() count"
+
" from "
+
"("
+
"select-choose c.customerId customerId, o.customerId kk"
+
" from "
+
"(customers c"
+
" splice join orders o"
+
" on o.customerId = c.customerId"
+
" post-join-where o.customerId = null"
+
")"
+
")"
+
") _xQdbA1 limit 10"
+
")"
,
"(select c.customerId, o.customerId kk, count() from customers c"
+
" splice join orders o on c.customerId = o.customerId) "
+
" where kk = null limit 10"
,
modelOf
(
"customers"
).
col
(
"customerId"
,
ColumnType
.
INT
),
modelOf
(
"orders"
).
col
(
"customerId"
,
ColumnType
.
INT
)
);
}
@Test
public
void
testSpliceJoinOrder
()
throws
Exception
{
assertQuery
(
"select-choose"
+
" c.customerId customerId,"
+
" e.employeeId employeeId,"
+
" o.customerId customerId1"
+
" from ("
+
"customers c"
+
" splice join employees e on e.employeeId = c.customerId"
+
" join orders o on o.customerId = c.customerId"
+
")"
,
"customers c"
+
" splice join employees e on c.customerId = e.employeeId"
+
" join orders o on c.customerId = o.customerId"
,
modelOf
(
"customers"
).
col
(
"customerId"
,
ColumnType
.
SYMBOL
),
modelOf
(
"employees"
).
col
(
"employeeId"
,
ColumnType
.
STRING
),
modelOf
(
"orders"
).
col
(
"customerId"
,
ColumnType
.
SYMBOL
));
}
@Test
public
void
testSpliceJoinSubQuery
()
throws
Exception
{
// execution order must be (src: SQL Server)
// 1. FROM
// 2. ON
// 3. JOIN
// 4. WHERE
// 5. GROUP BY
// 6. WITH CUBE or WITH ROLLUP
// 7. HAVING
// 8. SELECT
// 9. DISTINCT
// 10. ORDER BY
// 11. TOP
//
// which means "where" clause for "e" table has to be explicitly as post-join-where
assertQuery
(
"select-choose"
+
" c.customerId customerId,"
+
" e.blah blah,"
+
" e.lastName lastName,"
+
" e.employeeId employeeId,"
+
" e.timestamp timestamp,"
+
" o.customerId customerId1"
+
" from ("
+
"customers c"
+
" splice join"
+
" (select-virtual"
+
" '1' blah,"
+
" lastName,"
+
" employeeId,"
+
" timestamp"
+
" from (employees)"
+
" order by lastName) e on e.employeeId = c.customerId post-join-where e.lastName = 'x' and e.blah = 'y'"
+
" join orders o on o.customerId = c.customerId"
+
")"
,
"customers c"
+
" splice join (select '1' blah, lastName, employeeId, timestamp from employees order by lastName) e on c.customerId = e.employeeId"
+
" join orders o on c.customerId = o.customerId where e.lastName = 'x' and e.blah = 'y'"
,
modelOf
(
"customers"
)
.
col
(
"customerId"
,
ColumnType
.
SYMBOL
),
modelOf
(
"employees"
)
.
col
(
"employeeId"
,
ColumnType
.
STRING
)
.
col
(
"lastName"
,
ColumnType
.
STRING
)
.
col
(
"timestamp"
,
ColumnType
.
TIMESTAMP
),
modelOf
(
"orders"
)
.
col
(
"customerId"
,
ColumnType
.
SYMBOL
)
);
}
@Test
public
void
testSpliceJoinSubQuerySimpleAlias
()
throws
Exception
{
assertQuery
(
"select-choose"
+
" c.customerId customerId,"
+
" a.blah blah,"
+
" a.lastName lastName,"
+
" a.customerId customerId1,"
+
" a.timestamp timestamp"
+
" from "
+
"("
+
"customers c"
+
" splice join ("
+
"select-virtual"
+
" '1' blah,"
+
" lastName,"
+
" customerId,"
+
" timestamp"
+
" from ("
+
"select-choose"
+
" lastName,"
+
" employeeId customerId,"
+
" timestamp from (employees)) order by lastName) a on a.customerId = c.customerId)"
,
"customers c"
+
" splice join (select '1' blah, lastName, employeeId customerId, timestamp from employees order by lastName) a on (customerId)"
,
modelOf
(
"customers"
)
.
col
(
"customerId"
,
ColumnType
.
SYMBOL
),
modelOf
(
"employees"
)
.
col
(
"employeeId"
,
ColumnType
.
STRING
)
.
col
(
"lastName"
,
ColumnType
.
STRING
)
.
col
(
"timestamp"
,
ColumnType
.
TIMESTAMP
)
);
}
@Test
public
void
testSpliceJoinSubQuerySimpleNoAlias
()
throws
Exception
{
assertQuery
(
"select-choose"
+
" c.customerId customerId,"
+
" _xQdbA1.blah blah,"
+
" _xQdbA1.lastName lastName,"
+
" _xQdbA1.customerId customerId1,"
+
" _xQdbA1.timestamp timestamp"
+
" from ("
+
"customers c"
+
" splice join (select-virtual '1' blah, lastName, customerId, timestamp"
+
" from (select-choose lastName, employeeId customerId, timestamp"
+
" from (employees)) order by lastName) _xQdbA1 on _xQdbA1.customerId = c.customerId)"
,
"customers c"
+
" splice join (select '1' blah, lastName, employeeId customerId, timestamp from employees order by lastName) on (customerId)"
,
modelOf
(
"customers"
).
col
(
"customerId"
,
ColumnType
.
SYMBOL
),
modelOf
(
"employees"
)
.
col
(
"employeeId"
,
ColumnType
.
STRING
)
.
col
(
"lastName"
,
ColumnType
.
STRING
)
.
col
(
"timestamp"
,
ColumnType
.
TIMESTAMP
)
);
}
@Test
public
void
testStackOverflow
()
{
assertSyntaxError
(
...
...
@@ -4280,17 +4280,19 @@ public class SqlParserTest extends AbstractGriffinTest {
}
};
CairoEngine
engine
=
new
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
);
assertSyntaxError
(
compiler
,
engine
,
"select * from tab"
,
14
,
"Cannot open file"
,
modelOf
(
"tab"
).
col
(
"x"
,
ColumnType
.
INT
)
);
try
(
CairoEngine
engine
=
new
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
)
)
{
assertSyntaxError
(
compiler
,
engine
,
"select * from tab"
,
14
,
"Cannot open file"
,
modelOf
(
"tab"
).
col
(
"x"
,
ColumnType
.
INT
)
);
}
}
@Test
...
...
core/src/test/java/com/questdb/griffin/WhereClauseParserTest.java
浏览文件 @
9dc2f3da
...
...
@@ -5,7 +5,7 @@
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-201
8
Appsicle
* Copyright (C) 2014-201
9
Appsicle
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
...
...
@@ -38,7 +38,7 @@ import static com.questdb.griffin.GriffinParserTestUtils.intervalToString;
public
class
WhereClauseParserTest
extends
AbstractCairoTest
{
private
final
static
SqlCompiler
compiler
=
new
SqlCompiler
(
new
Engine
(
configuration
)
,
configuration
);
private
final
static
SqlCompiler
compiler
=
new
SqlCompiler
(
new
Engine
(
configuration
));
private
static
TableReader
reader
;
private
static
TableReader
noTimestampReader
;
private
static
TableReader
unindexedReader
;
...
...
core/src/test/java/com/questdb/griffin/engine/functions/eq/EqStrFunctionFactoryTest.java
浏览文件 @
9dc2f3da
...
...
@@ -5,7 +5,7 @@
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-201
8
Appsicle
* Copyright (C) 2014-201
9
Appsicle
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
...
...
@@ -39,7 +39,7 @@ public class EqStrFunctionFactoryTest extends AbstractCairoTest {
private
static
final
BindVariableService
bindVariableService
=
new
BindVariableService
();
private
static
final
Engine
engine
=
new
Engine
(
configuration
);
private
static
final
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
);
private
static
final
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
);
@Before
public
void
setUp2
()
{
...
...
core/src/test/java/com/questdb/griffin/engine/functions/rnd/RndBinFunctionFactoryTest.java
浏览文件 @
9dc2f3da
...
...
@@ -5,7 +5,7 @@
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-201
8
Appsicle
* Copyright (C) 2014-201
9
Appsicle
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
...
...
@@ -40,7 +40,7 @@ import java.io.IOException;
public
class
RndBinFunctionFactoryTest
extends
AbstractFunctionFactoryTest
{
private
static
final
CairoEngine
engine
=
new
Engine
(
configuration
);
private
static
final
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
);
private
static
final
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
);
private
static
final
BindVariableService
bindVariableService
=
new
BindVariableService
();
@Before
...
...
core/src/test/java/com/questdb/griffin/engine/groupby/SampleByTest.java
浏览文件 @
9dc2f3da
...
...
@@ -247,7 +247,7 @@ public class SampleByTest extends AbstractGriffinTest {
};
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
try
{
try
(
RecordCursorFactory
factory
=
compiler
.
compile
(
"select c, sum_t(d) from x"
,
bindVariableService
))
{
factory
.
getCursor
(
bindVariableService
);
...
...
@@ -1136,7 +1136,7 @@ public class SampleByTest extends AbstractGriffinTest {
};
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
try
{
compiler
.
compile
(
"select b, sum(a), k from x sample by 3h fill(linear)"
,
bindVariableService
);
Assert
.
fail
();
...
...
@@ -1190,7 +1190,7 @@ public class SampleByTest extends AbstractGriffinTest {
};
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
,
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
try
{
try
(
RecordCursorFactory
factory
=
compiler
.
compile
(
"select b, sum(a), k from x sample by 3h fill(linear)"
,
bindVariableService
))
{
// with mmap count = 5 we should get failure in cursor
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录