Remove redundant code

This commit is contained in:
jbajic 2022-11-22 13:27:02 +01:00
parent 37f5fb29ea
commit d080e260e6
4 changed files with 5 additions and 53 deletions

View File

@ -407,7 +407,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
typename TReturnType = std::enable_if_t<std::is_same_v<TTag, StorageTag>, bool>>
TReturnType HasLabelImpl(const VertexAccessor &vertex, const LabelIx &label, StorageTag /*tag*/) {
auto has_label = vertex.HasLabel(view_, GetLabel(label));
if (has_label.HasError() && has_label.GetError().code == Error::NONEXISTENT_OBJECT) {
if (has_label.HasError() && has_label.GetError() == Error::NONEXISTENT_OBJECT) {
// This is a very nasty and temporary hack in order to make MERGE
// work. The old storage had the following logic when returning an
// `OLD` view: `return old ? old : new`. That means that if the
@ -746,7 +746,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
class TReturnType = std::enable_if_t<std::is_same_v<TTag, StorageTag>, TypedValue>>
TypedValue GetProperty(const TRecordAccessor &record_accessor, PropertyIx prop) {
auto maybe_prop = record_accessor.GetProperty(view_, ctx_->properties[prop.ix]);
if (maybe_prop.HasError() && maybe_prop.GetError().code == Error::NONEXISTENT_OBJECT) {
if (maybe_prop.HasError() && maybe_prop.GetError() == Error::NONEXISTENT_OBJECT) {
// This is a very nasty and temporary hack in order to make MERGE work.
// The old storage had the following logic when returning an `OLD` view:
// `return old ? old : new`. That means that if the `OLD` view didn't
@ -765,7 +765,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
class TReturnType = std::enable_if_t<std::is_same_v<TTag, StorageTag>, TypedValue>>
TypedValue GetProperty(const TRecordAccessor &record_accessor, const std::string_view name) {
auto maybe_prop = record_accessor.GetProperty(view_, dba_->NameToProperty(name));
if (maybe_prop.HasError() && maybe_prop.GetError().code == Error::NONEXISTENT_OBJECT) {
if (maybe_prop.HasError() && maybe_prop.GetError() == Error::NONEXISTENT_OBJECT) {
// This is a very nasty and temporary hack in order to make MERGE work.
// The old storage had the following logic when returning an `OLD` view:
// `return old ? old : new`. That means that if the `OLD` view didn't

View File

@ -81,19 +81,5 @@ inline void ExpectType(const Symbol &symbol, const TypedValue &value, TypedValue
throw QueryRuntimeException("Expected a {} for '{}', but got {}.", expected, symbol.name(), value.type());
}
template <typename T>
concept AccessorWithSetProperty = requires(T accessor, const storage::v3::PropertyId key,
const storage::v3::PropertyValue new_value) {
{ accessor.SetProperty(key, new_value) } -> std::same_as<storage::v3::ShardResult<storage::v3::PropertyValue>>;
};
template <typename T>
concept AccessorWithSetPropertyAndValidate = requires(T accessor, const storage::v3::PropertyId key,
const storage::v3::PropertyValue new_value) {
{
accessor.SetPropertyAndValidate(key, new_value)
} -> std::same_as<storage::v3::ShardResult<storage::v3::PropertyValue>>;
};
int64_t QueryTimestamp();
} // namespace memgraph::query::v2

View File

@ -816,45 +816,9 @@ std::vector<Symbol> SetProperties::ModifiedSymbols(const SymbolTable &table) con
SetProperties::SetPropertiesCursor::SetPropertiesCursor(const SetProperties &self, utils::MemoryResource *mem)
: self_(self), input_cursor_(self.input_->MakeCursor(mem)) {}
namespace {
template <typename T>
concept AccessorWithProperties = requires(T value, storage::v3::PropertyId property_id,
storage::v3::PropertyValue property_value) {
{
value.ClearProperties()
} -> std::same_as<storage::v3::ShardResult<std::map<storage::v3::PropertyId, storage::v3::PropertyValue>>>;
{value.SetProperty(property_id, property_value)};
};
} // namespace
bool SetProperties::SetPropertiesCursor::Pull(Frame &frame, ExecutionContext &context) {
SCOPED_PROFILE_OP("SetProperties");
return false;
// if (!input_cursor_->Pull(frame, context)) return false;
//
// TypedValue &lhs = frame[self_.input_symbol_];
//
// // Set, just like Create needs to see the latest changes.
// ExpressionEvaluator evaluator(&frame, context.symbol_table, context.evaluation_context, context.db_accessor,
// storage::v3::View::NEW);
// TypedValue rhs = self_.rhs_->Accept(evaluator);
//
// switch (lhs.type()) {
// case TypedValue::Type::Vertex:
// SetPropertiesOnRecord(&lhs.ValueVertex(), rhs, self_.op_, &context);
// break;
// case TypedValue::Type::Edge:
// SetPropertiesOnRecord(&lhs.ValueEdge(), rhs, self_.op_, &context);
// break;
// case TypedValue::Type::Null:
// // Skip setting properties on Null (can occur in optional match).
// break;
// default:
// throw QueryRuntimeException("Properties can only be set on edges and vertices.");
// }
// return true;
}
void SetProperties::SetPropertiesCursor::Shutdown() { input_cursor_->Shutdown(); }

View File

@ -37,6 +37,8 @@ struct ShardError {
std::string source;
inline friend bool operator==(const ShardError &lhs, const ShardError &rhs) { return lhs.code == rhs.code; }
inline friend bool operator==(const ShardError &lhs, const common::ErrorCode rhs) { return lhs.code == rhs; }
};
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)