Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
90f9b45f
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,发现更多精彩内容 >>
未验证
提交
90f9b45f
编写于
5月 25, 2020
作者:
T
TheTanc
提交者:
GitHub
5月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
abs(double) implementation + unbranching (#318)
上级
5a9e22f1
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
263 addition
and
3 deletion
+263
-3
core/src/main/java/io/questdb/griffin/engine/functions/math/AbsDoubleFunctionFactory.java
...iffin/engine/functions/math/AbsDoubleFunctionFactory.java
+65
-0
core/src/main/java/io/questdb/griffin/engine/functions/math/AbsIntFunctionFactory.java
.../griffin/engine/functions/math/AbsIntFunctionFactory.java
+2
-1
core/src/main/java/io/questdb/griffin/engine/functions/math/AbsLongFunctionFactory.java
...griffin/engine/functions/math/AbsLongFunctionFactory.java
+1
-1
core/src/main/java/io/questdb/griffin/engine/functions/math/AbsShortFunctionFactory.java
...riffin/engine/functions/math/AbsShortFunctionFactory.java
+1
-1
core/src/main/java/module-info.java
core/src/main/java/module-info.java
+1
-0
core/src/test/java/io/questdb/griffin/engine/functions/math/AbsDoubleFunctionFactoryTest.java
...n/engine/functions/math/AbsDoubleFunctionFactoryTest.java
+47
-0
core/src/test/java/io/questdb/griffin/engine/functions/math/AbsIntFunctionFactoryTest.java
...ffin/engine/functions/math/AbsIntFunctionFactoryTest.java
+49
-0
core/src/test/java/io/questdb/griffin/engine/functions/math/AbsLongFunctionFactoryTest.java
...fin/engine/functions/math/AbsLongFunctionFactoryTest.java
+48
-0
core/src/test/java/io/questdb/griffin/engine/functions/math/AbsShortFunctionFactoryTest.java
...in/engine/functions/math/AbsShortFunctionFactoryTest.java
+47
-0
core/src/test/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/math/AbsDoubleFunctionFactory.java
0 → 100644
浏览文件 @
90f9b45f
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (c) 2014-2019 Appsicle
* Copyright (c) 2019-2020 QuestDB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
package
io.questdb.griffin.engine.functions.math
;
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.DoubleFunction
;
import
io.questdb.griffin.engine.functions.UnaryFunction
;
import
io.questdb.std.ObjList
;
public
class
AbsDoubleFunctionFactory
implements
FunctionFactory
{
@Override
public
String
getSignature
()
{
return
"abs(D)"
;
}
@Override
public
Function
newInstance
(
ObjList
<
Function
>
args
,
int
position
,
CairoConfiguration
configuration
)
{
return
new
AbsFunction
(
position
,
args
.
getQuick
(
0
));
}
private
static
class
AbsFunction
extends
DoubleFunction
implements
UnaryFunction
{
final
Function
function
;
public
AbsFunction
(
int
position
,
Function
function
)
{
super
(
position
);
this
.
function
=
function
;
}
@Override
public
Function
getArg
()
{
return
function
;
}
@Override
public
double
getDouble
(
Record
rec
)
{
double
value
=
function
.
getDouble
(
rec
);
return
Math
.
abs
(
value
);
}
}
}
core/src/main/java/io/questdb/griffin/engine/functions/math/AbsIntFunctionFactory.java
浏览文件 @
90f9b45f
...
...
@@ -60,10 +60,11 @@ public class AbsIntFunctionFactory implements FunctionFactory {
return
arg
;
}
@Override
public
int
getInt
(
Record
rec
)
{
int
value
=
arg
.
getInt
(
rec
);
return
value
<
0
?
-
value
:
value
;
return
Math
.
abs
(
value
)
;
}
}
}
core/src/main/java/io/questdb/griffin/engine/functions/math/AbsLongFunctionFactory.java
浏览文件 @
90f9b45f
...
...
@@ -50,7 +50,7 @@ public class AbsLongFunctionFactory implements FunctionFactory {
@Override
public
long
getLong
(
Record
rec
)
{
long
value
=
arg
.
getLong
(
rec
);
return
value
<
0
?
-
value
:
value
;
return
Math
.
abs
(
value
)
;
}
}
}
core/src/main/java/io/questdb/griffin/engine/functions/math/AbsShortFunctionFactory.java
浏览文件 @
90f9b45f
...
...
@@ -59,7 +59,7 @@ public class AbsShortFunctionFactory implements FunctionFactory {
@Override
public
short
getShort
(
Record
rec
)
{
short
value
=
function
.
getShort
(
rec
);
return
value
<
0
?
(
short
)
-
value
:
value
;
return
(
short
)
Math
.
abs
(
value
)
;
}
}
}
core/src/main/java/module-info.java
浏览文件 @
90f9b45f
...
...
@@ -131,6 +131,7 @@ open module io.questdb {
io
.
questdb
.
griffin
.
engine
.
functions
.
math
.
AbsIntFunctionFactory
,
io
.
questdb
.
griffin
.
engine
.
functions
.
math
.
AbsShortFunctionFactory
,
io
.
questdb
.
griffin
.
engine
.
functions
.
math
.
AbsLongFunctionFactory
,
io
.
questdb
.
griffin
.
engine
.
functions
.
math
.
AbsDoubleFunctionFactory
,
// # '~=',
io
.
questdb
.
griffin
.
engine
.
functions
.
regex
.
MatchStrFunctionFactory
,
io
.
questdb
.
griffin
.
engine
.
functions
.
regex
.
MatchCharFunctionFactory
,
...
...
core/src/test/java/io/questdb/griffin/engine/functions/math/AbsDoubleFunctionFactoryTest.java
0 → 100644
浏览文件 @
90f9b45f
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (c) 2014-2019 Appsicle
* Copyright (c) 2019-2020 QuestDB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
package
io.questdb.griffin.engine.functions.math
;
import
io.questdb.griffin.FunctionFactory
;
import
io.questdb.griffin.SqlException
;
import
io.questdb.griffin.engine.AbstractFunctionFactoryTest
;
import
org.junit.Test
;
public
class
AbsDoubleFunctionFactoryTest
extends
AbstractFunctionFactoryTest
{
@Test
public
void
testPositive
()
throws
SqlException
{
call
(
13.1
).
andAssert
(
13.1
,
0.0000000001
);
}
@Test
public
void
testNegative
()
throws
SqlException
{
call
(-
13.1
).
andAssert
(
13.1
,
0.0000000001
);
}
@Override
protected
FunctionFactory
getFunctionFactory
()
{
return
new
AbsDoubleFunctionFactory
();
}
}
\ No newline at end of file
core/src/test/java/io/questdb/griffin/engine/functions/math/AbsIntFunctionFactoryTest.java
0 → 100644
浏览文件 @
90f9b45f
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (c) 2014-2019 Appsicle
* Copyright (c) 2019-2020 QuestDB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
package
io.questdb.griffin.engine.functions.math
;
import
io.questdb.griffin.FunctionFactory
;
import
io.questdb.griffin.SqlException
;
import
io.questdb.griffin.engine.AbstractFunctionFactoryTest
;
import
io.questdb.std.Numbers
;
import
org.junit.Test
;
public
class
AbsIntFunctionFactoryTest
extends
AbstractFunctionFactoryTest
{
@Test
public
void
testPositive
()
throws
SqlException
{
call
(
1
).
andAssert
(
1
,
0.0000000001
);
}
@Test
public
void
testNegative
()
throws
SqlException
{
call
(-
1
).
andAssert
(
1
,
0.0000000001
);
}
@Override
protected
FunctionFactory
getFunctionFactory
()
{
return
new
AbsIntFunctionFactory
();
}
}
\ No newline at end of file
core/src/test/java/io/questdb/griffin/engine/functions/math/AbsLongFunctionFactoryTest.java
0 → 100644
浏览文件 @
90f9b45f
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (c) 2014-2019 Appsicle
* Copyright (c) 2019-2020 QuestDB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
package
io.questdb.griffin.engine.functions.math
;
import
io.questdb.griffin.FunctionFactory
;
import
io.questdb.griffin.SqlException
;
import
io.questdb.griffin.engine.AbstractFunctionFactoryTest
;
import
org.junit.Test
;
public
class
AbsLongFunctionFactoryTest
extends
AbstractFunctionFactoryTest
{
@Test
public
void
testPositive
()
throws
SqlException
{
call
(
1L
).
andAssert
(
1
,
0.0000000001
);
}
@Test
public
void
testNegative
()
throws
SqlException
{
call
(-
1L
).
andAssert
(
1
,
0.0000000001
);
}
@Override
protected
FunctionFactory
getFunctionFactory
()
{
return
new
AbsLongFunctionFactory
();
}
}
\ No newline at end of file
core/src/test/java/io/questdb/griffin/engine/functions/math/AbsShortFunctionFactoryTest.java
0 → 100644
浏览文件 @
90f9b45f
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (c) 2014-2019 Appsicle
* Copyright (c) 2019-2020 QuestDB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
package
io.questdb.griffin.engine.functions.math
;
import
io.questdb.griffin.FunctionFactory
;
import
io.questdb.griffin.SqlException
;
import
io.questdb.griffin.engine.AbstractFunctionFactoryTest
;
import
org.junit.Test
;
public
class
AbsShortFunctionFactoryTest
extends
AbstractFunctionFactoryTest
{
@Test
public
void
testPositive
()
throws
SqlException
{
call
(
1
).
andAssert
(
1
,
0.0000000001
);
}
@Test
public
void
testNegative
()
throws
SqlException
{
call
(-
1
).
andAssert
(
1
,
0.0000000001
);
}
@Override
protected
FunctionFactory
getFunctionFactory
()
{
return
new
AbsShortFunctionFactory
();
}
}
\ No newline at end of file
core/src/test/resources/META-INF/services/io.questdb.griffin.FunctionFactory
浏览文件 @
90f9b45f
...
...
@@ -128,9 +128,11 @@ io.questdb.griffin.engine.functions.math.MulDoubleFunctionFactory
io.questdb.griffin.engine.functions.math.MulLongFunctionFactory
io.questdb.griffin.engine.functions.math.MulIntFunctionFactory
# 'abs'
io.questdb.griffin.engine.functions.math.AbsIntFunctionFactory
io.questdb.griffin.engine.functions.math.AbsShortFunctionFactory
io.questdb.griffin.engine.functions.math.AbsLongFunctionFactory
io.questdb.griffin.engine.functions.math.AbsDoubleFunctionFactory
# '~='
io.questdb.griffin.engine.functions.regex.MatchStrFunctionFactory
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录