Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Committed-by: [email protected] from Dev container

Committed-by: [email protected] from Dev container
  • Loading branch information
zhanglei1949 committed Jan 22, 2025
1 parent 443f4bd commit 7b9842b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
25 changes: 10 additions & 15 deletions flex/engines/graph_db/runtime/common/operators/retrieve/scan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,26 @@ namespace gs {
namespace runtime {

Context Scan::find_vertex_with_oid(const GraphReadInterface& graph,
label_t label, const Any& oid, int32_t alias,
int32_t limit) {
label_t label, const Any& oid,
int32_t alias) {
SLVertexColumnBuilder builder(label);
vid_t vid;
if (limit >= 1) {
if (graph.GetVertexIndex(label, oid, vid)) {
builder.push_back_opt(vid);
}
if (graph.GetVertexIndex(label, oid, vid)) {
builder.push_back_opt(vid);
}
Context ctx;
ctx.set(alias, builder.finish());
return ctx;
}

Context Scan::find_vertex_with_gid(const GraphReadInterface& graph,
label_t label, int64_t gid, int32_t alias,
int32_t limit) {
label_t label, int64_t gid, int32_t alias) {
SLVertexColumnBuilder builder(label);
if (limit >= 1) {
if (GlobalId::get_label_id(gid) == label) {
builder.push_back_opt(GlobalId::get_vid(gid));
} else {
LOG(ERROR) << "Invalid label id: "
<< static_cast<int>(GlobalId::get_label_id(gid));
}
if (GlobalId::get_label_id(gid) == label) {
builder.push_back_opt(GlobalId::get_vid(gid));
} else {
LOG(ERROR) << "Invalid label id: "
<< static_cast<int>(GlobalId::get_label_id(gid));
}
Context ctx;
ctx.set(alias, builder.finish());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,10 @@ class Scan {

static Context find_vertex_with_oid(const GraphReadInterface& graph,
label_t label, const Any& pk,
int32_t alias, int32_t limit);
int32_t alias);

static Context find_vertex_with_gid(const GraphReadInterface& graph,
label_t label, int64_t pk, int32_t alias,
int32_t limit);
label_t label, int64_t pk, int32_t alias);
};

} // namespace runtime
Expand Down
11 changes: 6 additions & 5 deletions flex/engines/graph_db/runtime/execute/ops/retrieve/scan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class FilterOidsWithoutPredOpr : public IReadOperator {
std::vector<Any> oids = oids_(params);
if (params_.tables.size() == 1 && oids.size() == 1) {
return Scan::find_vertex_with_oid(graph, params_.tables[0], oids[0],
params_.alias, params_.limit);
params_.alias);
}
return Scan::filter_oids(
graph, params_, [](label_t, vid_t) { return true; }, oids);
Expand Down Expand Up @@ -230,7 +230,7 @@ class FilterGidsWithoutPredOpr : public IReadOperator {
}
if (params_.tables.size() == 1 && gids.size() == 1) {
return Scan::find_vertex_with_gid(graph, params_.tables[0], gids[0],
params_.alias, params_.limit);
params_.alias);
}
return Scan::filter_gids(
graph, params_, [](label_t, vid_t) { return true; }, gids);
Expand Down Expand Up @@ -566,15 +566,16 @@ std::pair<std::unique_ptr<IReadOperator>, ContextMeta> ScanOprBuilder::Build(

ScanParams scan_params;
scan_params.alias = scan_opr.has_alias() ? scan_opr.alias().value() : -1;
scan_params.limit = std::numeric_limits<int32_t>::max();
if (scan_opr.params().has_limit()) {
auto& limit_range = scan_opr.params().limit();
if (limit_range.lower() != 0) {
LOG(FATAL) << "Scan with lower limit expect 0, but got "
<< limit_range.lower();
}
scan_params.limit = limit_range.upper();
} else {
scan_params.limit = std::numeric_limits<int32_t>::max();
if (limit_range.upper() > 0) {
scan_params.limit = limit_range.upper();
}
}
for (auto& table : scan_opr.params().tables()) {
// bug here, exclude invalid vertex label id
Expand Down

0 comments on commit 7b9842b

Please sign in to comment.