diff --git a/src/executor/algo/ProduceSemiShortestPathExecutor.cpp b/src/executor/algo/ProduceSemiShortestPathExecutor.cpp index c2fcb5042..b769ea825 100644 --- a/src/executor/algo/ProduceSemiShortestPathExecutor.cpp +++ b/src/executor/algo/ProduceSemiShortestPathExecutor.cpp @@ -86,9 +86,7 @@ void ProduceSemiShortestPathExecutor::dstNotInHistory(const Edge& edge, auto cost = srcPath.second.cost_ + weight; std::vector newPaths = createPaths(srcPath.second.paths_, edge); - std::unordered_map temp = { - {srcPath.first, CostPaths(cost, newPaths)}}; - currentCostPathMap.emplace(dst, std::move(temp)); + currentCostPathMap[dst].emplace(srcPath.first, CostPaths(cost, std::move(newPaths))); } } else { // dst in current @@ -102,6 +100,7 @@ void ProduceSemiShortestPathExecutor::removeSamePath(std::vector& paths, auto iter = paths.begin(); while (iter != paths.end()) { if (*iter == *ptr) { + VLOG(2) << "Erese Path :" << *iter; iter = paths.erase(iter); } else { ++iter; @@ -124,9 +123,8 @@ void ProduceSemiShortestPathExecutor::dstInHistory(const Edge& edge, // (dst, startVid)'s path not in history auto newCost = srcPath.second.cost_ + weight; std::vector newPaths = createPaths(srcPath.second.paths_, edge); - std::unordered_map temp = { - {srcPath.first, CostPaths(newCost, newPaths)}}; - currentCostPathMap.emplace(dst, std::move(temp)); + currentCostPathMap[dst].emplace(srcPath.first, + CostPaths(newCost, std::move(newPaths))); } else { // (dst, startVid)'s path in history, compare cost auto newCost = srcPath.second.cost_ + weight; @@ -136,9 +134,8 @@ void ProduceSemiShortestPathExecutor::dstInHistory(const Edge& edge, } else if (newCost < historyCost) { // update (dst, startVid)'s path std::vector newPaths = createPaths(srcPath.second.paths_, edge); - std::unordered_map temp = { - {srcPath.first, CostPaths(newCost, newPaths)}}; - currentCostPathMap.emplace(dst, std::move(temp)); + currentCostPathMap[dst].emplace(srcPath.first, + CostPaths(newCost, std::move(newPaths))); } else { std::vector newPaths = createPaths(srcPath.second.paths_, edge); // if same path in history, remove it @@ -146,9 +143,8 @@ void ProduceSemiShortestPathExecutor::dstInHistory(const Edge& edge, if (newPaths.empty()) { continue; } - std::unordered_map temp = { - {srcPath.first, CostPaths(newCost, newPaths)}}; - currentCostPathMap.emplace(dst, std::move(temp)); + currentCostPathMap[dst].emplace(srcPath.first, + CostPaths(newCost, std::move(newPaths))); } } } @@ -220,11 +216,11 @@ folly::Future ProduceSemiShortestPathExecutor::execute() { path.src = Vertex(src, {}); path.steps.emplace_back(Step(Vertex(dst, {}), edge.type, edge.name, edge.ranking, {})); if (currentCostPathMap.find(dst) != currentCostPathMap.end()) { - // same (src, dst), diffrent edge type or rank if (currentCostPathMap[dst].find(src) == currentCostPathMap[dst].end()) { CostPaths costPaths(weight, {std::move(path)}); currentCostPathMap[dst].emplace(src, std::move(costPaths)); } else { + // same (src, dst), diffrent edge type or rank auto currentCost = currentCostPathMap[dst][src].cost_; if (weight == currentCost) { currentCostPathMap[dst][src].paths_.emplace_back(std::move(path)); @@ -237,8 +233,7 @@ folly::Future ProduceSemiShortestPathExecutor::execute() { } } else { CostPaths costPaths(weight, {std::move(path)}); - std::unordered_map temp = {{src, std::move(costPaths)}}; - currentCostPathMap.emplace(dst, std::move(temp)); + currentCostPathMap[dst].emplace(src, std::move(costPaths)); } } else { if (historyCostPathMap_.find(dst) == historyCostPathMap_.end()) { @@ -272,7 +267,7 @@ folly::Future ProduceSemiShortestPathExecutor::execute() { updateHistory(dst, srcPath.first, cost, ds.rows.back().values.back()); } } - + VLOG(2) << "SemiShortPath : " << ds; return finish(ResultBuilder().value(Value(std::move(ds))).finish()); } diff --git a/src/optimizer/OptimizerUtils.cpp b/src/optimizer/OptimizerUtils.cpp index 618166f81..748e94494 100644 --- a/src/optimizer/OptimizerUtils.cpp +++ b/src/optimizer/OptimizerUtils.cpp @@ -813,7 +813,7 @@ bool OptimizerUtils::findOptimalIndex(const Expression* condition, const std::vector>& indexItems, bool* isPrefixScan, IndexQueryContext* ictx) { - // Return directly if there is not valid index to use. + // Return directly if there is no valid index to use. if (indexItems.empty()) { return false; } diff --git a/tests/tck/features/bugfix/StringFlaotAddition.feature b/tests/tck/features/bugfix/StringFlaotAddition.feature new file mode 100644 index 000000000..b08cd18e5 --- /dev/null +++ b/tests/tck/features/bugfix/StringFlaotAddition.feature @@ -0,0 +1,69 @@ +# Copyright (c) 2021 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License, +# attached with Common Clause Condition 1.0, found in the LICENSES directory. +Feature: Test return float plus string + + Background: + Given a graph with space named "nba" + + # Fix https://github.com/vesoft-inc/nebula-graph/issues/1214 + Scenario: addition[1] + When executing query: + """ + RETURN 30.142857142857142 + "Yao Ming" + """ + Then the result should be, in any order, with relax comparison: + | (30.142857142857142+"Yao Ming") | + | "30.142857142857142Yao Ming" | + When executing query: + """ + RETURN -30.142857142857142 + "Yao Ming" + """ + Then the result should be, in any order, with relax comparison: + | (-(30.142857142857142)+"Yao Ming") | + | "-30.142857142857142Yao Ming" | + When executing query: + """ + RETURN "Yao Ming" + 30.142857142857142 + """ + Then the result should be, in any order, with relax comparison: + | ("Yao Ming"+30.142857142857142) | + | "Yao Ming30.142857142857142" | + When executing query: + """ + RETURN "Yao Ming" + -30.142857142857142 + """ + Then the result should be, in any order, with relax comparison: + | ("Yao Ming"+-(30.142857142857142)) | + | "Yao Ming-30.142857142857142" | + + Scenario: addition[2] + When executing query: + """ + RETURN 30.14 + "Yao Ming" + """ + Then the result should be, in any order, with relax comparison: + | (30.14+"Yao Ming") | + | "30.14Yao Ming" | + When executing query: + """ + RETURN -30.14 + "Yao Ming" + """ + Then the result should be, in any order, with relax comparison: + | (-(30.14)+"Yao Ming") | + | "-30.14Yao Ming" | + When executing query: + """ + RETURN "Yao Ming" + 30.14 + """ + Then the result should be, in any order, with relax comparison: + | ("Yao Ming"+30.14) | + | "Yao Ming30.14" | + When executing query: + """ + RETURN "Yao Ming" + -30.14 + """ + Then the result should be, in any order, with relax comparison: + | ("Yao Ming"+-(30.14)) | + | "Yao Ming-30.14" |