Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: delete functions in src/codec/schema_codec.h #2100

Merged
merged 4 commits into from
Jul 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions src/codec/schema_codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
namespace openmldb {
namespace codec {

constexpr uint32_t MAX_ROW_BYTE_SIZE = 1024 * 1024; // 1M
constexpr uint32_t HEADER_BYTE_SIZE = 3;

const std::string NONETOKEN = "!N@U#L$L%"; // NOLINT
const std::string EMPTY_STRING = "!@#$%"; // NOLINT
const std::string DEFAULT_LONG = "1"; // NOLINT
Expand Down Expand Up @@ -193,50 +190,6 @@ class SchemaCodec {
return hybridse::type::kNull;
}
}

static void GetSchemaData(const std::map<std::string, std::string>& columns_map, const Schema& schema,
Schema& new_schema) { // NOLINT
for (int i = 0; i < schema.size(); i++) {
const ::openmldb::common::ColumnDesc& col = schema.Get(i);
const std::string& col_name = col.name();
auto iter = columns_map.find(col_name);
if (iter != columns_map.end()) {
::openmldb::common::ColumnDesc* tmp = new_schema.Add();
tmp->CopyFrom(col);
}
}
}

static openmldb::base::Status GetCdColumns(
const Schema& schema, const std::map<std::string, std::string>& cd_columns_map,
::google::protobuf::RepeatedPtrField<::openmldb::api::Columns>* cd_columns) {
std::map<std::string, ::openmldb::type::DataType> name_type_map;
for (const auto& col_desc : schema) {
name_type_map.insert(std::make_pair(col_desc.name(), col_desc.data_type()));
}
for (const auto& kv : cd_columns_map) {
auto iter = name_type_map.find(kv.first);
if (iter == name_type_map.end()) {
return openmldb::base::Status(-1, "query failed! col_name " + kv.first + " not exist");
}
::openmldb::api::Columns* index = cd_columns->Add();
index->add_name(kv.first);
if (kv.second == NONETOKEN || kv.second == "null") {
continue;
}
}
return openmldb::base::Status();
}

private:
// calc the total size of schema
uint32_t GetSize(const std::vector<ColumnDesc>& columns) {
uint32_t byte_size = 0;
for (uint32_t i = 0; i < columns.size(); i++) {
byte_size += (HEADER_BYTE_SIZE + columns[i].name.size());
}
return byte_size;
}
};

} // namespace codec
Expand Down