Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
096fb9fe
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,发现更多精彩内容 >>
提交
096fb9fe
编写于
2月 16, 2020
作者:
V
Vlad Ilyushchenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(griffin): thorough testing of "asof" join and fixes for edge cases.
上级
03d2d2dd
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
405 addition
and
30 deletion
+405
-30
core/src/main/java/io/questdb/griffin/engine/join/AsOfJoinNoKeyRecordCursorFactory.java
...griffin/engine/join/AsOfJoinNoKeyRecordCursorFactory.java
+67
-29
core/src/test/java/io/questdb/griffin/JoinTest.java
core/src/test/java/io/questdb/griffin/JoinTest.java
+338
-1
未找到文件。
core/src/main/java/io/questdb/griffin/engine/join/AsOfJoinNoKeyRecordCursorFactory.java
浏览文件 @
096fb9fe
...
...
@@ -81,9 +81,10 @@ public class AsOfJoinNoKeyRecordCursorFactory extends AbstractRecordCursorFactor
private
RecordCursor
masterCursor
;
private
RecordCursor
slaveCursor
;
private
Record
masterRecord
;
private
Record
slaveRecord
;
private
Record
slaveRecB
;
private
Record
slaveRecA
;
private
long
slaveTimestamp
=
Long
.
MIN_VALUE
;
private
long
lastSlaveRowID
=
Long
.
MIN_VALUE
;
private
long
la
te
stSlaveRowID
=
Long
.
MIN_VALUE
;
public
AsOfLightJoinRecordCursor
(
int
columnSplit
,
...
...
@@ -116,46 +117,81 @@ public class AsOfJoinNoKeyRecordCursorFactory extends AbstractRecordCursorFactor
return
slaveCursor
.
getSymbolTable
(
columnIndex
-
columnSplit
);
}
@Override
public
boolean
hasNext
()
{
final
long
prevSlaveRowID
=
lastSlaveRowID
;
long
lastRowId
=
lastSlaveRowID
;
if
(
masterCursor
.
hasNext
())
{
// great, we have a record no matter what
final
long
masterTimestamp
=
masterRecord
.
getTimestamp
(
masterTimestampIndex
);
long
slaveTimestamp
=
this
.
slaveTimestamp
;
if
(
slaveTimestamp
<=
masterTimestamp
)
{
final
Record
rec
=
slaveCursor
.
getRecord
();
while
(
slaveCursor
.
hasNext
())
{
slaveTimestamp
=
rec
.
getTimestamp
(
slaveTimestampIndex
);
if
(
slaveTimestamp
>
masterTimestamp
)
{
break
;
}
lastRowId
=
rec
.
getRowId
();
}
// now we have dangling slave record, which we need to hold on to
if
(
masterTimestamp
<
slaveTimestamp
)
{
return
true
;
}
nextSlave
(
masterTimestamp
);
return
true
;
}
return
false
;
}
private
void
nextSlave
(
long
masterTimestamp
)
{
if
(
slaveCursor
.
hasNext
())
{
// check where this record falls
long
slaveTimestamp
=
slaveRecA
.
getTimestamp
(
slaveTimestampIndex
);
if
(
slaveTimestamp
>
masterTimestamp
)
{
positionSlaveRecB
();
latestSlaveRowID
=
slaveRecA
.
getRowId
();
this
.
slaveTimestamp
=
slaveTimestamp
;
this
.
lastSlaveRowID
=
lastRowId
;
}
else
{
overScrollSlave
(
masterTimestamp
,
slaveTimestamp
);
}
}
else
{
slaveIsDone
();
}
}
private
void
positionSlaveRecB
()
{
if
(
this
.
latestSlaveRowID
!=
Long
.
MIN_VALUE
)
{
record
.
hasSlave
(
true
);
slaveCursor
.
recordAt
(
slaveRecB
,
latestSlaveRowID
);
}
}
private
void
slaveIsDone
()
{
positionSlaveRecB
();
this
.
slaveTimestamp
=
Long
.
MAX_VALUE
;
}
if
(
lastRowId
==
Long
.
MIN_VALUE
)
{
record
.
hasSlave
(
false
);
private
void
overScrollSlave
(
long
masterTimestamp
,
long
slaveTimestamp
)
{
latestSlaveRowID
=
slaveRecA
.
getRowId
();
this
.
slaveTimestamp
=
slaveTimestamp
;
// scroll slave down
while
(
true
)
{
if
(
slaveCursor
.
hasNext
())
{
slaveTimestamp
=
slaveRecA
.
getTimestamp
(
slaveTimestampIndex
);
if
(
slaveTimestamp
>
masterTimestamp
)
{
record
.
hasSlave
(
true
);
slaveCursor
.
recordAt
(
slaveRecB
,
latestSlaveRowID
);
latestSlaveRowID
=
slaveRecA
.
getRowId
();
this
.
slaveTimestamp
=
slaveTimestamp
;
break
;
}
else
{
latestSlaveRowID
=
slaveRecA
.
getRowId
();
this
.
slaveTimestamp
=
slaveTimestamp
;
}
}
else
{
record
.
hasSlave
(
true
);
// positioning
if
(
prevSlaveRowID
!=
lastSlaveRowID
)
{
slaveCursor
.
recordAt
(
slaveRecord
,
lastSlaveRowID
);
}
slaveCursor
.
recordAt
(
slaveRecB
,
latestSlaveRowID
);
this
.
slaveTimestamp
=
Long
.
MAX_VALUE
;
break
;
}
return
true
;
}
return
false
;
}
@Override
public
void
toTop
()
{
slaveTimestamp
=
Long
.
MIN_VALUE
;
lastSlaveRowID
=
Long
.
MIN_VALUE
;
latestSlaveRowID
=
Long
.
MIN_VALUE
;
record
.
hasSlave
(
false
);
masterCursor
.
toTop
();
slaveCursor
.
toTop
();
}
...
...
@@ -167,12 +203,14 @@ public class AsOfJoinNoKeyRecordCursorFactory extends AbstractRecordCursorFactor
private
void
of
(
RecordCursor
masterCursor
,
RecordCursor
slaveCursor
)
{
slaveTimestamp
=
Long
.
MIN_VALUE
;
lastSlaveRowID
=
Long
.
MIN_VALUE
;
la
te
stSlaveRowID
=
Long
.
MIN_VALUE
;
this
.
masterCursor
=
masterCursor
;
this
.
slaveCursor
=
slaveCursor
;
this
.
masterRecord
=
masterCursor
.
getRecord
();
this
.
slaveRecord
=
slaveCursor
.
getRecordB
();
record
.
of
(
masterRecord
,
slaveRecord
);
this
.
slaveRecA
=
slaveCursor
.
getRecord
();
this
.
slaveRecB
=
slaveCursor
.
getRecordB
();
record
.
of
(
masterRecord
,
slaveRecB
);
record
.
hasSlave
(
false
);
}
}
}
core/src/test/java/io/questdb/griffin/JoinTest.java
浏览文件 @
096fb9fe
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录