Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
d6dce89e
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,发现更多精彩内容 >>
提交
d6dce89e
编写于
6月 13, 2019
作者:
V
Vlad Ilyushchenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
misc: refactored Engine to reduce confusion with names. work in progress on new main method!
上级
92536794
变更
53
展开全部
隐藏空白更改
内联
并排
Showing
53 changed file
with
1968 addition
and
313 deletion
+1968
-313
core/src/main/c/share/files.c
core/src/main/c/share/files.c
+0
-5
core/src/main/c/share/files.h
core/src/main/c/share/files.h
+0
-8
core/src/main/c/windows/files.c
core/src/main/c/windows/files.c
+0
-11
core/src/main/java/com/questdb/PropServerConfiguration.java
core/src/main/java/com/questdb/PropServerConfiguration.java
+24
-10
core/src/main/java/com/questdb/ServerMain.java
core/src/main/java/com/questdb/ServerMain.java
+211
-0
core/src/main/java/com/questdb/cairo/AbstractDataFrameCursorFactory.java
...ava/com/questdb/cairo/AbstractDataFrameCursorFactory.java
+0
-1
core/src/main/java/com/questdb/cairo/CairoEngine.java
core/src/main/java/com/questdb/cairo/CairoEngine.java
+8
-15
core/src/main/java/com/questdb/cairo/FullBwdDataFrameCursorFactory.java
...java/com/questdb/cairo/FullBwdDataFrameCursorFactory.java
+0
-1
core/src/main/java/com/questdb/cairo/FullFwdDataFrameCursorFactory.java
...java/com/questdb/cairo/FullFwdDataFrameCursorFactory.java
+0
-1
core/src/main/java/com/questdb/cairo/IntervalBwdDataFrameCursorFactory.java
.../com/questdb/cairo/IntervalBwdDataFrameCursorFactory.java
+0
-1
core/src/main/java/com/questdb/cairo/IntervalFwdDataFrameCursorFactory.java
.../com/questdb/cairo/IntervalFwdDataFrameCursorFactory.java
+0
-1
core/src/main/java/com/questdb/cairo/TableReaderRecordCursorFactory.java
...ava/com/questdb/cairo/TableReaderRecordCursorFactory.java
+0
-1
core/src/main/java/com/questdb/cairo/sql/CairoEngine.java
core/src/main/java/com/questdb/cairo/sql/CairoEngine.java
+0
-61
core/src/main/java/com/questdb/cutlass/http/processors/JsonQueryProcessor.java
...m/questdb/cutlass/http/processors/JsonQueryProcessor.java
+1
-1
core/src/main/java/com/questdb/cutlass/http/processors/TextImportProcessor.java
.../questdb/cutlass/http/processors/TextImportProcessor.java
+1
-1
core/src/main/java/com/questdb/cutlass/http/processors/TextImportProcessorState.java
...tdb/cutlass/http/processors/TextImportProcessorState.java
+1
-1
core/src/main/java/com/questdb/cutlass/line/CairoLineProtoParser.java
...n/java/com/questdb/cutlass/line/CairoLineProtoParser.java
+0
-1
core/src/main/java/com/questdb/cutlass/line/udp/GenericLineProtoReceiver.java
...om/questdb/cutlass/line/udp/GenericLineProtoReceiver.java
+1
-1
core/src/main/java/com/questdb/cutlass/line/udp/LinuxLineProtoReceiver.java
.../com/questdb/cutlass/line/udp/LinuxLineProtoReceiver.java
+1
-1
core/src/main/java/com/questdb/cutlass/line/udp/ReceiverFactory.java
...in/java/com/questdb/cutlass/line/udp/ReceiverFactory.java
+1
-1
core/src/main/java/com/questdb/cutlass/text/CairoTextWriter.java
...c/main/java/com/questdb/cutlass/text/CairoTextWriter.java
+0
-1
core/src/main/java/com/questdb/cutlass/text/TextLoader.java
core/src/main/java/com/questdb/cutlass/text/TextLoader.java
+1
-1
core/src/main/java/com/questdb/griffin/SqlOptimiser.java
core/src/main/java/com/questdb/griffin/SqlOptimiser.java
+0
-1
core/src/main/java/com/questdb/std/Files.java
core/src/main/java/com/questdb/std/Files.java
+0
-10
core/src/main/resources/binaries/windows/libquestdb.dll
core/src/main/resources/binaries/windows/libquestdb.dll
+0
-0
core/src/main/resources/site/conf/server.conf
core/src/main/resources/site/conf/server.conf
+0
-0
core/src/test/java/com/questdb/FilesTest.java
core/src/test/java/com/questdb/FilesTest.java
+0
-46
core/src/test/java/com/questdb/PropServerConfigurationTest.java
...rc/test/java/com/questdb/PropServerConfigurationTest.java
+54
-10
core/src/test/java/com/questdb/cairo/CairoEngineTest.java
core/src/test/java/com/questdb/cairo/CairoEngineTest.java
+18
-18
core/src/test/java/com/questdb/cairo/FullBwdDataFrameCursorTest.java
...st/java/com/questdb/cairo/FullBwdDataFrameCursorTest.java
+1
-2
core/src/test/java/com/questdb/cairo/FullFwdDataFrameCursorFactoryTest.java
.../com/questdb/cairo/FullFwdDataFrameCursorFactoryTest.java
+1
-1
core/src/test/java/com/questdb/cairo/IntervalBwdDataFrameCursorTest.java
...ava/com/questdb/cairo/IntervalBwdDataFrameCursorTest.java
+5
-2
core/src/test/java/com/questdb/cairo/IntervalFwdDataFrameCursorTest.java
...ava/com/questdb/cairo/IntervalFwdDataFrameCursorTest.java
+5
-2
core/src/test/java/com/questdb/cairo/TableReaderRecordCursorFactoryTest.java
...com/questdb/cairo/TableReaderRecordCursorFactoryTest.java
+1
-1
core/src/test/java/com/questdb/cairo/TableReaderTailRecordCursorTest.java
...va/com/questdb/cairo/TableReaderTailRecordCursorTest.java
+1
-1
core/src/test/java/com/questdb/cutlass/http/IODispatcherTest.java
.../test/java/com/questdb/cutlass/http/IODispatcherTest.java
+9
-10
core/src/test/java/com/questdb/cutlass/http/MimeTypesCacheTest.java
...est/java/com/questdb/cutlass/http/MimeTypesCacheTest.java
+3
-3
core/src/test/java/com/questdb/cutlass/line/CairoLineProtoParserTest.java
...va/com/questdb/cutlass/line/CairoLineProtoParserTest.java
+1
-2
core/src/test/java/com/questdb/cutlass/line/udp/LinuxLineProtoReceiverTest.java
.../questdb/cutlass/line/udp/LinuxLineProtoReceiverTest.java
+2
-3
core/src/test/java/com/questdb/cutlass/text/TextLoaderTest.java
...rc/test/java/com/questdb/cutlass/text/TextLoaderTest.java
+2
-2
core/src/test/java/com/questdb/griffin/AbstractGriffinTest.java
...rc/test/java/com/questdb/griffin/AbstractGriffinTest.java
+3
-3
core/src/test/java/com/questdb/griffin/AlterTableAddColumnTest.java
...est/java/com/questdb/griffin/AlterTableAddColumnTest.java
+1
-1
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
+2
-2
core/src/test/java/com/questdb/griffin/SqlCompilerTest.java
core/src/test/java/com/questdb/griffin/SqlCompilerTest.java
+8
-9
core/src/test/java/com/questdb/griffin/SqlParserTest.java
core/src/test/java/com/questdb/griffin/SqlParserTest.java
+1
-2
core/src/test/java/com/questdb/griffin/WhereClauseParserTest.java
.../test/java/com/questdb/griffin/WhereClauseParserTest.java
+1
-1
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
-3
core/src/test/java/com/questdb/griffin/engine/groupby/SampleByTest.java
...java/com/questdb/griffin/engine/groupby/SampleByTest.java
+4
-4
core/src/test/java/com/questdb/griffin/engine/table/DataFrameRecordCursorFactoryTest.java
...riffin/engine/table/DataFrameRecordCursorFactoryTest.java
+1
-1
core/src/test/java/com/questdb/net/http/MimeTypesTest.java
core/src/test/java/com/questdb/net/http/MimeTypesTest.java
+0
-44
core/src/test/resources/mime.types
core/src/test/resources/mime.types
+1588
-0
未找到文件。
core/src/main/c/share/files.c
浏览文件 @
d6dce89e
...
...
@@ -88,11 +88,6 @@ JNIEXPORT jlong JNICALL Java_com_questdb_std_Files_read
return
pread
((
int
)
fd
,
(
void
*
)
address
,
(
size_t
)
len
,
(
off_t
)
offset
);
}
JNIEXPORT
jlong
JNICALL
Java_com_questdb_std_Files_sequentialRead
(
JNIEnv
*
e
,
jclass
cl
,
jlong
fd
,
jlong
address
,
jint
len
)
{
return
read
((
int
)
fd
,
(
void
*
)
address
,
(
size_t
)
len
);
}
JNIEXPORT
jlong
JNICALL
Java_com_questdb_std_Files_getLastModified
(
JNIEnv
*
e
,
jclass
cl
,
jlong
pchar
)
{
struct
stat
st
;
...
...
core/src/main/c/share/files.h
浏览文件 @
d6dce89e
...
...
@@ -109,14 +109,6 @@ JNIEXPORT jint JNICALL Java_com_questdb_std_Files_lock
JNIEXPORT
jlong
JNICALL
Java_com_questdb_std_Files_read
(
JNIEnv
*
,
jclass
,
jlong
,
jlong
,
jlong
,
jlong
);
/*
* Class: com_questdb_std_Files
* Method: sequentialRead
* Signature: (JJI)J
*/
JNIEXPORT
jlong
JNICALL
Java_com_questdb_std_Files_sequentialRead
(
JNIEnv
*
,
jclass
,
jlong
,
jlong
,
jint
);
/*
* Class: com_questdb_std_Files
* Method: truncate
...
...
core/src/main/c/windows/files.c
浏览文件 @
d6dce89e
...
...
@@ -79,17 +79,6 @@ JNIEXPORT jlong JNICALL Java_com_questdb_std_Files_read
#define MILLIS_SINCE_1970 11644473600000
JNIEXPORT
jlong
JNICALL
Java_com_questdb_std_Files_sequentialRead
(
JNIEnv
*
e
,
jclass
cl
,
jlong
fd
,
jlong
address
,
jint
len
)
{
DWORD
count
;
WINBOOL
r
=
ReadFile
((
HANDLE
)
fd
,
(
LPVOID
)
address
,
(
DWORD
)
len
,
&
count
,
NULL
);
if
(
r
)
{
return
count
;
}
SaveLastError
();
return
0
;
}
JNIEXPORT
jlong
JNICALL
Java_com_questdb_std_Files_getLastModified
(
JNIEnv
*
e
,
jclass
cl
,
jlong
lpszName
)
{
...
...
core/src/main/java/com/questdb/PropServerConfiguration.java
浏览文件 @
d6dce89e
...
...
@@ -31,16 +31,21 @@ import com.questdb.cutlass.http.processors.TextImportProcessorConfiguration;
import
com.questdb.cutlass.line.udp.LineUdpReceiverConfiguration
;
import
com.questdb.cutlass.text.TextConfiguration
;
import
com.questdb.network.*
;
import
com.questdb.std.*
;
import
com.questdb.std.FilesFacade
;
import
com.questdb.std.FilesFacadeImpl
;
import
com.questdb.std.Numbers
;
import
com.questdb.std.NumericException
;
import
com.questdb.std.microtime.MicrosecondClock
;
import
com.questdb.std.microtime.MicrosecondClockImpl
;
import
com.questdb.std.str.Path
;
import
com.questdb.std.time.MillisecondClock
;
import
com.questdb.std.time.MillisecondClockImpl
;
import
java.io.File
;
import
java.util.Properties
;
public
class
PropServerConfiguration
implements
ServerConfigurationV2
{
public
static
final
String
CONFIG_DIRECTORY
=
"conf"
;
private
final
IODispatcherConfiguration
ioDispatcherConfiguration
=
new
PropIODispatcherConfiguration
();
private
final
TextImportProcessorConfiguration
textImportProcessorConfiguration
=
new
PropTextImportProcessorConfiguration
();
private
final
StaticContentProcessorConfiguration
staticContentProcessorConfiguration
=
new
PropStaticContentProcessorConfiguration
();
...
...
@@ -58,7 +63,7 @@ public class PropServerConfiguration implements ServerConfigurationV2 {
private
final
int
workerCount
;
private
final
int
sendBufferSize
;
private
final
CharSequence
indexFileName
;
private
final
CharSequence
publicDirectory
;
private
final
String
publicDirectory
;
private
final
boolean
abortBrokenUploads
;
private
final
int
activeConnectionLimit
;
private
final
int
eventCapacity
;
...
...
@@ -140,7 +145,16 @@ public class PropServerConfiguration implements ServerConfigurationV2 {
this
.
workerCount
=
getInt
(
properties
,
"http.worker.count"
,
2
);
this
.
sendBufferSize
=
getIntSize
(
properties
,
"http.send.buffer.size"
,
2
*
1024
*
1024
);
this
.
indexFileName
=
getString
(
properties
,
"http.static.index.file.name"
,
"index.html"
);
this
.
publicDirectory
=
getString
(
properties
,
"http.static.pubic.directory"
,
"public"
);
final
String
publicDirectory
=
getString
(
properties
,
"http.static.pubic.directory"
,
"public"
);
// translate public directory into absolute path
// this will generate some garbage, but this is ok - we just doing this once on startup
if
(
new
File
(
publicDirectory
).
isAbsolute
())
{
this
.
publicDirectory
=
publicDirectory
;
}
else
{
this
.
publicDirectory
=
new
File
(
root
,
publicDirectory
).
getAbsolutePath
();
}
this
.
abortBrokenUploads
=
getBoolean
(
properties
,
"http.text.abort.broken.uploads"
,
true
);
this
.
activeConnectionLimit
=
getInt
(
properties
,
"http.net.active.connection.limit"
,
256
);
this
.
eventCapacity
=
getInt
(
properties
,
"http.net.event.capacity"
,
1024
);
...
...
@@ -169,13 +183,8 @@ public class PropServerConfiguration implements ServerConfigurationV2 {
bindPort
=
p
;
});
String
defaultFilePath
=
this
.
getClass
().
getResource
(
"/site/conf/mime.types"
).
getFile
();
if
(
Os
.
type
==
Os
.
WINDOWS
)
{
// on Windows Java returns "/C:/dir/file". This leading slash is Java specific and doesn't bode well
// with OS file open methods.
defaultFilePath
=
defaultFilePath
.
substring
(
1
);
}
try
(
Path
path
=
new
Path
().
of
(
defaultFilePath
).
$
())
{
// load mime types
try
(
Path
path
=
new
Path
().
of
(
new
File
(
new
File
(
root
,
CONFIG_DIRECTORY
),
"mime.types"
).
getAbsolutePath
()).
$
())
{
this
.
mimeTypesCache
=
new
MimeTypesCache
(
FilesFacadeImpl
.
INSTANCE
,
path
);
}
...
...
@@ -356,6 +365,11 @@ public class PropServerConfiguration implements ServerConfigurationV2 {
return
mimeTypesCache
;
}
/**
* Absolute path to HTTP public directory.
*
* @return path to public directory
*/
@Override
public
CharSequence
getPublicDirectory
()
{
return
publicDirectory
;
...
...
core/src/main/java/com/questdb/ServerMain.java
0 → 100644
浏览文件 @
d6dce89e
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-2019 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,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
package
com.questdb
;
import
com.questdb.cairo.CairoEngine
;
import
com.questdb.net.http.HttpServer
;
import
com.questdb.std.CharSequenceObjHashMap
;
import
com.questdb.std.Os
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.nio.file.*
;
import
java.nio.file.attribute.BasicFileAttributes
;
import
java.util.EnumSet
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.Properties
;
import
java.util.jar.Attributes
;
import
java.util.jar.Manifest
;
import
static
java
.
nio
.
file
.
StandardCopyOption
.
COPY_ATTRIBUTES
;
import
static
java
.
nio
.
file
.
StandardCopyOption
.
REPLACE_EXISTING
;
public
class
ServerMain
{
public
ServerMain
(
String
[]
args
)
throws
Exception
{
System
.
err
.
printf
(
"QuestDB server %s%nCopyright (C) Appsicle 2014-2019, all rights reserved.%n%n"
,
getVersion
());
if
(
args
.
length
<
1
)
{
System
.
err
.
println
(
"Root directory name expected"
);
return
;
}
if
(
Os
.
type
==
Os
.
_32Bit
)
{
System
.
err
.
println
(
"QuestDB requires 64-bit JVM"
);
return
;
}
final
CharSequenceObjHashMap
<
String
>
optHash
=
hashArgs
(
args
);
// expected flags:
// -d <root dir> = sets root directory
// -f = forces copy of site to root directory even if site exists
// -n = disables handling of HUP signal
final
String
rootDirectory
=
optHash
.
get
(
"-d"
);
extractSite
(
rootDirectory
,
optHash
.
get
(
"-f"
)
!=
null
);
final
Properties
properties
=
new
Properties
();
final
String
configurationFileName
=
"/server.conf"
;
final
File
configurationFile
=
new
File
(
new
File
(
rootDirectory
,
PropServerConfiguration
.
CONFIG_DIRECTORY
),
configurationFileName
);
try
(
InputStream
is
=
new
FileInputStream
(
configurationFile
))
{
properties
.
load
(
is
);
}
// todo: load path to data directory from configuration
final
PropServerConfiguration
configuration
=
new
PropServerConfiguration
(
rootDirectory
,
properties
);
final
CairoEngine
cairoEngine
=
new
CairoEngine
(
configuration
.
getCairoConfiguration
());
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
ServerMain
(
args
);
}
private
static
CharSequenceObjHashMap
<
String
>
hashArgs
(
String
[]
args
)
{
CharSequenceObjHashMap
<
String
>
optHash
=
new
CharSequenceObjHashMap
<>();
String
flag
=
null
;
for
(
int
i
=
0
,
n
=
args
.
length
;
i
<
n
;
i
++)
{
String
s
=
args
[
i
];
if
(
s
.
startsWith
(
"-"
))
{
if
(
flag
!=
null
)
{
optHash
.
put
(
flag
,
""
);
}
flag
=
s
;
}
else
{
if
(
flag
!=
null
)
{
optHash
.
put
(
flag
,
s
);
flag
=
null
;
}
else
{
System
.
err
.
println
(
"Unknown arg: "
+
s
);
System
.
exit
(
55
);
}
}
}
if
(
flag
!=
null
)
{
optHash
.
put
(
flag
,
""
);
}
return
optHash
;
}
private
static
void
extractSite
(
String
dir
,
boolean
force
)
throws
URISyntaxException
,
IOException
{
System
.
out
.
println
(
"Preparing site content..."
);
URL
url
=
HttpServer
.
class
.
getResource
(
"/site/"
);
String
[]
components
=
url
.
toURI
().
toString
().
split
(
"!"
);
FileSystem
fs
=
null
;
final
Path
source
;
final
int
sourceLen
;
if
(
components
.
length
>
1
)
{
fs
=
FileSystems
.
newFileSystem
(
URI
.
create
(
components
[
0
]),
new
HashMap
<>());
source
=
fs
.
getPath
(
components
[
1
]);
sourceLen
=
source
.
toAbsolutePath
().
toString
().
length
();
}
else
{
source
=
Paths
.
get
(
url
.
toURI
());
sourceLen
=
source
.
toAbsolutePath
().
toString
().
length
()
+
1
;
}
try
{
final
Path
target
=
Paths
.
get
(
dir
);
final
EnumSet
<
FileVisitOption
>
walkOptions
=
EnumSet
.
of
(
FileVisitOption
.
FOLLOW_LINKS
);
final
CopyOption
[]
copyOptions
=
new
CopyOption
[]{
COPY_ATTRIBUTES
,
REPLACE_EXISTING
};
if
(
force
)
{
File
pub
=
new
File
(
dir
,
"public"
);
if
(
pub
.
exists
())
{
com
.
questdb
.
store
.
Files
.
delete
(
pub
);
}
}
Files
.
walkFileTree
(
source
,
walkOptions
,
Integer
.
MAX_VALUE
,
new
FileVisitor
<
Path
>()
{
private
boolean
skip
=
true
;
@Override
public
FileVisitResult
preVisitDirectory
(
Path
dir
,
BasicFileAttributes
attrs
)
{
if
(
skip
)
{
skip
=
false
;
}
else
{
try
{
Files
.
copy
(
dir
,
toDestination
(
dir
),
copyOptions
);
System
.
out
.
println
(
"Extracted "
+
dir
);
}
catch
(
FileAlreadyExistsException
ignore
)
{
}
catch
(
IOException
x
)
{
return
FileVisitResult
.
SKIP_SUBTREE
;
}
}
return
FileVisitResult
.
CONTINUE
;
}
@Override
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
throws
IOException
{
Files
.
copy
(
file
,
toDestination
(
file
),
copyOptions
);
System
.
out
.
println
(
"Extracted "
+
file
);
return
FileVisitResult
.
CONTINUE
;
}
@Override
public
FileVisitResult
visitFileFailed
(
Path
file
,
IOException
exc
)
{
return
FileVisitResult
.
CONTINUE
;
}
@Override
public
FileVisitResult
postVisitDirectory
(
Path
dir
,
IOException
exc
)
{
return
FileVisitResult
.
CONTINUE
;
}
private
Path
toDestination
(
final
Path
path
)
{
final
Path
tmp
=
path
.
toAbsolutePath
();
return
target
.
resolve
(
tmp
.
toString
().
substring
(
sourceLen
));
}
});
}
finally
{
System
.
out
.
println
(
"Site content is ready"
);
if
(
fs
!=
null
)
{
fs
.
close
();
}
}
}
private
String
getVersion
()
throws
IOException
{
Enumeration
<
URL
>
resources
=
BootstrapMain
.
class
.
getClassLoader
()
.
getResources
(
"META-INF/MANIFEST.MF"
);
while
(
resources
.
hasMoreElements
())
{
try
(
InputStream
is
=
resources
.
nextElement
().
openStream
())
{
Manifest
manifest
=
new
Manifest
(
is
);
Attributes
attributes
=
manifest
.
getMainAttributes
();
if
(
"org.questdb"
.
equals
(
attributes
.
getValue
(
"Implementation-Vendor-Id"
)))
{
return
manifest
.
getMainAttributes
().
getValue
(
"Implementation-Version"
);
}
}
}
return
"[DEVELOPMENT]"
;
}
}
core/src/main/java/com/questdb/cairo/AbstractDataFrameCursorFactory.java
浏览文件 @
d6dce89e
...
...
@@ -23,7 +23,6 @@
package
com.questdb.cairo
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cairo.sql.DataFrameCursorFactory
;
public
abstract
class
AbstractDataFrameCursorFactory
implements
DataFrameCursorFactory
{
...
...
core/src/main/java/com/questdb/cairo/Engine.java
→
core/src/main/java/com/questdb/cairo/
Cairo
Engine.java
浏览文件 @
d6dce89e
...
...
@@ -26,7 +26,6 @@ package com.questdb.cairo;
import
com.questdb.cairo.pool.PoolListener
;
import
com.questdb.cairo.pool.ReaderPool
;
import
com.questdb.cairo.pool.WriterPool
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.log.Log
;
import
com.questdb.log.LogFactory
;
import
com.questdb.mp.SynchronizedJob
;
...
...
@@ -38,18 +37,18 @@ import org.jetbrains.annotations.Nullable;
import
java.io.Closeable
;
public
class
Engine
implements
Closeable
,
CairoEngin
e
{
private
static
final
Log
LOG
=
LogFactory
.
getLog
(
Engine
.
class
);
public
class
CairoEngine
implements
Closeabl
e
{
private
static
final
Log
LOG
=
LogFactory
.
getLog
(
Cairo
Engine
.
class
);
private
final
WriterPool
writerPool
;
private
final
ReaderPool
readerPool
;
private
final
CairoConfiguration
configuration
;
public
Engine
(
CairoConfiguration
configuration
)
{
public
Cairo
Engine
(
CairoConfiguration
configuration
)
{
this
(
configuration
,
null
);
}
public
Engine
(
CairoConfiguration
configuration
,
CairoWorkScheduler
workScheduler
)
{
public
Cairo
Engine
(
CairoConfiguration
configuration
,
CairoWorkScheduler
workScheduler
)
{
this
.
configuration
=
configuration
;
this
.
writerPool
=
new
WriterPool
(
configuration
,
workScheduler
);
this
.
readerPool
=
new
ReaderPool
(
configuration
);
...
...
@@ -73,7 +72,6 @@ public class Engine implements Closeable, CairoEngine {
return
writerPool
.
getBusyCount
();
}
@Override
public
CairoConfiguration
getConfiguration
()
{
return
configuration
;
}
...
...
@@ -87,7 +85,6 @@ public class Engine implements Closeable, CairoEngine {
this
.
readerPool
.
setPoolListener
(
poolListener
);
}
@Override
public
TableReader
getReader
(
CharSequence
tableName
,
long
version
)
{
TableReader
reader
=
readerPool
.
get
(
tableName
);
if
(
version
>
-
1
&&
reader
.
getVersion
()
!=
version
)
{
...
...
@@ -97,17 +94,14 @@ public class Engine implements Closeable, CairoEngine {
return
reader
;
}
@Override
public
int
getStatus
(
Path
path
,
CharSequence
tableName
,
int
lo
,
int
hi
)
{
return
TableUtils
.
exists
(
configuration
.
getFilesFacade
(),
path
,
configuration
.
getRoot
(),
tableName
,
lo
,
hi
);
}
@Override
public
TableWriter
getWriter
(
CharSequence
tableName
)
{
return
writerPool
.
get
(
tableName
);
}
@Override
public
boolean
lock
(
CharSequence
tableName
)
{
if
(
writerPool
.
lock
(
tableName
))
{
boolean
locked
=
readerPool
.
lock
(
tableName
);
...
...
@@ -119,23 +113,19 @@ public class Engine implements Closeable, CairoEngine {
return
false
;
}
@Override
public
boolean
releaseAllReaders
()
{
return
readerPool
.
releaseAll
();
}
@Override
public
boolean
releaseAllWriters
()
{
return
writerPool
.
releaseAll
();
}
@Override
public
void
unlock
(
CharSequence
tableName
,
@Nullable
TableWriter
writer
)
{
readerPool
.
unlock
(
tableName
);
writerPool
.
unlock
(
tableName
,
writer
);
}
@Override
public
void
remove
(
Path
path
,
CharSequence
tableName
)
{
if
(
lock
(
tableName
))
{
try
{
...
...
@@ -153,7 +143,6 @@ public class Engine implements Closeable, CairoEngine {
throw
CairoException
.
instance
(
configuration
.
getFilesFacade
().
errno
()).
put
(
"Cannot lock "
).
put
(
tableName
);
}
@Override
public
void
rename
(
Path
path
,
CharSequence
tableName
,
Path
otherPath
,
String
newName
)
{
if
(
lock
(
tableName
))
{
try
{
...
...
@@ -191,6 +180,10 @@ public class Engine implements Closeable, CairoEngine {
}
}
public
int
getStatus
(
Path
path
,
CharSequence
tableName
)
{
return
getStatus
(
path
,
tableName
,
0
,
tableName
.
length
());
}
private
class
WriterMaintenanceJob
extends
SynchronizedJob
{
private
final
MicrosecondClock
clock
;
...
...
core/src/main/java/com/questdb/cairo/FullBwdDataFrameCursorFactory.java
浏览文件 @
d6dce89e
...
...
@@ -23,7 +23,6 @@
package
com.questdb.cairo
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cairo.sql.DataFrameCursor
;
public
class
FullBwdDataFrameCursorFactory
extends
AbstractDataFrameCursorFactory
{
...
...
core/src/main/java/com/questdb/cairo/FullFwdDataFrameCursorFactory.java
浏览文件 @
d6dce89e
...
...
@@ -23,7 +23,6 @@
package
com.questdb.cairo
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cairo.sql.DataFrameCursor
;
public
class
FullFwdDataFrameCursorFactory
extends
AbstractDataFrameCursorFactory
{
...
...
core/src/main/java/com/questdb/cairo/IntervalBwdDataFrameCursorFactory.java
浏览文件 @
d6dce89e
...
...
@@ -23,7 +23,6 @@
package
com.questdb.cairo
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cairo.sql.DataFrameCursor
;
import
com.questdb.std.LongList
;
...
...
core/src/main/java/com/questdb/cairo/IntervalFwdDataFrameCursorFactory.java
浏览文件 @
d6dce89e
...
...
@@ -23,7 +23,6 @@
package
com.questdb.cairo
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cairo.sql.DataFrameCursor
;
import
com.questdb.std.LongList
;
...
...
core/src/main/java/com/questdb/cairo/TableReaderRecordCursorFactory.java
浏览文件 @
d6dce89e
...
...
@@ -23,7 +23,6 @@
package
com.questdb.cairo
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cairo.sql.RecordCursor
;
import
com.questdb.cairo.sql.RecordMetadata
;
import
com.questdb.griffin.engine.functions.bind.BindVariableService
;
...
...
core/src/main/java/com/questdb/cairo/sql/CairoEngine.java
已删除
100644 → 0
浏览文件 @
92536794
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-2019 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,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
package
com.questdb.cairo.sql
;
import
com.questdb.cairo.CairoConfiguration
;
import
com.questdb.cairo.TableReader
;
import
com.questdb.cairo.TableWriter
;
import
com.questdb.std.str.Path
;
import
org.jetbrains.annotations.Nullable
;
import
java.io.Closeable
;
public
interface
CairoEngine
extends
Closeable
{
@Override
void
close
();
TableReader
getReader
(
CharSequence
tableName
,
long
version
);
int
getStatus
(
Path
path
,
CharSequence
tableName
,
int
lo
,
int
hi
);
default
int
getStatus
(
Path
path
,
CharSequence
tableName
)
{
return
getStatus
(
path
,
tableName
,
0
,
tableName
.
length
());
}
TableWriter
getWriter
(
CharSequence
tableName
);
boolean
lock
(
CharSequence
tableName
);
boolean
releaseAllReaders
();
boolean
releaseAllWriters
();
void
remove
(
Path
path
,
CharSequence
tableName
);
void
rename
(
Path
path
,
CharSequence
tableName
,
Path
otherPath
,
String
newName
);
void
unlock
(
CharSequence
tableName
,
@Nullable
TableWriter
writer
);
CairoConfiguration
getConfiguration
();
}
core/src/main/java/com/questdb/cutlass/http/processors/JsonQueryProcessor.java
浏览文件 @
d6dce89e
...
...
@@ -23,10 +23,10 @@
package
com.questdb.cutlass.http.processors
;
import
com.questdb.cairo.CairoEngine
;
import
com.questdb.cairo.CairoError
;
import
com.questdb.cairo.CairoException
;
import
com.questdb.cairo.ColumnType
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cairo.sql.Record
;
import
com.questdb.cairo.sql.RecordCursorFactory
;
import
com.questdb.cutlass.http.*
;
...
...
core/src/main/java/com/questdb/cutlass/http/processors/TextImportProcessor.java
浏览文件 @
d6dce89e
...
...
@@ -23,8 +23,8 @@
package
com.questdb.cutlass.http.processors
;
import
com.questdb.cairo.CairoEngine
;
import
com.questdb.cairo.PartitionBy
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cairo.sql.RecordMetadata
;
import
com.questdb.cutlass.http.*
;
import
com.questdb.cutlass.json.JsonException
;
...
...
core/src/main/java/com/questdb/cutlass/http/processors/TextImportProcessorState.java
浏览文件 @
d6dce89e
...
...
@@ -23,7 +23,7 @@
package
com.questdb.cutlass.http.processors
;
import
com.questdb.cairo.
sql.
CairoEngine
;
import
com.questdb.cairo.CairoEngine
;
import
com.questdb.cutlass.json.JsonException
;
import
com.questdb.cutlass.text.TextConfiguration
;
import
com.questdb.cutlass.text.TextLoader
;
...
...
core/src/main/java/com/questdb/cutlass/line/CairoLineProtoParser.java
浏览文件 @
d6dce89e
...
...
@@ -24,7 +24,6 @@
package
com.questdb.cutlass.line
;
import
com.questdb.cairo.*
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cairo.sql.RecordMetadata
;
import
com.questdb.log.Log
;
import
com.questdb.log.LogFactory
;
...
...
core/src/main/java/com/questdb/cutlass/line/udp/GenericLineProtoReceiver.java
浏览文件 @
d6dce89e
...
...
@@ -23,8 +23,8 @@
package
com.questdb.cutlass.line.udp
;
import
com.questdb.cairo.CairoEngine
;
import
com.questdb.cairo.CairoException
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cutlass.line.CairoLineProtoParser
;
import
com.questdb.cutlass.line.LineProtoLexer
;
import
com.questdb.log.Log
;
...
...
core/src/main/java/com/questdb/cutlass/line/udp/LinuxLineProtoReceiver.java
浏览文件 @
d6dce89e
...
...
@@ -23,8 +23,8 @@
package
com.questdb.cutlass.line.udp
;
import
com.questdb.cairo.CairoEngine
;
import
com.questdb.cairo.CairoException
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cutlass.line.CairoLineProtoParser
;
import
com.questdb.cutlass.line.LineProtoLexer
;
import
com.questdb.log.Log
;
...
...
core/src/main/java/com/questdb/cutlass/line/udp/ReceiverFactory.java
浏览文件 @
d6dce89e
...
...
@@ -23,7 +23,7 @@
package
com.questdb.cutlass.line.udp
;
import
com.questdb.cairo.
sql.
CairoEngine
;
import
com.questdb.cairo.CairoEngine
;
import
com.questdb.mp.Job
;
@FunctionalInterface
...
...
core/src/main/java/com/questdb/cutlass/text/CairoTextWriter.java
浏览文件 @
d6dce89e
...
...
@@ -24,7 +24,6 @@
package
com.questdb.cutlass.text
;
import
com.questdb.cairo.*
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cairo.sql.RecordMetadata
;
import
com.questdb.cutlass.text.types.BadDateAdapter
;
import
com.questdb.cutlass.text.types.BadTimestampAdapter
;
...
...
core/src/main/java/com/questdb/cutlass/text/TextLoader.java
浏览文件 @
d6dce89e
...
...
@@ -23,7 +23,7 @@
package
com.questdb.cutlass.text
;
import
com.questdb.cairo.
sql.
CairoEngine
;
import
com.questdb.cairo.CairoEngine
;
import
com.questdb.cairo.sql.RecordMetadata
;
import
com.questdb.cutlass.json.JsonException
;
import
com.questdb.cutlass.json.JsonLexer
;
...
...
core/src/main/java/com/questdb/griffin/SqlOptimiser.java
浏览文件 @
d6dce89e
...
...
@@ -25,7 +25,6 @@ package com.questdb.griffin;
import
com.questdb.cairo.*
;
import
com.questdb.cairo.pool.ex.EntryLockedException
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cairo.sql.Function
;
import
com.questdb.cairo.sql.RecordMetadata
;
import
com.questdb.griffin.model.*
;
...
...
core/src/main/java/com/questdb/std/Files.java
浏览文件 @
d6dce89e
...
...
@@ -70,16 +70,6 @@ public final class Files {
return
res
;
}
public
static
long
copy
(
long
fdFrom
,
long
fdTo
,
long
bufPtr
,
int
bufSize
)
{
long
total
=
0
;
long
l
;
while
((
l
=
Files
.
sequentialRead
(
fdFrom
,
bufPtr
,
bufSize
))
>
0
)
{
Files
.
append
(
fdTo
,
bufPtr
,
(
int
)
l
);
total
+=
l
;
}
return
total
;
}
public
static
native
boolean
exists
(
long
fd
);
public
static
boolean
exists
(
LPSZ
lpsz
)
{
...
...
core/src/main/resources/binaries/windows/libquestdb.dll
浏览文件 @
d6dce89e
无法预览此类型文件
core/src/main/resources/site/conf/server.conf
0 → 100644
浏览文件 @
d6dce89e
core/src/test/java/com/questdb/FilesTest.java
浏览文件 @
d6dce89e
...
...
@@ -46,52 +46,6 @@ public class FilesTest {
@Rule
public
final
TemporaryFolder
temporaryFolder
=
new
TemporaryFolder
();
@Test
public
void
testAppendAndSeqRead
()
throws
Exception
{
try
(
Path
path
=
new
Path
())
{
File
f
=
temporaryFolder
.
newFile
();
long
fd
=
Files
.
openRW
(
path
.
of
(
f
.
getAbsolutePath
()).
$
());
try
{
Assert
.
assertTrue
(
fd
>
0
);
ByteBuffer
buf
=
ByteBuffer
.
allocateDirect
(
1024
).
order
(
ByteOrder
.
LITTLE_ENDIAN
);
try
{
ByteBuffers
.
putStr
(
buf
,
"hello from java"
);
Files
.
append
(
fd
,
ByteBuffers
.
getAddress
(
buf
),
buf
.
position
());
buf
.
clear
();
ByteBuffers
.
putStr
(
buf
,
", awesome"
);
Files
.
append
(
fd
,
ByteBuffers
.
getAddress
(
buf
),
buf
.
position
());
}
finally
{
ByteBuffers
.
release
(
buf
);
}
}
finally
{
Files
.
close
(
fd
);
}
fd
=
Files
.
openRO
(
path
);
try
{
Assert
.
assertTrue
(
fd
>
0
);
ByteBuffer
buf
=
ByteBuffer
.
allocateDirect
(
1024
).
order
(
ByteOrder
.
LITTLE_ENDIAN
);
try
{
int
len
=
(
int
)
Files
.
length
(
path
);
long
ptr
=
ByteBuffers
.
getAddress
(
buf
);
Assert
.
assertEquals
(
48
,
Files
.
sequentialRead
(
fd
,
ptr
,
len
));
DirectCharSequence
cs
=
new
DirectCharSequence
().
of
(
ptr
,
ptr
+
len
);
TestUtils
.
assertEquals
(
"hello from java, awesome"
,
cs
);
}
finally
{
ByteBuffers
.
release
(
buf
);
}
}
finally
{
Files
.
close
(
fd
);
}
Assert
.
assertTrue
(
Files
.
exists
(
path
));
Assert
.
assertFalse
(
Files
.
exists
(
path
.
of
(
"/x/yz/1/2/3"
).
$
()));
}
}
@Test
public
void
testDeleteDir
()
throws
Exception
{
File
r
=
temporaryFolder
.
newFolder
(
"to_delete"
);
...
...
core/src/test/java/com/questdb/PropServerConfigurationTest.java
浏览文件 @
d6dce89e
...
...
@@ -32,18 +32,46 @@ import com.questdb.std.microtime.MicrosecondClockImpl;
import
com.questdb.std.time.MillisecondClockImpl
;
import
com.questdb.test.tools.TestUtils
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.rules.TemporaryFolder
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Properties
;
public
class
PropServerConfigurationTest
{
public
final
TemporaryFolder
temp
=
new
TemporaryFolder
();
@Before
public
void
setUp
()
throws
Exception
{
temp
.
create
();
}
private
void
copyMimeTypes
(
String
targetDir
)
throws
IOException
{
try
(
InputStream
stream
=
PropServerConfigurationTest
.
class
.
getResourceAsStream
(
"/site/conf/mime.types"
))
{
Assert
.
assertNotNull
(
stream
);
final
File
target
=
new
File
(
targetDir
,
"conf/mime.types"
);
Assert
.
assertTrue
(
target
.
getParentFile
().
mkdirs
());
try
(
FileOutputStream
fos
=
new
FileOutputStream
(
target
))
{
byte
[]
buffer
=
new
byte
[
1024
*
1204
];
int
len
;
while
((
len
=
stream
.
read
(
buffer
))
>
0
)
{
fos
.
write
(
buffer
,
0
,
len
);
}
}
}
}
@Test
public
void
testAllDefaults
()
throws
ServerConfigurationException
{
public
void
testAllDefaults
()
throws
ServerConfigurationException
,
IOException
{
Properties
properties
=
new
Properties
();
PropServerConfiguration
configuration
=
new
PropServerConfiguration
(
"root"
,
properties
);
File
root
=
new
File
(
temp
.
getRoot
(),
"root"
);
copyMimeTypes
(
root
.
getAbsolutePath
());
PropServerConfiguration
configuration
=
new
PropServerConfiguration
(
root
.
getAbsolutePath
(),
properties
);
Assert
.
assertEquals
(
16
,
configuration
.
getHttpServerConfiguration
().
getConnectionPoolInitialCapacity
());
Assert
.
assertEquals
(
128
,
configuration
.
getHttpServerConfiguration
().
getConnectionStringPoolCapacity
());
Assert
.
assertEquals
(
512
,
configuration
.
getHttpServerConfiguration
().
getMultipartHeaderBufferSize
());
...
...
@@ -54,7 +82,12 @@ public class PropServerConfigurationTest {
Assert
.
assertEquals
(
2
,
configuration
.
getHttpServerConfiguration
().
getWorkerCount
());
Assert
.
assertEquals
(
2097152
,
configuration
.
getHttpServerConfiguration
().
getSendBufferSize
());
Assert
.
assertEquals
(
"index.html"
,
configuration
.
getHttpServerConfiguration
().
getStaticContentProcessorConfiguration
().
getIndexFileName
());
Assert
.
assertEquals
(
"public"
,
configuration
.
getHttpServerConfiguration
().
getStaticContentProcessorConfiguration
().
getPublicDirectory
());
// this is going to need interesting validation logic
// configuration path is expected to be relative and we need to check if absolute path is good
Assert
.
assertEquals
(
new
File
(
root
,
"public"
).
getAbsolutePath
(),
configuration
.
getHttpServerConfiguration
().
getStaticContentProcessorConfiguration
().
getPublicDirectory
());
Assert
.
assertTrue
(
configuration
.
getHttpServerConfiguration
().
getTextImportProcessorConfiguration
().
abortBrokenUploads
());
Assert
.
assertEquals
(
256
,
configuration
.
getHttpServerConfiguration
().
getDispatcherConfiguration
().
getActiveConnectionLimit
());
...
...
@@ -140,7 +173,7 @@ public class PropServerConfigurationTest {
Assert
.
assertSame
(
MillisecondClockImpl
.
INSTANCE
,
configuration
.
getCairoConfiguration
().
getMillisecondClock
());
Assert
.
assertSame
(
MicrosecondClockImpl
.
INSTANCE
,
configuration
.
getCairoConfiguration
().
getMicrosecondClock
());
Assert
.
assertSame
(
NetworkFacadeImpl
.
INSTANCE
,
configuration
.
getLineUdpReceiverConfiguration
().
getNetworkFacade
());
TestUtils
.
assertEquals
(
"root"
,
configuration
.
getCairoConfiguration
().
getRoot
());
TestUtils
.
assertEquals
(
root
.
getAbsolutePath
()
,
configuration
.
getCairoConfiguration
().
getRoot
());
// assert mime types
TestUtils
.
assertEquals
(
"application/json"
,
configuration
.
getHttpServerConfiguration
().
getStaticContentProcessorConfiguration
().
getMimeTypesCache
().
get
(
"json"
));
...
...
@@ -175,10 +208,12 @@ public class PropServerConfigurationTest {
}
@Test
(
expected
=
ServerConfigurationException
.
class
)
public
void
testInvalidIPv4Address
()
throws
ServerConfigurationException
{
public
void
testInvalidIPv4Address
()
throws
ServerConfigurationException
,
IOException
{
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
"line.udp.join"
,
"12a.990.00"
);
new
PropServerConfiguration
(
"root"
,
properties
);
File
root
=
new
File
(
temp
.
getRoot
(),
"data"
);
copyMimeTypes
(
root
.
getAbsolutePath
());
new
PropServerConfiguration
(
root
.
getAbsolutePath
(),
properties
);
}
@Test
(
expected
=
ServerConfigurationException
.
class
)
...
...
@@ -196,10 +231,12 @@ public class PropServerConfigurationTest {
}
@Test
(
expected
=
ServerConfigurationException
.
class
)
public
void
testInvalidLong
()
throws
ServerConfigurationException
{
public
void
testInvalidLong
()
throws
ServerConfigurationException
,
IOException
{
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
"cairo.idle.check.interval"
,
"1234a"
);
new
PropServerConfiguration
(
"root"
,
properties
);
File
root
=
new
File
(
temp
.
getRoot
(),
"data"
);
copyMimeTypes
(
root
.
getAbsolutePath
());
new
PropServerConfiguration
(
root
.
getAbsolutePath
(),
properties
);
}
@Test
...
...
@@ -207,7 +244,11 @@ public class PropServerConfigurationTest {
try
(
InputStream
is
=
PropServerConfigurationTest
.
class
.
getResourceAsStream
(
"/server.conf"
))
{
Properties
properties
=
new
Properties
();
properties
.
load
(
is
);
PropServerConfiguration
configuration
=
new
PropServerConfiguration
(
"data"
,
properties
);
File
root
=
new
File
(
temp
.
getRoot
(),
"data"
);
copyMimeTypes
(
root
.
getAbsolutePath
());
PropServerConfiguration
configuration
=
new
PropServerConfiguration
(
root
.
getAbsolutePath
(),
properties
);
Assert
.
assertEquals
(
64
,
configuration
.
getHttpServerConfiguration
().
getConnectionPoolInitialCapacity
());
Assert
.
assertEquals
(
512
,
configuration
.
getHttpServerConfiguration
().
getConnectionStringPoolCapacity
());
Assert
.
assertEquals
(
256
,
configuration
.
getHttpServerConfiguration
().
getMultipartHeaderBufferSize
());
...
...
@@ -218,7 +259,10 @@ public class PropServerConfigurationTest {
Assert
.
assertEquals
(
6
,
configuration
.
getHttpServerConfiguration
().
getWorkerCount
());
Assert
.
assertEquals
(
128
,
configuration
.
getHttpServerConfiguration
().
getSendBufferSize
());
Assert
.
assertEquals
(
"index2.html"
,
configuration
.
getHttpServerConfiguration
().
getStaticContentProcessorConfiguration
().
getIndexFileName
());
Assert
.
assertEquals
(
"public_ok"
,
configuration
.
getHttpServerConfiguration
().
getStaticContentProcessorConfiguration
().
getPublicDirectory
());
Assert
.
assertEquals
(
new
File
(
root
,
"public_ok"
).
getAbsolutePath
(),
configuration
.
getHttpServerConfiguration
().
getStaticContentProcessorConfiguration
().
getPublicDirectory
());
Assert
.
assertFalse
(
configuration
.
getHttpServerConfiguration
().
getTextImportProcessorConfiguration
().
abortBrokenUploads
());
Assert
.
assertEquals
(
64
,
configuration
.
getHttpServerConfiguration
().
getDispatcherConfiguration
().
getActiveConnectionLimit
());
Assert
.
assertEquals
(
2048
,
configuration
.
getHttpServerConfiguration
().
getDispatcherConfiguration
().
getEventCapacity
());
...
...
core/src/test/java/com/questdb/cairo/EngineTest.java
→
core/src/test/java/com/questdb/cairo/
Cairo
EngineTest.java
浏览文件 @
d6dce89e
...
...
@@ -35,7 +35,7 @@ import com.questdb.test.tools.TestUtils;
import
org.junit.Assert
;
import
org.junit.Test
;
public
class
EngineTest
extends
AbstractCairoTest
{
public
class
Cairo
EngineTest
extends
AbstractCairoTest
{
private
final
static
Path
path
=
new
Path
();
private
final
static
Path
otherPath
=
new
Path
();
...
...
@@ -55,7 +55,7 @@ public class EngineTest extends AbstractCairoTest {
MyListener
listener
=
new
MyListener
();
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
engine
.
setPoolListener
(
listener
);
Assert
.
assertEquals
(
listener
,
engine
.
getPoolListener
());
...
...
@@ -116,7 +116,7 @@ public class EngineTest extends AbstractCairoTest {
MyListener
listener
=
new
MyListener
();
MyWorkScheduler
workScheduler
=
new
MyWorkScheduler
();
try
(
Engine
engine
=
new
Engine
(
configuration
,
workScheduler
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
,
workScheduler
))
{
engine
.
setPoolListener
(
listener
);
assertWriter
(
engine
,
"x"
);
...
...
@@ -141,7 +141,7 @@ public class EngineTest extends AbstractCairoTest {
createX
();
TestUtils
.
assertMemoryLeak
(()
->
{
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
try
(
TableReader
reader
=
engine
.
getReader
(
"x"
,
TableUtils
.
ANY_TABLE_VERSION
))
{
Assert
.
assertNotNull
(
reader
);
Assert
.
assertFalse
(
engine
.
lock
(
"x"
));
...
...
@@ -157,7 +157,7 @@ public class EngineTest extends AbstractCairoTest {
createX
();
TestUtils
.
assertMemoryLeak
(()
->
{
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
engine
.
rename
(
path
,
"x"
,
otherPath
,
"y"
);
assertWriter
(
engine
,
"y"
);
...
...
@@ -171,7 +171,7 @@ public class EngineTest extends AbstractCairoTest {
TestUtils
.
assertMemoryLeak
(()
->
{
createX
();
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
assertReader
(
engine
,
"x"
);
assertWriter
(
engine
,
"x"
);
engine
.
remove
(
path
,
"x"
);
...
...
@@ -197,7 +197,7 @@ public class EngineTest extends AbstractCairoTest {
createX
();
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
engine
.
remove
(
path
,
"x"
);
Assert
.
assertEquals
(
TableUtils
.
TABLE_DOES_NOT_EXIST
,
engine
.
getStatus
(
path
,
"x"
));
}
...
...
@@ -207,7 +207,7 @@ public class EngineTest extends AbstractCairoTest {
public
void
testRemoveNonExisting
()
throws
Exception
{
createY
();
// this will create root dir at least
TestUtils
.
assertMemoryLeak
(()
->
{
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
try
{
engine
.
remove
(
path
,
"x"
);
Assert
.
fail
();
...
...
@@ -223,7 +223,7 @@ public class EngineTest extends AbstractCairoTest {
TestUtils
.
assertMemoryLeak
(()
->
{
createX
();
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
try
(
TableReader
reader
=
engine
.
getReader
(
"x"
,
TableUtils
.
ANY_TABLE_VERSION
))
{
Assert
.
assertNotNull
(
reader
);
try
{
...
...
@@ -241,7 +241,7 @@ public class EngineTest extends AbstractCairoTest {
TestUtils
.
assertMemoryLeak
(()
->
{
createX
();
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
try
(
TableWriter
writer
=
engine
.
getWriter
(
"x"
))
{
Assert
.
assertNotNull
(
writer
);
try
{
...
...
@@ -259,7 +259,7 @@ public class EngineTest extends AbstractCairoTest {
createX
();
TestUtils
.
assertMemoryLeak
(()
->
{
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
assertWriter
(
engine
,
"x"
);
assertReader
(
engine
,
"x"
);
...
...
@@ -281,7 +281,7 @@ public class EngineTest extends AbstractCairoTest {
try
(
TableWriter
ignored1
=
new
TableWriter
(
configuration
,
"x"
))
{
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
try
{
engine
.
getWriter
(
"x"
);
Assert
.
fail
();
...
...
@@ -325,7 +325,7 @@ public class EngineTest extends AbstractCairoTest {
}
};
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
assertReader
(
engine
,
"x"
);
assertWriter
(
engine
,
"x"
);
try
{
...
...
@@ -355,7 +355,7 @@ public class EngineTest extends AbstractCairoTest {
CairoTestUtils
.
create
(
model
);
}
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
engine
.
rename
(
path
,
"x"
,
otherPath
,
"y"
);
Assert
.
fail
();
}
catch
(
CairoException
e
)
{
...
...
@@ -371,7 +371,7 @@ public class EngineTest extends AbstractCairoTest {
createX
();
createY
();
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
assertWriter
(
engine
,
"x"
);
assertReader
(
engine
,
"x"
);
try
{
...
...
@@ -394,7 +394,7 @@ public class EngineTest extends AbstractCairoTest {
createX
();
TestUtils
.
assertMemoryLeak
(()
->
{
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
assertWriter
(
engine
,
"x"
);
try
{
engine
.
getReader
(
"x"
,
2
);
...
...
@@ -407,13 +407,13 @@ public class EngineTest extends AbstractCairoTest {
});
}
private
void
assertReader
(
Engine
engine
,
String
name
)
{
private
void
assertReader
(
Cairo
Engine
engine
,
String
name
)
{
try
(
TableReader
reader
=
engine
.
getReader
(
name
,
TableUtils
.
ANY_TABLE_VERSION
))
{
Assert
.
assertNotNull
(
reader
);
}
}
private
void
assertWriter
(
Engine
engine
,
String
name
)
{
private
void
assertWriter
(
Cairo
Engine
engine
,
String
name
)
{
try
(
TableWriter
w
=
engine
.
getWriter
(
name
))
{
Assert
.
assertNotNull
(
w
);
}
...
...
core/src/test/java/com/questdb/cairo/FullBwdDataFrameCursorTest.java
浏览文件 @
d6dce89e
...
...
@@ -23,7 +23,6 @@
package
com.questdb.cairo
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cairo.sql.DataFrame
;
import
com.questdb.cairo.sql.DataFrameCursor
;
import
com.questdb.std.Rnd
;
...
...
@@ -85,7 +84,7 @@ public class FullBwdDataFrameCursorTest extends AbstractCairoTest {
}
w
.
commit
();
try
(
CairoEngine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
FullBwdDataFrameCursorFactory
factory
=
new
FullBwdDataFrameCursorFactory
(
engine
,
"x"
,
0
);
final
TableReaderRecord
record
=
new
TableReaderRecord
();
...
...
core/src/test/java/com/questdb/cairo/FullFwdDataFrameCursorFactoryTest.java
浏览文件 @
d6dce89e
...
...
@@ -69,7 +69,7 @@ public class FullFwdDataFrameCursorFactoryTest extends AbstractCairoTest {
writer
.
commit
();
}
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
FullFwdDataFrameCursorFactory
factory
=
new
FullFwdDataFrameCursorFactory
(
engine
,
"x"
,
0
);
long
count
=
0
;
try
(
DataFrameCursor
cursor
=
factory
.
getCursor
())
{
...
...
core/src/test/java/com/questdb/cairo/IntervalBwdDataFrameCursorTest.java
浏览文件 @
d6dce89e
...
...
@@ -23,7 +23,10 @@
package
com.questdb.cairo
;
import
com.questdb.cairo.sql.*
;
import
com.questdb.cairo.sql.DataFrame
;
import
com.questdb.cairo.sql.DataFrameCursor
;
import
com.questdb.cairo.sql.RowCursor
;
import
com.questdb.cairo.sql.SymbolTable
;
import
com.questdb.std.LongList
;
import
com.questdb.std.Rnd
;
import
com.questdb.std.microtime.DateFormatUtils
;
...
...
@@ -358,7 +361,7 @@ public class IntervalBwdDataFrameCursorTest extends AbstractCairoTest {
final
Rnd
rnd
=
new
Rnd
();
long
timestamp
=
DateFormatUtils
.
parseDateTime
(
"1980-01-01T00:00:00.000Z"
);
try
(
CairoEngine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
final
TableReaderRecord
record
=
new
TableReaderRecord
();
final
IntervalBwdDataFrameCursorFactory
factory
=
new
IntervalBwdDataFrameCursorFactory
(
engine
,
"x"
,
0
,
intervals
);
try
(
DataFrameCursor
cursor
=
factory
.
getCursor
())
{
...
...
core/src/test/java/com/questdb/cairo/IntervalFwdDataFrameCursorTest.java
浏览文件 @
d6dce89e
...
...
@@ -23,7 +23,10 @@
package
com.questdb.cairo
;
import
com.questdb.cairo.sql.*
;
import
com.questdb.cairo.sql.DataFrame
;
import
com.questdb.cairo.sql.DataFrameCursor
;
import
com.questdb.cairo.sql.RowCursor
;
import
com.questdb.cairo.sql.SymbolTable
;
import
com.questdb.std.LongList
;
import
com.questdb.std.Rnd
;
import
com.questdb.std.microtime.DateFormatUtils
;
...
...
@@ -359,7 +362,7 @@ public class IntervalFwdDataFrameCursorTest extends AbstractCairoTest {
final
Rnd
rnd
=
new
Rnd
();
long
timestamp
=
DateFormatUtils
.
parseDateTime
(
"1980-01-01T00:00:00.000Z"
);
try
(
CairoEngine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
final
TableReaderRecord
record
=
new
TableReaderRecord
();
final
IntervalFwdDataFrameCursorFactory
factory
=
new
IntervalFwdDataFrameCursorFactory
(
engine
,
"x"
,
0
,
intervals
);
try
(
DataFrameCursor
cursor
=
factory
.
getCursor
())
{
...
...
core/src/test/java/com/questdb/cairo/TableReaderRecordCursorFactoryTest.java
浏览文件 @
d6dce89e
...
...
@@ -77,7 +77,7 @@ public class TableReaderRecordCursorFactoryTest extends AbstractCairoTest {
}
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
final
RecordMetadata
metadata
;
try
(
TableReader
reader
=
engine
.
getReader
(
"x"
,
-
1
))
{
...
...
core/src/test/java/com/questdb/cairo/TableReaderTailRecordCursorTest.java
浏览文件 @
d6dce89e
...
...
@@ -39,7 +39,7 @@ import java.util.concurrent.TimeUnit;
import
java.util.concurrent.atomic.AtomicInteger
;
public
class
TableReaderTailRecordCursorTest
extends
AbstractCairoTest
{
private
final
static
Engine
engine
=
new
Engine
(
configuration
);
private
final
static
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
);
private
final
static
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
);
private
final
static
BindVariableService
bindVariableService
=
new
BindVariableService
();
...
...
core/src/test/java/com/questdb/cutlass/http/IODispatcherTest.java
浏览文件 @
d6dce89e
...
...
@@ -23,11 +23,10 @@
package
com.questdb.cutlass.http
;
import
com.questdb.cairo.CairoEngine
;
import
com.questdb.cairo.CairoTestUtils
;
import
com.questdb.cairo.DefaultCairoConfiguration
;
import
com.questdb.cairo.Engine
;
import
com.questdb.cairo.TestRecord
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cutlass.http.processors.JsonQueryProcessor
;
import
com.questdb.cutlass.http.processors.StaticContentProcessor
;
import
com.questdb.cutlass.http.processors.StaticContentProcessorConfiguration
;
...
...
@@ -243,7 +242,7 @@ public class IODispatcherTest {
final
String
baseDir
=
System
.
getProperty
(
"java.io.tmpdir"
);
final
DefaultHttpServerConfiguration
httpConfiguration
=
createHttpServerConfiguration
(
baseDir
);
try
(
CairoEngine
engine
=
new
Engine
(
new
DefaultCairoConfiguration
(
baseDir
));
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
new
DefaultCairoConfiguration
(
baseDir
));
HttpServer
httpServer
=
new
HttpServer
(
httpConfiguration
))
{
httpServer
.
bind
(
new
HttpRequestProcessorFactory
()
{
@Override
...
...
@@ -406,7 +405,7 @@ public class IODispatcherTest {
final
String
baseDir
=
System
.
getProperty
(
"java.io.tmpdir"
);
final
DefaultHttpServerConfiguration
httpConfiguration
=
createHttpServerConfiguration
(
baseDir
);
try
(
CairoEngine
engine
=
new
Engine
(
new
DefaultCairoConfiguration
(
baseDir
));
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
new
DefaultCairoConfiguration
(
baseDir
));
HttpServer
httpServer
=
new
HttpServer
(
httpConfiguration
)
)
{
httpServer
.
bind
(
new
HttpRequestProcessorFactory
()
{
...
...
@@ -545,7 +544,7 @@ public class IODispatcherTest {
final
DefaultHttpServerConfiguration
httpConfiguration
=
createHttpServerConfiguration
(
baseDir
);
try
(
CairoEngine
engine
=
new
Engine
(
new
DefaultCairoConfiguration
(
baseDir
));
CairoEngine
engine
=
new
Cairo
Engine
(
new
DefaultCairoConfiguration
(
baseDir
));
HttpServer
httpServer
=
new
HttpServer
(
httpConfiguration
)
)
{
httpServer
.
bind
(
new
HttpRequestProcessorFactory
()
{
...
...
@@ -692,7 +691,7 @@ public class IODispatcherTest {
final
DefaultHttpServerConfiguration
httpConfiguration
=
createHttpServerConfiguration
(
baseDir
);
try
(
CairoEngine
engine
=
new
Engine
(
new
DefaultCairoConfiguration
(
baseDir
));
CairoEngine
engine
=
new
Cairo
Engine
(
new
DefaultCairoConfiguration
(
baseDir
));
HttpServer
httpServer
=
new
HttpServer
(
httpConfiguration
)
)
{
httpServer
.
bind
(
new
HttpRequestProcessorFactory
()
{
...
...
@@ -773,7 +772,7 @@ public class IODispatcherTest {
final
String
baseDir
=
System
.
getProperty
(
"java.io.tmpdir"
);
final
DefaultHttpServerConfiguration
httpConfiguration
=
createHttpServerConfiguration
(
nf
,
baseDir
,
128
);
try
(
CairoEngine
engine
=
new
Engine
(
new
DefaultCairoConfiguration
(
baseDir
));
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
new
DefaultCairoConfiguration
(
baseDir
));
HttpServer
httpServer
=
new
HttpServer
(
httpConfiguration
))
{
httpServer
.
bind
(
new
HttpRequestProcessorFactory
()
{
@Override
...
...
@@ -917,7 +916,7 @@ public class IODispatcherTest {
final
DefaultHttpServerConfiguration
httpConfiguration
=
createHttpServerConfiguration
(
baseDir
);
try
(
CairoEngine
engine
=
new
Engine
(
new
DefaultCairoConfiguration
(
baseDir
));
CairoEngine
engine
=
new
Cairo
Engine
(
new
DefaultCairoConfiguration
(
baseDir
));
HttpServer
httpServer
=
new
HttpServer
(
httpConfiguration
)
)
{
httpServer
.
bind
(
new
HttpRequestProcessorFactory
()
{
...
...
@@ -2103,7 +2102,7 @@ public class IODispatcherTest {
final
DefaultHttpServerConfiguration
httpConfiguration
=
createHttpServerConfiguration
(
baseDir
);
try
(
CairoEngine
engine
=
new
Engine
(
new
DefaultCairoConfiguration
(
baseDir
));
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
new
DefaultCairoConfiguration
(
baseDir
));
HttpServer
httpServer
=
new
HttpServer
(
httpConfiguration
))
{
httpServer
.
bind
(
new
HttpRequestProcessorFactory
()
{
@Override
...
...
@@ -2337,7 +2336,7 @@ public class IODispatcherTest {
private
final
HttpServer
httpServer
;
public
CairoHttpServer
(
CharSequence
cairoBaseDir
,
HttpServerConfiguration
configuration
)
{
this
.
engine
=
new
Engine
(
new
DefaultCairoConfiguration
(
cairoBaseDir
));
this
.
engine
=
new
Cairo
Engine
(
new
DefaultCairoConfiguration
(
cairoBaseDir
));
this
.
httpServer
=
new
HttpServer
(
configuration
);
httpServer
.
bind
(
new
HttpRequestProcessorFactory
()
{
@Override
...
...
core/src/test/java/com/questdb/cutlass/http/MimeTypesCacheTest.java
浏览文件 @
d6dce89e
...
...
@@ -119,13 +119,13 @@ public class MimeTypesCacheTest {
try
(
Path
path
=
new
Path
())
{
String
filePath
;
if
(
Os
.
type
==
Os
.
WINDOWS
)
{
filePath
=
this
.
getClass
().
getResource
(
"/mime
_test
.types"
).
getFile
().
substring
(
1
);
filePath
=
this
.
getClass
().
getResource
(
"/mime.types"
).
getFile
().
substring
(
1
);
}
else
{
filePath
=
this
.
getClass
().
getResource
(
"/mime
_test
.types"
).
getFile
();
filePath
=
this
.
getClass
().
getResource
(
"/mime.types"
).
getFile
();
}
path
.
of
(
filePath
).
$
();
MimeTypesCache
mimeTypes
=
new
MimeTypesCache
(
FilesFacadeImpl
.
INSTANCE
,
path
);
Assert
.
assertEquals
(
6
,
mimeTypes
.
size
());
Assert
.
assertEquals
(
980
,
mimeTypes
.
size
());
TestUtils
.
assertEquals
(
"application/andrew-inset"
,
mimeTypes
.
get
(
"ez"
));
TestUtils
.
assertEquals
(
"application/inkml+xml"
,
mimeTypes
.
get
(
"ink"
));
TestUtils
.
assertEquals
(
"application/inkml+xml"
,
mimeTypes
.
get
(
"inkml"
));
...
...
core/src/test/java/com/questdb/cutlass/line/CairoLineProtoParserTest.java
浏览文件 @
d6dce89e
...
...
@@ -24,7 +24,6 @@
package
com.questdb.cutlass.line
;
import
com.questdb.cairo.*
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.std.*
;
import
com.questdb.std.microtime.DateFormatUtils
;
import
com.questdb.std.microtime.MicrosecondClock
;
...
...
@@ -506,7 +505,7 @@ public class CairoLineProtoParserTest extends AbstractCairoTest {
private
void
assertThat
(
String
expected
,
String
lines
,
CharSequence
tableName
,
CairoConfiguration
configuration
)
throws
Exception
{
TestUtils
.
assertMemoryLeak
(()
->
{
try
(
CairoEngine
engine
=
new
Engine
(
configuration
,
null
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
,
null
))
{
try
(
CairoLineProtoParser
parser
=
new
CairoLineProtoParser
(
engine
))
{
byte
[]
bytes
=
lines
.
getBytes
(
StandardCharsets
.
UTF_8
);
int
len
=
bytes
.
length
;
...
...
core/src/test/java/com/questdb/cutlass/line/udp/LinuxLineProtoReceiverTest.java
浏览文件 @
d6dce89e
...
...
@@ -24,7 +24,6 @@
package
com.questdb.cutlass.line.udp
;
import
com.questdb.cairo.*
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.mp.Job
;
import
com.questdb.mp.SOCountDownLatch
;
import
com.questdb.mp.Worker
;
...
...
@@ -203,7 +202,7 @@ public class LinuxLineProtoReceiverTest extends AbstractCairoTest {
}
private
void
assertConstructorFail
(
LineUdpReceiverConfiguration
receiverCfg
,
ReceiverFactory
factory
)
{
try
(
CairoEngine
engine
=
new
Engine
(
new
DefaultCairoConfiguration
(
root
),
null
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
new
DefaultCairoConfiguration
(
root
),
null
))
{
try
{
factory
.
createReceiver
(
receiverCfg
,
engine
);
Assert
.
fail
();
...
...
@@ -236,7 +235,7 @@ public class LinuxLineProtoReceiverTest extends AbstractCairoTest {
"blue\tsquare\t3.400000000000\t1970-01-01T00:01:40.000000Z\n"
+
"blue\tsquare\t3.400000000000\t1970-01-01T00:01:40.000000Z\n"
;
try
(
CairoEngine
engine
=
new
Engine
(
new
DefaultCairoConfiguration
(
root
),
null
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
new
DefaultCairoConfiguration
(
root
),
null
))
{
Job
receiver
=
factory
.
createReceiver
(
receiverCfg
,
engine
);
...
...
core/src/test/java/com/questdb/cutlass/text/TextLoaderTest.java
浏览文件 @
d6dce89e
...
...
@@ -24,8 +24,8 @@
package com.questdb.cutlass.text;
import com.questdb.cairo.AbstractCairoTest;
import com.questdb.cairo.CairoEngine;
import com.questdb.cairo.CairoException;
import com.questdb.cairo.Engine;
import com.questdb.cairo.TableWriter;
import com.questdb.cairo.sql.RecordCursor;
import com.questdb.cairo.sql.RecordCursorFactory;
...
...
@@ -49,7 +49,7 @@ import java.nio.charset.StandardCharsets;
public class TextLoaderTest extends AbstractCairoTest {
private static final
Engine engine = new
Engine(configuration);
private static final
CairoEngine engine = new Cairo
Engine(configuration);
private static final SqlCompiler compiler = new SqlCompiler(engine);
private static final ByteManipulator ENTITY_MANIPULATOR = (index, len, b) -> b;
...
...
core/src/test/java/com/questdb/griffin/AbstractGriffinTest.java
浏览文件 @
d6dce89e
...
...
@@ -24,8 +24,8 @@
package
com.questdb.griffin
;
import
com.questdb.cairo.AbstractCairoTest
;
import
com.questdb.cairo.CairoEngine
;
import
com.questdb.cairo.ColumnType
;
import
com.questdb.cairo.Engine
;
import
com.questdb.cairo.TableUtils
;
import
com.questdb.cairo.sql.*
;
import
com.questdb.griffin.engine.functions.bind.BindVariableService
;
...
...
@@ -44,7 +44,7 @@ import java.io.IOException;
public
class
AbstractGriffinTest
extends
AbstractCairoTest
{
protected
static
final
BindVariableService
bindVariableService
=
new
BindVariableService
();
private
static
final
LongList
rows
=
new
LongList
();
protected
static
Engine
engine
;
protected
static
Cairo
Engine
engine
;
protected
static
SqlCompiler
compiler
;
protected
static
TestExecutionContext
sqlExecutionContext
;
...
...
@@ -86,7 +86,7 @@ public class AbstractGriffinTest extends AbstractCairoTest {
@BeforeClass
public
static
void
setUp2
()
{
engine
=
new
Engine
(
configuration
);
engine
=
new
Cairo
Engine
(
configuration
);
compiler
=
new
SqlCompiler
(
engine
);
sqlExecutionContext
=
new
TestExecutionContext
(
compiler
.
getCodeGenerator
());
}
...
...
core/src/test/java/com/questdb/griffin/AlterTableAddColumnTest.java
浏览文件 @
d6dce89e
...
...
@@ -151,7 +151,7 @@ public class AlterTableAddColumnTest extends AbstractGriffinTest {
}
};
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
Assert
.
assertNull
(
compiler
.
compile
(
"alter table x add column meh symbol cache"
,
bindVariableService
));
...
...
core/src/test/java/com/questdb/griffin/ExpressionParserTest.java
浏览文件 @
d6dce89e
...
...
@@ -24,14 +24,14 @@
package
com.questdb.griffin
;
import
com.questdb.cairo.AbstractCairoTest
;
import
com.questdb.cairo.Engine
;
import
com.questdb.cairo.
Cairo
Engine
;
import
com.questdb.std.Chars
;
import
com.questdb.test.tools.TestUtils
;
import
org.junit.Assert
;
import
org.junit.Test
;
public
class
ExpressionParserTest
extends
AbstractCairoTest
{
private
final
static
SqlCompiler
compiler
=
new
SqlCompiler
(
new
Engine
(
configuration
));
private
final
static
SqlCompiler
compiler
=
new
SqlCompiler
(
new
Cairo
Engine
(
configuration
));
private
final
static
RpnBuilder
rpnBuilder
=
new
RpnBuilder
();
@Test
...
...
core/src/test/java/com/questdb/griffin/SqlCodeGeneratorTest.java
浏览文件 @
d6dce89e
...
...
@@ -68,7 +68,7 @@ public class SqlCodeGeneratorTest extends AbstractGriffinTest {
};
try
(
Engine
engine
=
new
Engine
(
configuration
);
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
)
)
{
compiler
.
compile
(
"create table y as (x), cast(col as symbol cache)"
,
bindVariableService
);
...
...
@@ -1118,7 +1118,7 @@ public class SqlCodeGeneratorTest extends AbstractGriffinTest {
}
};
try
(
Engine
engine
=
new
Engine
(
configuration
);
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
try
{
compiler
.
compile
((
"create table x as "
+
...
...
core/src/test/java/com/questdb/griffin/SqlCompilerTest.java
浏览文件 @
d6dce89e
...
...
@@ -24,7 +24,6 @@
package
com.questdb.griffin
;
import
com.questdb.cairo.*
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cairo.sql.RecordCursor
;
import
com.questdb.cairo.sql.RecordCursorFactory
;
import
com.questdb.griffin.engine.functions.bind.BindVariableService
;
...
...
@@ -49,7 +48,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import
java.util.concurrent.atomic.AtomicInteger
;
public
class
SqlCompilerTest
extends
AbstractCairoTest
{
private
final
static
Engine
engine
=
new
Engine
(
configuration
);
private
final
static
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
);
private
final
static
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
);
private
final
static
BindVariableService
bindVariableService
=
new
BindVariableService
();
private
final
static
Path
path
=
new
Path
();
...
...
@@ -117,7 +116,7 @@ public class SqlCompilerTest extends AbstractCairoTest {
}
};
CairoEngine
engine
=
new
Engine
(
configuration
);
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
);
try
{
...
...
@@ -1832,7 +1831,7 @@ public class SqlCompilerTest extends AbstractCairoTest {
};
try
(
Engine
engine
=
new
Engine
(
configuration
);
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
)
)
{
try
{
...
...
@@ -1891,7 +1890,7 @@ public class SqlCompilerTest extends AbstractCairoTest {
}
};
try
(
Engine
engine
=
new
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
try
{
compiler
.
compile
(
sql
,
bindVariableService
);
Assert
.
fail
();
...
...
@@ -2242,7 +2241,7 @@ public class SqlCompilerTest extends AbstractCairoTest {
TestUtils
.
assertMemoryLeak
(()
->
{
try
(
Engine
engine
=
new
Engine
(
configuration
);
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
)
)
{
try
{
...
...
@@ -2932,7 +2931,7 @@ public class SqlCompilerTest extends AbstractCairoTest {
};
TestUtils
.
assertMemoryLeak
(()
->
{
try
(
Engine
engine
=
new
Engine
(
configuration
)
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
)
{
@Override
public
TableReader
getReader
(
CharSequence
tableName
,
long
version
)
{
fiddler
.
run
(
this
);
...
...
@@ -3382,7 +3381,7 @@ public class SqlCompilerTest extends AbstractCairoTest {
// create source table
compiler
.
compile
(
"create table X (a int, b int, t timestamp) timestamp(t)"
,
bindVariableService
);
try
(
Engine
engine
=
new
Engine
(
configuration
)
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
)
{
@Override
public
TableReader
getReader
(
CharSequence
tableName
,
long
tableVersion
)
{
fiddler
.
run
(
this
);
...
...
@@ -3428,7 +3427,7 @@ public class SqlCompilerTest extends AbstractCairoTest {
}
};
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
compiler
.
compile
(
"create table x (a INT, b INT)"
,
bindVariableService
);
...
...
core/src/test/java/com/questdb/griffin/SqlParserTest.java
浏览文件 @
d6dce89e
...
...
@@ -24,7 +24,6 @@
package
com.questdb.griffin
;
import
com.questdb.cairo.*
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.griffin.model.ExecutionModel
;
import
com.questdb.griffin.model.QueryModel
;
import
com.questdb.std.*
;
...
...
@@ -4281,7 +4280,7 @@ public class SqlParserTest extends AbstractGriffinTest {
};
try
(
CairoEngine
engine
=
new
Engine
(
configuration
);
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
);
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
)
)
{
assertSyntaxError
(
...
...
core/src/test/java/com/questdb/griffin/WhereClauseParserTest.java
浏览文件 @
d6dce89e
...
...
@@ -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
));
private
final
static
SqlCompiler
compiler
=
new
SqlCompiler
(
new
Cairo
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
浏览文件 @
d6dce89e
...
...
@@ -24,7 +24,7 @@
package
com.questdb.griffin.engine.functions.eq
;
import
com.questdb.cairo.AbstractCairoTest
;
import
com.questdb.cairo.Engine
;
import
com.questdb.cairo.
Cairo
Engine
;
import
com.questdb.cairo.sql.RecordCursor
;
import
com.questdb.cairo.sql.RecordCursorFactory
;
import
com.questdb.griffin.SqlCompiler
;
...
...
@@ -38,7 +38,7 @@ import org.junit.Test;
public
class
EqStrFunctionFactoryTest
extends
AbstractCairoTest
{
private
static
final
BindVariableService
bindVariableService
=
new
BindVariableService
();
private
static
final
Engine
engine
=
new
Engine
(
configuration
);
private
static
final
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
);
private
static
final
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
);
@Before
...
...
core/src/test/java/com/questdb/griffin/engine/functions/rnd/RndBinFunctionFactoryTest.java
浏览文件 @
d6dce89e
...
...
@@ -23,8 +23,7 @@
package
com.questdb.griffin.engine.functions.rnd
;
import
com.questdb.cairo.Engine
;
import
com.questdb.cairo.sql.CairoEngine
;
import
com.questdb.cairo.CairoEngine
;
import
com.questdb.cairo.sql.RecordCursorFactory
;
import
com.questdb.griffin.FunctionFactory
;
import
com.questdb.griffin.SqlCompiler
;
...
...
@@ -39,7 +38,7 @@ import org.junit.Test;
import
java.io.IOException
;
public
class
RndBinFunctionFactoryTest
extends
AbstractFunctionFactoryTest
{
private
static
final
CairoEngine
engine
=
new
Engine
(
configuration
);
private
static
final
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
);
private
static
final
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
);
private
static
final
BindVariableService
bindVariableService
=
new
BindVariableService
();
...
...
core/src/test/java/com/questdb/griffin/engine/groupby/SampleByTest.java
浏览文件 @
d6dce89e
...
...
@@ -24,9 +24,9 @@
package
com.questdb.griffin.engine.groupby
;
import
com.questdb.cairo.CairoConfiguration
;
import
com.questdb.cairo.CairoEngine
;
import
com.questdb.cairo.CairoException
;
import
com.questdb.cairo.DefaultCairoConfiguration
;
import
com.questdb.cairo.Engine
;
import
com.questdb.cairo.sql.RecordCursor
;
import
com.questdb.cairo.sql.RecordCursorFactory
;
import
com.questdb.griffin.AbstractGriffinTest
;
...
...
@@ -246,7 +246,7 @@ public class SampleByTest extends AbstractGriffinTest {
}
};
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
try
{
try
(
RecordCursorFactory
factory
=
compiler
.
compile
(
"select c, sum_t(d) from x"
,
bindVariableService
))
{
...
...
@@ -1135,7 +1135,7 @@ public class SampleByTest extends AbstractGriffinTest {
}
};
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
try
(
SqlCompiler
compiler
=
new
SqlCompiler
(
engine
))
{
try
{
compiler
.
compile
(
"select b, sum(a), k from x sample by 3h fill(linear)"
,
bindVariableService
);
...
...
@@ -1189,7 +1189,7 @@ public class SampleByTest extends AbstractGriffinTest {
}
};
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
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
))
{
...
...
core/src/test/java/com/questdb/griffin/engine/table/DataFrameRecordCursorFactoryTest.java
浏览文件 @
d6dce89e
...
...
@@ -73,7 +73,7 @@ public class DataFrameRecordCursorFactoryTest extends AbstractCairoTest {
writer
.
commit
();
}
try
(
Engine
engine
=
new
Engine
(
configuration
))
{
try
(
CairoEngine
engine
=
new
Cairo
Engine
(
configuration
))
{
String
value
=
symbols
[
N
-
10
];
int
columnIndex
;
int
symbolKey
;
...
...
core/src/test/java/com/questdb/net/http/MimeTypesTest.java
已删除
100644 → 0
浏览文件 @
92536794
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-2018 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,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
package
com.questdb.net.http
;
import
com.questdb.test.tools.TestUtils
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
java.io.File
;
public
class
MimeTypesTest
{
@Test
public
void
testLoading
()
throws
Exception
{
MimeTypes
mimeTypes
=
new
MimeTypes
(
new
File
(
this
.
getClass
().
getResource
(
"/mime_test.types"
).
getFile
()));
Assert
.
assertEquals
(
6
,
mimeTypes
.
size
());
TestUtils
.
assertEquals
(
"application/andrew-inset"
,
mimeTypes
.
get
(
"ez"
));
TestUtils
.
assertEquals
(
"application/inkml+xml"
,
mimeTypes
.
get
(
"ink"
));
TestUtils
.
assertEquals
(
"application/inkml+xml"
,
mimeTypes
.
get
(
"inkml"
));
TestUtils
.
assertEquals
(
"application/mp21"
,
mimeTypes
.
get
(
"m21"
));
TestUtils
.
assertEquals
(
"application/mp21"
,
mimeTypes
.
get
(
"mp21"
));
TestUtils
.
assertEquals
(
"application/mp4"
,
mimeTypes
.
get
(
"mp4s"
));
}
}
\ No newline at end of file
core/src/test/resources/mime.types
0 → 100644
浏览文件 @
d6dce89e
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录