Skip to content

Commit

Permalink
don't need std_string
Browse files Browse the repository at this point in the history
Committed-by: xiaolei.zl from Dev container
  • Loading branch information
zhanglei1949 committed Oct 15, 2024
1 parent 16a8ece commit c3c9e95
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 74 deletions.
10 changes: 2 additions & 8 deletions flex/engines/graph_db/runtime/adhoc/operators/procedure_call.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,9 @@ std::shared_ptr<IContextColumn> any_vec_to_column(
}
return builder.finish();
} else if (first == RTAnyType::kStringValue) {
ValueColumnBuilder<std::string> builder;
ValueColumnBuilder<std::string_view> builder;
for (auto& any : any_vec) {
builder.push_back_opt(std::string(any.as_string()));
}
return builder.finish();
} else if (first == RTAnyType::kStdStringValue) {
ValueColumnBuilder<std::string> builder;
for (auto& any : any_vec) {
builder.push_back_opt(any.as_std_string());
builder.push_back_elem(any);
}
return builder.finish();
} else {
Expand Down
24 changes: 0 additions & 24 deletions flex/engines/graph_db/runtime/common/columns/i_context_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,30 +110,6 @@ class SigColumn<std::string_view> : public ISigColumn {
std::vector<size_t> sig_list_;
};

template <>
class SigColumn<std::string> : public ISigColumn {
public:
SigColumn(const std::vector<std::string>& data) {
std::unordered_map<std::string, size_t> table;
sig_list_.reserve(data.size());
for (auto& str : data) {
auto iter = table.find(str);
if (iter == table.end()) {
size_t idx = table.size();
table.emplace(str, idx);
sig_list_.push_back(idx);
} else {
sig_list_.push_back(iter->second);
}
}
}
~SigColumn() = default;
size_t get_sig(size_t idx) const override { return sig_list_[idx]; }

private:
std::vector<size_t> sig_list_;
};

template <>
class SigColumn<std::set<std::string>> : public ISigColumn {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/

#include "flex/engines/graph_db/runtime/common/columns/value_columns.h"
#include "flex/proto_generated_gie/results.pb.h"

namespace gs {

Expand Down
30 changes: 2 additions & 28 deletions flex/engines/graph_db/runtime/common/rt_any.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ const RTAnyType RTAnyType::kBoolValue =
RTAnyType(RTAnyType::RTAnyTypeImpl::kBoolValue);
const RTAnyType RTAnyType::kStringValue =
RTAnyType(RTAnyType::RTAnyTypeImpl::kStringValue);
const RTAnyType RTAnyType::kStdStringValue =
RTAnyType(RTAnyType::RTAnyTypeImpl::kStdStringValue);
const RTAnyType RTAnyType::kVertexSetValue =
RTAnyType(RTAnyType::RTAnyTypeImpl::kVertexSetValue);
const RTAnyType RTAnyType::kStringSetValue =
Expand Down Expand Up @@ -142,8 +140,6 @@ RTAny::RTAny(const RTAny& rhs) : type_(rhs.type_) {
value_.vertex = rhs.value_.vertex;
} else if (type_ == RTAnyType::kStringValue) {
value_.str_val = rhs.value_.str_val;
} else if (type_ == RTAnyType::kStdStringValue) {
value_.std_str_val = rhs.value_.std_str_val;
} else if (type_ == RTAnyType::kNull) {
// do nothing
} else if (type_ == RTAnyType::kTuple) {
Expand Down Expand Up @@ -171,8 +167,6 @@ RTAny& RTAny::operator=(const RTAny& rhs) {
value_.vertex = rhs.value_.vertex;
} else if (type_ == RTAnyType::kStringValue) {
value_.str_val = rhs.value_.str_val;
} else if (type_ == RTAnyType::kStdStringValue) {
value_.std_str_val = rhs.value_.std_str_val;
} else if (type_ == RTAnyType::kTuple) {
value_.t = rhs.value_.t.dup();
} else if (type_ == RTAnyType::kList) {
Expand Down Expand Up @@ -244,8 +238,8 @@ RTAny RTAny::from_int32(int v) {

RTAny RTAny::from_string(const std::string& str) {
RTAny ret;
ret.type_ = RTAnyType::kStdStringValue;
ret.value_.std_str_val = str;
ret.type_ = RTAnyType::kStringValue;
ret.value_.str_val = std::string_view(str);
return ret;
}

Expand Down Expand Up @@ -368,17 +362,6 @@ std::string_view RTAny::as_string() const {
}
}

std::string RTAny::as_std_string() const {
if (type_ == RTAnyType::kStdStringValue) {
return *(value_.std_str_val.ptr);
} else if (type_ == RTAnyType::kUnknown) {
return std::string();
} else {
LOG(FATAL) << "unexpected type" << static_cast<int>(type_.type_enum_);
return std::string();
}
}

List RTAny::as_list() const {
CHECK(type_ == RTAnyType::kList);
return value_.list;
Expand Down Expand Up @@ -462,8 +445,6 @@ bool RTAny::operator<(const RTAny& other) const {

} else if (type_ == RTAnyType::kStringValue) {
return value_.str_val < other.value_.str_val;
} else if (type_ == RTAnyType::kStdStringValue) {
return *(value_.std_str_val.ptr) < *(other.value_.std_str_val.ptr);
} else if (type_ == RTAnyType::kDate32) {
return value_.i64_val < other.value_.i64_val;
} else if (type_ == RTAnyType::kF64Value) {
Expand All @@ -490,8 +471,6 @@ bool RTAny::operator==(const RTAny& other) const {
return value_.i32_val == other.value_.i32_val;
} else if (type_ == RTAnyType::kStringValue) {
return value_.str_val == other.value_.str_val;
} else if (type_ == RTAnyType::kStdStringValue) {
return *(value_.std_str_val.ptr) == *(other.value_.std_str_val.ptr);
} else if (type_ == RTAnyType::kVertex) {
return value_.vertex == other.value_.vertex;
} else if (type_ == RTAnyType::kDate32) {
Expand Down Expand Up @@ -576,9 +555,6 @@ void RTAny::sink_impl(common::Value* value) const {
value->set_i64(value_.i64_val);
} else if (type_ == RTAnyType::kStringValue) {
value->set_str(value_.str_val.data(), value_.str_val.size());
} else if (type_ == RTAnyType::kStdStringValue) {
value->set_str(value_.std_str_val.ptr->data(),
value_.std_str_val.ptr->size());
} else if (type_ == RTAnyType::kI32Value) {
value->set_i32(value_.i32_val);
} else if (type_ == RTAnyType::kStringSetValue) {
Expand Down Expand Up @@ -767,8 +743,6 @@ std::string RTAny::to_string() const {
return std::to_string(value_.i64_val);
} else if (type_ == RTAnyType::kStringValue) {
return std::string(value_.str_val);
} else if (type_ == RTAnyType::kStdStringValue) {
return std::string(*(value_.std_str_val.ptr));
} else if (type_ == RTAnyType::kI32Value) {
return std::to_string(value_.i32_val);
} else if (type_ == RTAnyType::kVertex) {
Expand Down
13 changes: 0 additions & 13 deletions flex/engines/graph_db/runtime/common/rt_any.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ union RTAnyValue {
const std::vector<vid_t>* vset;
const std::set<std::string>* str_set;
std::string_view str_val;
StringPtr std_str_val;
Path p;
Tuple t;
List list;
Expand Down Expand Up @@ -281,7 +280,6 @@ class RTAny {
const std::tuple<LabelTriplet, vid_t, vid_t, Any, Direction>& as_edge() const;
const std::set<std::string>& as_string_set() const;
std::string_view as_string() const;
std::string as_std_string() const;
const std::vector<vid_t>& as_vertex_list() const;
Path as_path() const;
Tuple as_tuple() const;
Expand Down Expand Up @@ -365,17 +363,6 @@ struct TypedConverter<std::string_view> {
}
};

template <>
struct TypedConverter<std::string> {
static RTAnyType type() { return RTAnyType::kStringValue; }
static std::string to_typed(const RTAny& val) { return val.as_std_string(); }
static RTAny from_typed(const std::string& val) {
return RTAny::from_string(val);
}
static const std::string name() { return "string"; }
static std::string typed_from_string(const std::string& str) { return str; }
};

template <>
struct TypedConverter<uint64_t> {
static RTAnyType type() { return RTAnyType::kU64Value; }
Expand Down

0 comments on commit c3c9e95

Please sign in to comment.