Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
oceanbase
miniob
提交
b955826f
M
miniob
项目概览
oceanbase
/
miniob
1 年多 前同步成功
通知
74
Star
1521
Fork
537
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
M
miniob
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
提交
b955826f
编写于
1月 28, 2023
作者:
L
Longda Feng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move observer's utility to common directory
上级
72505bdd
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
49 addition
and
63 deletion
+49
-63
deps/common/lang/comparator.cpp
deps/common/lang/comparator.cpp
+5
-0
deps/common/lang/comparator.h
deps/common/lang/comparator.h
+5
-0
deps/common/lang/string.cpp
deps/common/lang/string.cpp
+19
-0
deps/common/lang/string.h
deps/common/lang/string.h
+7
-0
src/observer/sql/expr/tuple_cell.cpp
src/observer/sql/expr/tuple_cell.cpp
+9
-9
src/observer/storage/index/bplus_tree.h
src/observer/storage/index/bplus_tree.h
+4
-4
src/observer/util/util.cpp
src/observer/util/util.cpp
+0
-31
src/observer/util/util.h
src/observer/util/util.h
+0
-19
未找到文件。
src/observer/util
/comparator.cpp
→
deps/common/lang
/comparator.cpp
浏览文件 @
b955826f
...
...
@@ -16,6 +16,9 @@ See the Mulan PSL v2 for more details. */
#include <algorithm>
#include "common/defs.h"
namespace
common
{
int
compare_int
(
void
*
arg1
,
void
*
arg2
)
{
int
v1
=
*
(
int
*
)
arg1
;
...
...
@@ -56,3 +59,5 @@ int compare_string(void *arg1, int arg1_max_length, void *arg2, int arg2_max_len
}
return
0
;
}
}
\ No newline at end of file
src/observer/util
/comparator.h
→
deps/common/lang
/comparator.h
浏览文件 @
b955826f
...
...
@@ -14,6 +14,11 @@ See the Mulan PSL v2 for more details. */
#pragma once
namespace
common
{
int
compare_int
(
void
*
arg1
,
void
*
arg2
);
int
compare_float
(
void
*
arg1
,
void
*
arg2
);
int
compare_string
(
void
*
arg1
,
int
arg1_max_length
,
void
*
arg2
,
int
arg2_max_length
);
}
\ No newline at end of file
deps/common/lang/string.cpp
浏览文件 @
b955826f
...
...
@@ -265,4 +265,23 @@ char *substr(const char *s, int n1, int n2)
return
sp
;
}
/**
* double to string
* @param v
* @return
*/
std
::
string
double_to_str
(
double
v
)
{
char
buf
[
256
];
snprintf
(
buf
,
sizeof
(
buf
),
"%.2f"
,
v
);
size_t
len
=
strlen
(
buf
);
while
(
buf
[
len
-
1
]
==
'0'
)
{
len
--
;
}
if
(
buf
[
len
-
1
]
==
'.'
)
{
len
--
;
}
return
std
::
string
(
buf
,
len
);
}
}
// namespace common
deps/common/lang/string.h
浏览文件 @
b955826f
...
...
@@ -112,6 +112,13 @@ bool str_to_val(const std::string &str, T &val, std::ios_base &(*radix)(std::ios
template
<
class
T
>
void
val_to_str
(
const
T
&
val
,
std
::
string
&
str
,
std
::
ios_base
&
(
*
radix
)(
std
::
ios_base
&
)
=
std
::
dec
);
/**
* Double to string
* @param v
* @return
*/
std
::
string
double_to_str
(
double
v
);
bool
is_blank
(
const
char
*
s
);
/**
...
...
src/observer/sql/expr/tuple_cell.cpp
浏览文件 @
b955826f
...
...
@@ -16,8 +16,8 @@ See the Mulan PSL v2 for more details. */
#include "sql/expr/tuple_cell.h"
#include "storage/common/field.h"
#include "common/log/log.h"
#include "
util
/comparator.h"
#include "
util/util
.h"
#include "
common/lang
/comparator.h"
#include "
common/lang/string
.h"
TupleCellSpec
::
TupleCellSpec
(
const
char
*
table_name
,
const
char
*
field_name
,
const
char
*
alias
)
{
...
...
@@ -140,7 +140,7 @@ void TupleCell::to_string(std::ostream &os) const
os
<<
num_value_
.
int_value_
;
}
break
;
case
FLOATS
:
{
os
<<
double2string
(
num_value_
.
float_value_
);
os
<<
common
::
double_to_str
(
num_value_
.
float_value_
);
}
break
;
case
BOOLEANS
:
{
os
<<
num_value_
.
bool_value_
;
...
...
@@ -159,19 +159,19 @@ int TupleCell::compare(const TupleCell &other) const
if
(
this
->
attr_type_
==
other
.
attr_type_
)
{
switch
(
this
->
attr_type_
)
{
case
INTS
:
{
return
compare_int
((
void
*
)
&
this
->
num_value_
.
int_value_
,
(
void
*
)
&
other
.
num_value_
.
int_value_
);
return
com
mon
::
com
pare_int
((
void
*
)
&
this
->
num_value_
.
int_value_
,
(
void
*
)
&
other
.
num_value_
.
int_value_
);
}
break
;
case
FLOATS
:
{
return
compare_float
((
void
*
)
&
this
->
num_value_
.
float_value_
,
(
void
*
)
&
other
.
num_value_
.
float_value_
);
return
com
mon
::
com
pare_float
((
void
*
)
&
this
->
num_value_
.
float_value_
,
(
void
*
)
&
other
.
num_value_
.
float_value_
);
}
break
;
case
CHARS
:
{
return
compare_string
((
void
*
)
this
->
str_value_
.
c_str
(),
return
com
mon
::
com
pare_string
((
void
*
)
this
->
str_value_
.
c_str
(),
this
->
str_value_
.
length
(),
(
void
*
)
other
.
str_value_
.
c_str
(),
other
.
str_value_
.
length
());
}
break
;
case
BOOLEANS
:
{
return
compare_int
((
void
*
)
&
this
->
num_value_
.
bool_value_
,
(
void
*
)
&
other
.
num_value_
.
bool_value_
);
return
com
mon
::
com
pare_int
((
void
*
)
&
this
->
num_value_
.
bool_value_
,
(
void
*
)
&
other
.
num_value_
.
bool_value_
);
}
default:
{
LOG_WARN
(
"unsupported type: %d"
,
this
->
attr_type_
);
...
...
@@ -179,10 +179,10 @@ int TupleCell::compare(const TupleCell &other) const
}
}
else
if
(
this
->
attr_type_
==
INTS
&&
other
.
attr_type_
==
FLOATS
)
{
float
this_data
=
this
->
num_value_
.
int_value_
;
return
compare_float
((
void
*
)
&
this_data
,
(
void
*
)
&
other
.
num_value_
.
float_value_
);
return
com
mon
::
com
pare_float
((
void
*
)
&
this_data
,
(
void
*
)
&
other
.
num_value_
.
float_value_
);
}
else
if
(
this
->
attr_type_
==
FLOATS
&&
other
.
attr_type_
==
INTS
)
{
float
other_data
=
other
.
num_value_
.
int_value_
;
return
compare_float
((
void
*
)
&
this
->
num_value_
.
float_value_
,
(
void
*
)
&
other_data
);
return
com
mon
::
com
pare_float
((
void
*
)
&
this
->
num_value_
.
float_value_
,
(
void
*
)
&
other_data
);
}
LOG_WARN
(
"not supported"
);
return
-
1
;
// TODO return rc?
...
...
src/observer/storage/index/bplus_tree.h
浏览文件 @
b955826f
...
...
@@ -24,7 +24,7 @@ See the Mulan PSL v2 for more details. */
#include "storage/record/record_manager.h"
#include "storage/default/disk_buffer_pool.h"
#include "sql/parser/parse_defs.h"
#include "
util
/comparator.h"
#include "
common/lang
/comparator.h"
#define EMPTY_RID_PAGE_NUM -1
#define EMPTY_RID_SLOT_NUM -1
...
...
@@ -46,13 +46,13 @@ public:
{
switch
(
attr_type_
)
{
case
INTS
:
{
return
compare_int
((
void
*
)
v1
,
(
void
*
)
v2
);
return
com
mon
::
com
pare_int
((
void
*
)
v1
,
(
void
*
)
v2
);
}
break
;
case
FLOATS
:
{
return
compare_float
((
void
*
)
v1
,
(
void
*
)
v2
);
return
com
mon
::
com
pare_float
((
void
*
)
v1
,
(
void
*
)
v2
);
}
case
CHARS
:
{
return
compare_string
((
void
*
)
v1
,
attr_length_
,
(
void
*
)
v2
,
attr_length_
);
return
com
mon
::
com
pare_string
((
void
*
)
v1
,
attr_length_
,
(
void
*
)
v2
,
attr_length_
);
}
default:
{
LOG_ERROR
(
"unknown attr type. %d"
,
attr_type_
);
...
...
src/observer/util/util.cpp
已删除
100644 → 0
浏览文件 @
72505bdd
/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved.
miniob is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details. */
//
// Created by wangyunlai on 2022/9/28
//
#include <string.h>
#include "util/util.h"
std
::
string
double2string
(
double
v
)
{
char
buf
[
256
];
snprintf
(
buf
,
sizeof
(
buf
),
"%.2f"
,
v
);
size_t
len
=
strlen
(
buf
);
while
(
buf
[
len
-
1
]
==
'0'
)
{
len
--
;
}
if
(
buf
[
len
-
1
]
==
'.'
)
{
len
--
;
}
return
std
::
string
(
buf
,
len
);
}
src/observer/util/util.h
已删除
100644 → 0
浏览文件 @
72505bdd
/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved.
miniob is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details. */
//
// Created by wangyunlai on 2022/9/28
//
#pragma once
#include <string>
std
::
string
double2string
(
double
v
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录