Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion src/observer/catalog/catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ See the Mulan PSL v2 for more details. */

#include "catalog/catalog.h"

namespace oceanbase {

const TableStats &Catalog::get_table_stats(int table_id)
{
lock_guard<mutex> lock(mutex_);
Expand All @@ -20,4 +22,5 @@ void Catalog::update_table_stats(int table_id, const TableStats &table_stats)
{
lock_guard<mutex> lock(mutex_);
table_stats_[table_id] = table_stats;
}
}
} // namespace oceanbase
5 changes: 4 additions & 1 deletion src/observer/catalog/catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ See the Mulan PSL v2 for more details. */
#include "common/lang/mutex.h"
#include "catalog/table_stats.h"

namespace oceanbase {

/**
* @class Catalog
* @brief Store metadata, such as table statistics.
Expand Down Expand Up @@ -71,4 +73,5 @@ class Catalog
* This map is currently not persisted and its persistence is planned via a system table.
*/
unordered_map<int, TableStats> table_stats_; ///< Table statistics storage.
};
};
} // namespace oceanbase
5 changes: 4 additions & 1 deletion src/observer/catalog/table_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ See the Mulan PSL v2 for more details. */

#pragma once

namespace oceanbase {

/**
* @class TableStats
* @brief Represents statistics related to a table.
Expand All @@ -36,4 +38,5 @@ class TableStats
~TableStats() = default;

int row_nums = 0;
};
};
} // namespace oceanbase
3 changes: 3 additions & 0 deletions src/observer/common/global_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ See the Mulan PSL v2 for more details. */

#include "common/global_context.h"

namespace oceanbase {

static GlobalContext global_context;

GlobalContext &GlobalContext::instance() { return global_context; }
} // namespace oceanbase
5 changes: 4 additions & 1 deletion src/observer/common/global_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ See the Mulan PSL v2 for more details. */

#pragma once

namespace oceanbase {

class BufferPoolManager;
class DefaultHandler;
class TrxKit;
Expand All @@ -31,4 +33,5 @@ struct GlobalContext
static GlobalContext &instance();
};

#define GCTX GlobalContext::instance()
#define GCTX GlobalContext::instance()
} // namespace oceanbase
3 changes: 3 additions & 0 deletions src/observer/common/ini_setting.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ See the Mulan PSL v2 for more details. */

//! this document is used for ini setting

namespace oceanbase {

#define CLIENT_ADDRESS "CLIENT_ADDRESS"
#define MAX_CONNECTION_NUM "MAX_CONNECTION_NUM"
#define MAX_CONNECTION_NUM_DEFAULT 8192
Expand All @@ -25,3 +27,4 @@ See the Mulan PSL v2 for more details. */
#define SOCKET_BUFFER_SIZE 8192

#define SESSION_STAGE_NAME "SessionStage"
} // namespace oceanbase
16 changes: 8 additions & 8 deletions src/observer/common/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ See the Mulan PSL v2 for more details. */

using namespace common;

namespace oceanbase {

bool *&_get_init()
{
static bool util_init = false;
Expand Down Expand Up @@ -129,21 +131,18 @@ void cleanup_log()
}
}

int prepare_init_seda()
{
return 0;
}
int prepare_init_seda() { return 0; }

int init_global_objects(ProcessParam *process_param, Ini &properties)
{
GCTX.handler_ = new DefaultHandler();

int ret = 0;

RC rc = GCTX.handler_->init("miniob",
process_param->trx_kit_name().c_str(),
process_param->durability_mode().c_str(),
process_param->storage_engine().c_str());
RC rc = GCTX.handler_->init("miniob",
process_param->trx_kit_name().c_str(),
process_param->durability_mode().c_str(),
process_param->storage_engine().c_str());
if (OB_FAIL(rc)) {
LOG_ERROR("failed to init handler. rc=%s", strrc(rc));
return -1;
Expand Down Expand Up @@ -236,3 +235,4 @@ void cleanup_util()
}

void cleanup() { cleanup_util(); }
} // namespace oceanbase
3 changes: 3 additions & 0 deletions src/observer/common/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ See the Mulan PSL v2 for more details. */
#include "common/conf/ini.h"
#include "common/os/process_param.h"

namespace oceanbase {

int init(common::ProcessParam *processParam);
void cleanup();
} // namespace oceanbase
14 changes: 5 additions & 9 deletions src/observer/common/type/attr_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ 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. */


#include "common/lang/string.h"
#include "common/type/attr_type.h"

namespace oceanbase {

const char *ATTR_TYPE_NAME[] = {"undefined", "chars", "ints", "floats", "vectors", "booleans"};

const char *attr_type_to_string(AttrType type)
Expand All @@ -32,12 +33,7 @@ AttrType attr_type_from_string(const char *s)
return AttrType::UNDEFINED;
}

bool is_numerical_type(AttrType type)
{
return (type == AttrType::INTS || type == AttrType::FLOATS);
}
bool is_numerical_type(AttrType type) { return (type == AttrType::INTS || type == AttrType::FLOATS); }

bool is_string_type(AttrType type)
{
return (type == AttrType::CHARS);
}
bool is_string_type(AttrType type) { return (type == AttrType::CHARS); }
} // namespace oceanbase
3 changes: 3 additions & 0 deletions src/observer/common/type/attr_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ See the Mulan PSL v2 for more details. */

#pragma once

namespace oceanbase {

/**
* @brief 属性的类型
* @details AttrType 枚举列出了属性的各种数据类型。
Expand All @@ -29,3 +31,4 @@ const char *attr_type_to_string(AttrType type);
AttrType attr_type_from_string(const char *s);
bool is_numerical_type(AttrType type);
bool is_string_type(AttrType type);
} // namespace oceanbase
5 changes: 4 additions & 1 deletion src/observer/common/type/char_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ See the Mulan PSL v2 for more details. */
#include "common/type/char_type.h"
#include "common/value.h"

namespace oceanbase {

int CharType::compare(const Value &left, const Value &right) const
{
ASSERT(left.attr_type() == AttrType::CHARS && right.attr_type() == AttrType::CHARS, "invalid type");
Expand Down Expand Up @@ -48,4 +50,5 @@ RC CharType::to_string(const Value &val, string &result) const
ss << val.value_.pointer_value_;
result = ss.str();
return RC::SUCCESS;
}
}
} // namespace oceanbase
3 changes: 3 additions & 0 deletions src/observer/common/type/char_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ See the Mulan PSL v2 for more details. */
#include "common/sys/rc.h"
#include "common/type/data_type.h"

namespace oceanbase {

/**
* @brief 固定长度的字符串类型
* @ingroup DataType
Expand All @@ -34,3 +36,4 @@ class CharType : public DataType

RC to_string(const Value &val, string &result) const override;
};
} // namespace oceanbase
5 changes: 4 additions & 1 deletion src/observer/common/type/data_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ See the Mulan PSL v2 for more details. */
#include "common/type/data_type.h"
#include "common/type/vector_type.h"

namespace oceanbase {

// Todo: 实现新数据类型
// your code here

Expand All @@ -24,4 +26,5 @@ array<unique_ptr<DataType>, static_cast<int>(AttrType::MAXTYPE)> DataType::type_
make_unique<FloatType>(),
make_unique<VectorType>(),
make_unique<DataType>(AttrType::BOOLEANS),
};
};
} // namespace oceanbase
3 changes: 3 additions & 0 deletions src/observer/common/type/data_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ See the Mulan PSL v2 for more details. */
#include "common/sys/rc.h"
#include "common/type/attr_type.h"

namespace oceanbase {

class Value;
class Column;

Expand Down Expand Up @@ -104,3 +106,4 @@ class DataType

static array<unique_ptr<DataType>, static_cast<int>(AttrType::MAXTYPE)> type_instances_;
};
} // namespace oceanbase
8 changes: 5 additions & 3 deletions src/observer/common/type/float_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ See the Mulan PSL v2 for more details. */
#include "common/value.h"
#include "storage/common/column.h"

namespace oceanbase {

int FloatType::compare(const Value &left, const Value &right) const
{
ASSERT(left.attr_type() == AttrType::FLOATS, "left type is not float");
Expand All @@ -30,8 +32,7 @@ int FloatType::compare(const Column &left, const Column &right, int left_idx, in
{
ASSERT(left.attr_type() == AttrType::FLOATS, "left type is not float");
ASSERT(right.attr_type() == AttrType::FLOATS, "right type is not float");
return common::compare_float((void *)&((float*)left.data())[left_idx],
(void *)&((float*)right.data())[right_idx]);
return common::compare_float((void *)&((float *)left.data())[left_idx], (void *)&((float *)right.data())[right_idx]);
}

RC FloatType::add(const Value &left, const Value &right, Value &result) const
Expand Down Expand Up @@ -70,7 +71,7 @@ RC FloatType::negative(const Value &val, Value &result) const

RC FloatType::set_value_from_str(Value &val, const string &data) const
{
RC rc = RC::SUCCESS;
RC rc = RC::SUCCESS;
stringstream deserialize_stream;
deserialize_stream.clear();
deserialize_stream.str(data);
Expand All @@ -92,3 +93,4 @@ RC FloatType::to_string(const Value &val, string &result) const
result = ss.str();
return RC::SUCCESS;
}
} // namespace oceanbase
5 changes: 4 additions & 1 deletion src/observer/common/type/float_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ See the Mulan PSL v2 for more details. */

#include "common/type/data_type.h"

namespace oceanbase {

/**
* @brief 浮点型数据类型
* @ingroup DataType
Expand All @@ -34,4 +36,5 @@ class FloatType : public DataType
RC set_value_from_str(Value &val, const string &data) const override;

RC to_string(const Value &val, string &result) const override;
};
};
} // namespace oceanbase
24 changes: 12 additions & 12 deletions src/observer/common/type/integer_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ See the Mulan PSL v2 for more details. */
#include "common/value.h"
#include "storage/common/column.h"

namespace oceanbase {

int IntegerType::compare(const Value &left, const Value &right) const
{
ASSERT(left.attr_type() == AttrType::INTS, "left type is not integer");
Expand All @@ -33,21 +35,18 @@ int IntegerType::compare(const Column &left, const Column &right, int left_idx,
{
ASSERT(left.attr_type() == AttrType::INTS, "left type is not integer");
ASSERT(right.attr_type() == AttrType::INTS, "right type is not integer");
return common::compare_int((void *)&((int*)left.data())[left_idx],
(void *)&((int*)right.data())[right_idx]);
return common::compare_int((void *)&((int *)left.data())[left_idx], (void *)&((int *)right.data())[right_idx]);
}

RC IntegerType::cast_to(const Value &val, AttrType type, Value &result) const
{
switch (type) {
case AttrType::FLOATS: {
float float_value = val.get_int();
result.set_float(float_value);
return RC::SUCCESS;
}
default:
LOG_WARN("unsupported type %d", type);
return RC::SCHEMA_FIELD_TYPE_MISMATCH;
case AttrType::FLOATS: {
float float_value = val.get_int();
result.set_float(float_value);
return RC::SUCCESS;
}
default: LOG_WARN("unsupported type %d", type); return RC::SCHEMA_FIELD_TYPE_MISMATCH;
}
}

Expand Down Expand Up @@ -77,7 +76,7 @@ RC IntegerType::negative(const Value &val, Value &result) const

RC IntegerType::set_value_from_str(Value &val, const string &data) const
{
RC rc = RC::SUCCESS;
RC rc = RC::SUCCESS;
stringstream deserialize_stream;
deserialize_stream.clear(); // 清理stream的状态,防止多次解析出现异常
deserialize_stream.str(data);
Expand All @@ -97,4 +96,5 @@ RC IntegerType::to_string(const Value &val, string &result) const
ss << val.value_.int_value_;
result = ss.str();
return RC::SUCCESS;
}
}
} // namespace oceanbase
5 changes: 4 additions & 1 deletion src/observer/common/type/integer_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ See the Mulan PSL v2 for more details. */

#include "common/type/data_type.h"

namespace oceanbase {

/**
* @brief 整型类型
* @ingroup DataType
Expand Down Expand Up @@ -45,4 +47,5 @@ class IntegerType : public DataType
RC set_value_from_str(Value &val, const string &data) const override;

RC to_string(const Value &val, string &result) const override;
};
};
} // namespace oceanbase
Loading
Loading