Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
3999a1f1
Q
Questdb
项目概览
jobily
/
Questdb
12 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
Questdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3999a1f1
编写于
5月 03, 2016
作者:
V
Vlad Ilyushchenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid scroll bugfix, count() query optimisation, more to follow
上级
86c07607
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
253 addition
and
18 deletion
+253
-18
core/src/main/java/com/questdb/ql/impl/aggregation/CountRecordSource.java
...va/com/questdb/ql/impl/aggregation/CountRecordSource.java
+226
-0
core/src/main/java/com/questdb/ql/parser/QueryCompiler.java
core/src/main/java/com/questdb/ql/parser/QueryCompiler.java
+24
-15
core/src/main/resources/site/public/scripts/qdb.js
core/src/main/resources/site/public/scripts/qdb.js
+1
-1
ui/app/scripts/grid.js
ui/app/scripts/grid.js
+2
-2
未找到文件。
core/src/main/java/com/questdb/ql/impl/aggregation/CountRecordSource.java
0 → 100644
浏览文件 @
3999a1f1
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-2016 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/>.
*
* As a special exception, the copyright holders give permission to link the
* code of portions of this program with the OpenSSL library under certain
* conditions as described in each individual source file and distribute
* linked combinations including the program with the OpenSSL library. You
* must comply with the GNU Affero General Public License in all respects for
* all of the code used other than as permitted herein. If you modify file(s)
* with this exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do so,
* delete this exception statement from your version. If you delete this
* exception statement from all source files in the program, then also delete
* it in the license file.
*
******************************************************************************/
package
com.questdb.ql.impl.aggregation
;
import
com.questdb.ex.JournalException
;
import
com.questdb.factory.JournalReaderFactory
;
import
com.questdb.factory.configuration.ColumnMetadata
;
import
com.questdb.factory.configuration.RecordMetadata
;
import
com.questdb.io.sink.CharSink
;
import
com.questdb.ql.*
;
import
com.questdb.ql.impl.CollectionRecordMetadata
;
import
com.questdb.ql.ops.AbstractCombinedRecordSource
;
import
com.questdb.std.DirectInputStream
;
import
com.questdb.store.ColumnType
;
import
java.io.OutputStream
;
public
class
CountRecordSource
extends
AbstractCombinedRecordSource
{
private
final
CountRecord
record
;
private
final
PartitionSource
partitionSource
;
private
PartitionCursor
partitionCursor
;
private
boolean
done
=
false
;
public
CountRecordSource
(
String
columnName
,
PartitionSource
partitionSource
)
{
CollectionRecordMetadata
metadata
=
new
CollectionRecordMetadata
();
ColumnMetadata
m
=
new
ColumnMetadata
();
m
.
name
=
columnName
;
m
.
type
=
ColumnType
.
LONG
;
metadata
.
add
(
m
);
this
.
record
=
new
CountRecord
(
metadata
);
this
.
partitionSource
=
partitionSource
;
}
@Override
public
Record
getByRowId
(
long
rowId
)
{
return
null
;
}
@Override
public
StorageFacade
getStorageFacade
()
{
return
null
;
}
@Override
public
RecordMetadata
getMetadata
()
{
return
record
.
getMetadata
();
}
@Override
public
RecordCursor
prepareCursor
(
JournalReaderFactory
factory
)
throws
JournalException
{
partitionCursor
=
partitionSource
.
prepareCursor
(
factory
);
computeCount
();
return
this
;
}
@Override
public
void
reset
()
{
if
(
partitionCursor
!=
null
)
{
partitionCursor
.
reset
();
}
done
=
false
;
}
@Override
public
boolean
supportsRowIdAccess
()
{
return
false
;
}
@SuppressWarnings
(
"ConstantConditions"
)
@Override
public
boolean
hasNext
()
{
return
!
done
&&
(
done
=
true
);
}
@Override
public
Record
next
()
{
return
record
;
}
private
void
computeCount
()
{
long
count
=
0
;
while
(
partitionCursor
.
hasNext
())
{
PartitionSlice
slice
=
partitionCursor
.
next
();
long
hi
;
if
(
slice
.
calcHi
)
{
hi
=
slice
.
partition
.
size
();
}
else
{
hi
=
slice
.
hi
;
}
count
+=
(
hi
-
slice
.
lo
);
}
record
.
count
=
count
;
}
private
static
class
CountRecord
extends
AbstractRecord
{
private
long
count
;
public
CountRecord
(
RecordMetadata
metadata
)
{
super
(
metadata
);
}
@Override
public
byte
get
(
int
col
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
getBin
(
int
col
,
OutputStream
s
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
DirectInputStream
getBin
(
int
col
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
long
getBinLen
(
int
col
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
boolean
getBool
(
int
col
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
long
getDate
(
int
col
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
double
getDouble
(
int
col
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
float
getFloat
(
int
col
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
CharSequence
getFlyweightStr
(
int
col
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
CharSequence
getFlyweightStrB
(
int
col
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
int
getInt
(
int
col
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
long
getLong
(
int
col
)
{
return
count
;
}
@Override
public
long
getRowId
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
short
getShort
(
int
col
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
CharSequence
getStr
(
int
col
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
getStr
(
int
col
,
CharSink
sink
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
int
getStrLen
(
int
col
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
String
getSym
(
int
col
)
{
throw
new
UnsupportedOperationException
();
}
}
}
core/src/main/java/com/questdb/ql/parser/QueryCompiler.java
浏览文件 @
3999a1f1
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
<p>
*
___ _ ____ ____
*
/ _ \ _ _ ___ ___| |_| _ \| __ )
*
| | | | | | |/ _ \/ __| __| | | | _ \
*
| |_| | |_| | __/\__ \ |_| |_| | |_) |
*
\__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (C) 2014-2016 Appsicle
*
<p>
*
* 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.
*
<p>
*
* 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.
*
<p>
*
* 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/>.
*
<p>
*
* As a special exception, the copyright holders give permission to link the
* code of portions of this program with the OpenSSL library under certain
* conditions as described in each individual source file and distribute
...
...
@@ -30,6 +30,7 @@
* delete this exception statement from your version. If you delete this
* exception statement from all source files in the program, then also delete
* it in the license file.
*
******************************************************************************/
package
com.questdb.ql.parser
;
...
...
@@ -50,10 +51,7 @@ import com.questdb.misc.Numbers;
import
com.questdb.misc.Unsafe
;
import
com.questdb.ql.*
;
import
com.questdb.ql.impl.*
;
import
com.questdb.ql.impl.aggregation.AggregatedRecordSource
;
import
com.questdb.ql.impl.aggregation.ResampledRecordSource
;
import
com.questdb.ql.impl.aggregation.SamplerFactory
;
import
com.questdb.ql.impl.aggregation.TimestampSampler
;
import
com.questdb.ql.impl.aggregation.*
;
import
com.questdb.ql.impl.interval.IntervalJournalRecordSource
;
import
com.questdb.ql.impl.interval.MultiIntervalPartitionSource
;
import
com.questdb.ql.impl.interval.SingleIntervalSource
;
...
...
@@ -565,7 +563,7 @@ public class QueryCompiler {
selectColumns
(
model
.
getJoinModels
().
size
()
>
1
?
optimise
(
model
,
factory
).
compileJoins
(
model
,
factory
)
:
optimise
(
model
,
factory
).
compileSingleOrSubQuery
(
model
,
factory
),
compileSingleOrSubQuery
(
model
,
factory
),
model
),
model
),
model
...
...
@@ -809,6 +807,17 @@ public class QueryCompiler {
}
}
// check for case of simple "select count() from tab"
if
(
rs
==
null
&&
model
.
getColumns
().
size
()
==
1
)
{
QueryColumn
qc
=
model
.
getColumns
().
getQuick
(
0
);
if
(
"count"
.
equals
(
qc
.
getAst
().
token
)
&&
qc
.
getAst
().
paramCount
==
0
)
{
// remove order clause
model
.
getOrderBy
().
clear
();
// remove columns so that there is no wrapping of result source
model
.
getColumns
().
clear
();
return
new
CountRecordSource
(
qc
.
getAlias
()
==
null
?
"count"
:
qc
.
getAlias
(),
ps
);
}
}
return
new
JournalSource
(
ps
,
rs
==
null
?
new
AllRowSource
()
:
rs
);
}
...
...
core/src/main/resources/site/public/scripts/qdb.js
浏览文件 @
3999a1f1
此差异已折叠。
点击以展开。
ui/app/scripts/grid.js
浏览文件 @
3999a1f1
...
...
@@ -484,8 +484,8 @@
}
function
activeRowDown
(
n
)
{
if
(
activeRow
>
-
1
&&
activeRow
<
r
)
{
activeRow
=
Math
.
min
(
r
,
activeRow
+
n
);
if
(
activeRow
>
-
1
&&
activeRow
<
r
-
1
)
{
activeRow
=
Math
.
min
(
r
-
1
,
activeRow
+
n
);
activeRowContainer
.
className
=
'
qg-r
'
;
activeCellOff
();
activeRowContainer
=
rows
[
activeRow
&
dcn
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录