Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
655be6c2
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,发现更多精彩内容 >>
提交
655be6c2
编写于
10月 25, 2019
作者:
V
Vlad Ilyushchenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GRIFFIN: str = char implementation
上级
612bf4d9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
288 addition
and
0 deletion
+288
-0
core/src/main/java/io/questdb/griffin/engine/functions/eq/EqStrCharFunctionFactory.java
...griffin/engine/functions/eq/EqStrCharFunctionFactory.java
+137
-0
core/src/main/java/io/questdb/griffin/engine/functions/eq/EqSymStrFunctionFactory.java
.../griffin/engine/functions/eq/EqSymStrFunctionFactory.java
+149
-0
core/src/main/resources/META-INF/services/io.questdb.griffin.FunctionFactory
...rces/META-INF/services/io.questdb.griffin.FunctionFactory
+2
-0
未找到文件。
core/src/main/java/io/questdb/griffin/engine/functions/eq/EqStrCharFunctionFactory.java
0 → 100644
浏览文件 @
655be6c2
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* 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
io.questdb.griffin.engine.functions.eq
;
import
io.questdb.cairo.CairoConfiguration
;
import
io.questdb.cairo.sql.Function
;
import
io.questdb.cairo.sql.Record
;
import
io.questdb.griffin.FunctionFactory
;
import
io.questdb.griffin.engine.functions.BinaryFunction
;
import
io.questdb.griffin.engine.functions.BooleanFunction
;
import
io.questdb.griffin.engine.functions.UnaryFunction
;
import
io.questdb.std.ObjList
;
public
class
EqStrCharFunctionFactory
implements
FunctionFactory
{
@Override
public
String
getSignature
()
{
return
"=(SA)"
;
}
@Override
public
Function
newInstance
(
ObjList
<
Function
>
args
,
int
position
,
CairoConfiguration
configuration
)
{
// there are optimisation opportunities
// 1. when one of args is constant null comparison can boil down to checking
// length of non-constant (must be -1)
// 2. when one of arguments is constant, save method call and use a field
Function
a
=
args
.
getQuick
(
0
);
Function
b
=
args
.
getQuick
(
1
);
if
(
a
.
isConstant
()
&&
!
b
.
isConstant
())
{
return
createHalfConstantFunc
(
position
,
a
,
b
);
}
if
(!
a
.
isConstant
()
&&
b
.
isConstant
())
{
return
createHalfConstantFunc
(
position
,
b
,
a
);
}
return
new
Func
(
position
,
a
,
b
);
}
private
Function
createHalfConstantFunc
(
int
position
,
Function
constFunc
,
Function
varFunc
)
{
return
new
ConstCheckFunc
(
position
,
varFunc
,
constFunc
.
getChar
(
null
));
}
private
static
class
ConstCheckFunc
extends
BooleanFunction
implements
UnaryFunction
{
private
final
Function
arg
;
private
final
char
constant
;
public
ConstCheckFunc
(
int
position
,
Function
arg
,
char
constant
)
{
super
(
position
);
this
.
arg
=
arg
;
this
.
constant
=
constant
;
}
@Override
public
Function
getArg
()
{
return
arg
;
}
@Override
public
boolean
getBool
(
Record
rec
)
{
CharSequence
value
=
arg
.
getStr
(
rec
);
if
(
value
==
null
)
{
return
false
;
}
final
int
len
=
value
.
length
();
if
(
len
==
0
)
{
return
false
;
}
return
value
.
charAt
(
0
)
==
constant
;
}
}
private
static
class
Func
extends
BooleanFunction
implements
BinaryFunction
{
private
final
Function
left
;
private
final
Function
right
;
public
Func
(
int
position
,
Function
left
,
Function
right
)
{
super
(
position
);
this
.
left
=
left
;
this
.
right
=
right
;
}
@Override
public
Function
getLeft
()
{
return
left
;
}
@Override
public
Function
getRight
()
{
return
right
;
}
@Override
public
boolean
getBool
(
Record
rec
)
{
// important to compare A and B strings in case
// these are columns of the same record
// records have re-usable character sequences
final
CharSequence
a
=
left
.
getStr
(
rec
);
final
char
b
=
right
.
getChar
(
rec
);
if
(
a
==
null
)
{
return
false
;
}
int
len
=
a
.
length
();
if
(
len
==
0
)
{
return
false
;
}
return
a
.
charAt
(
0
)
==
b
;
}
}
}
core/src/main/java/io/questdb/griffin/engine/functions/eq/EqSymStrFunctionFactory.java
0 → 100644
浏览文件 @
655be6c2
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* 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
io.questdb.griffin.engine.functions.eq
;
import
io.questdb.cairo.CairoConfiguration
;
import
io.questdb.cairo.sql.Function
;
import
io.questdb.cairo.sql.Record
;
import
io.questdb.griffin.FunctionFactory
;
import
io.questdb.griffin.engine.functions.BinaryFunction
;
import
io.questdb.griffin.engine.functions.BooleanFunction
;
import
io.questdb.griffin.engine.functions.UnaryFunction
;
import
io.questdb.std.Chars
;
import
io.questdb.std.ObjList
;
public
class
EqSymStrFunctionFactory
implements
FunctionFactory
{
@Override
public
String
getSignature
()
{
return
"=(KS)"
;
}
@Override
public
Function
newInstance
(
ObjList
<
Function
>
args
,
int
position
,
CairoConfiguration
configuration
)
{
// there are optimisation opportunities
// 1. when one of args is constant null comparison can boil down to checking
// length of non-constant (must be -1)
// 2. when one of arguments is constant, save method call and use a field
Function
a
=
args
.
getQuick
(
0
);
Function
b
=
args
.
getQuick
(
1
);
if
(
a
.
isConstant
()
&&
!
b
.
isConstant
())
{
return
createHalfConstantFunc
(
position
,
a
,
b
);
}
if
(!
a
.
isConstant
()
&&
b
.
isConstant
())
{
return
createHalfConstantFunc
(
position
,
b
,
a
);
}
return
new
Func
(
position
,
a
,
b
);
}
private
Function
createHalfConstantFunc
(
int
position
,
Function
constFunc
,
Function
varFunc
)
{
CharSequence
constValue
=
constFunc
.
getStr
(
null
);
if
(
constValue
==
null
)
{
return
new
NullCheckFunc
(
position
,
varFunc
);
}
return
new
ConstCheckFunc
(
position
,
varFunc
,
constValue
);
}
private
static
class
NullCheckFunc
extends
BooleanFunction
implements
UnaryFunction
{
private
final
Function
arg
;
public
NullCheckFunc
(
int
position
,
Function
arg
)
{
super
(
position
);
this
.
arg
=
arg
;
}
@Override
public
Function
getArg
()
{
return
arg
;
}
@Override
public
boolean
getBool
(
Record
rec
)
{
return
arg
.
getSymbol
(
rec
)
==
null
;
}
}
private
static
class
ConstCheckFunc
extends
BooleanFunction
implements
UnaryFunction
{
private
final
Function
arg
;
private
final
CharSequence
constant
;
public
ConstCheckFunc
(
int
position
,
Function
arg
,
CharSequence
constant
)
{
super
(
position
);
this
.
arg
=
arg
;
this
.
constant
=
constant
;
}
@Override
public
Function
getArg
()
{
return
arg
;
}
@Override
public
boolean
getBool
(
Record
rec
)
{
return
Chars
.
equalsNc
(
constant
,
arg
.
getSymbol
(
rec
));
}
}
private
static
class
Func
extends
BooleanFunction
implements
BinaryFunction
{
private
final
Function
left
;
private
final
Function
right
;
public
Func
(
int
position
,
Function
left
,
Function
right
)
{
super
(
position
);
this
.
left
=
left
;
this
.
right
=
right
;
}
@Override
public
Function
getLeft
()
{
return
left
;
}
@Override
public
Function
getRight
()
{
return
right
;
}
@Override
public
boolean
getBool
(
Record
rec
)
{
// important to compare A and B strings in case
// these are columns of the same record
// records have re-usable character sequences
final
CharSequence
a
=
left
.
getSymbol
(
rec
);
final
CharSequence
b
=
right
.
getStr
(
rec
);
if
(
a
==
null
)
{
return
b
==
null
;
}
return
b
!=
null
&&
Chars
.
equals
(
a
,
b
);
}
}
}
core/src/main/resources/META-INF/services/io.questdb.griffin.FunctionFactory
浏览文件 @
655be6c2
...
...
@@ -21,6 +21,7 @@
#
################################################################################
################################################################################
# ___ _ ____ ____
# / _ \ _ _ ___ ___| |_| _ \| __ )
...
...
@@ -55,6 +56,7 @@ io.questdb.griffin.engine.functions.eq.EqLongFunctionFactory
io.questdb.griffin.engine.functions.eq.EqDoubleFunctionFactory
io.questdb.griffin.engine.functions.eq.EqLong256StrFunctionFactory
io.questdb.griffin.engine.functions.eq.EqLong256FunctionFactory
io.questdb.griffin.engine.functions.eq.EqStrCharFunctionFactory
# '<>'
io.questdb.griffin.engine.functions.eq.NotEqStrFunctionFactory
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录