Skip to content

Commit

Permalink
fix bug (#5614)
Browse files Browse the repository at this point in the history
* fix bug

* fix bug

* fix bug

* fix bug

* fix bug
  • Loading branch information
cangfengzhs committed Jun 29, 2023
1 parent 266672b commit c113ffa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/graph/executor/query/FulltextIndexScanExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ folly::Future<Status> FulltextIndexScanExecutor::execute() {
DataSet edges({"id", kScore});
for (auto& item : esResultValue.items) {
Edge edge;
edge.src = item.src;
edge.dst = item.dst;
edge.src = std::stol(item.src);
edge.dst = std::stol(item.dst);
edge.ranking = item.rank;
edge.type = ftIndexScan->schemaId();
edges.emplace_back(Row({std::move(edge), item.score}));
Expand All @@ -65,8 +65,8 @@ folly::Future<Status> FulltextIndexScanExecutor::execute() {
DataSet vertices({"id", kScore});
for (auto& item : esResultValue.items) {
std::string vidStr = item.vid;
int64_t vid = *reinterpret_cast<int64_t*>(vidStr.data());
vertices.emplace_back(Row({vid}));
int64_t vid = std::stol(vidStr);
vertices.emplace_back(Row({vid, item.score}));
}
finish(ResultBuilder().value(Value(std::move(vertices))).iter(Iterator::Kind::kProp).build());
}
Expand Down
11 changes: 6 additions & 5 deletions src/kvstore/listener/elasticsearch/ESListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void ESListener::pickTagAndEdgeData(BatchLogType type,
}
}
vid = NebulaKeyUtils::getVertexId(vIdLen_, key).toString();
vid = truncateVid(vid);
vid = normalizeVid(vid);
} else {
auto edgeType = NebulaKeyUtils::getEdgeType(vIdLen_, key);
if (edgeType < 0) {
Expand All @@ -123,8 +123,8 @@ void ESListener::pickTagAndEdgeData(BatchLogType type,
dst = NebulaKeyUtils::getDstId(vIdLen_, key).toString();
rank = NebulaKeyUtils::getRank(vIdLen_, key);

src = truncateVid(src);
dst = truncateVid(dst);
src = normalizeVid(src);
dst = normalizeVid(dst);
}
if (ftIndexes.empty()) {
return;
Expand Down Expand Up @@ -364,11 +364,12 @@ std::tuple<nebula::cpp2::ErrorCode, int64_t, int64_t> ESListener::commitSnapshot
return {nebula::cpp2::ErrorCode::SUCCEEDED, count, size};
}

std::string ESListener::truncateVid(const std::string& vid) {
std::string ESListener::normalizeVid(const std::string& vid) {
if (!isIntVid_) {
return folly::rtrim(folly::StringPiece(vid), [](char c) { return c == '\0'; }).toString();
} else {
return std::to_string(*reinterpret_cast<const int64_t*>(vid.data()));
}
return vid;
}

StatusOr<::nebula::plugin::ESAdapter> ESListener::getESAdapter() {
Expand Down
2 changes: 1 addition & 1 deletion src/kvstore/listener/elasticsearch/ESListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class ESListener : public Listener {
const std::string& value,
const PickFunc& func);

std::string truncateVid(const std::string& vid);
std::string normalizeVid(const std::string& vid);

StatusOr<::nebula::plugin::ESAdapter> getESAdapter();

Expand Down

0 comments on commit c113ffa

Please sign in to comment.