Make GetProperties return the PrimaryKeys as well, when queried for all properties like ScanAll
This commit is contained in:
parent
fdd89e0e81
commit
9be5ee1ae9
@ -519,6 +519,8 @@ class DistributedScanAllByPrimaryKeyCursor : public Cursor {
|
||||
// Original
|
||||
// current_batch_ = request_router.ScanVertices(request_label, pk);
|
||||
|
||||
auto asd_debug = request_router.ScanVertices(request_label, pk);
|
||||
|
||||
// VertexAccessor(Vertex v, std::vector<std::pair<PropertyId, Value>> props,
|
||||
// const RequestRouterInterface *request_router);
|
||||
|
||||
@ -536,21 +538,17 @@ class DistributedScanAllByPrimaryKeyCursor : public Cursor {
|
||||
|
||||
msgs::GetPropertiesRequest req = {.vertex_ids = {std::make_pair(label, pk)}};
|
||||
auto get_prop_result = request_router.GetProperties(req);
|
||||
MG_ASSERT(get_prop_result.size() == 1);
|
||||
MG_ASSERT(get_prop_result.size() <= 1);
|
||||
|
||||
// std::vector<std::pair<PropertyId, Value>> props
|
||||
std::map<msgs::PropertyId, msgs::Value> transformed_properties;
|
||||
auto properties = get_prop_result[0].props;
|
||||
std::transform(properties.begin(), properties.end(),
|
||||
std::inserter(transformed_properties, transformed_properties.end()), [](const auto &prop) {
|
||||
return std::make_pair(msgs::PropertyId::FromUint(prop.first.AsUint()), prop.second);
|
||||
});
|
||||
if (get_prop_result.empty()) {
|
||||
current_batch_ = std::vector<VertexAccessor>{};
|
||||
} else {
|
||||
auto properties = get_prop_result[0].props;
|
||||
// TODO (gvolfing) figure out labels when relevant.
|
||||
msgs::Vertex vertex = {.id = get_prop_result[0].vertex, .labels = {}};
|
||||
|
||||
msgs::Vertex vertex = {.id = get_prop_result[0].vertex, .labels = {label}};
|
||||
// auto va = VertexAccessor(vertex, std::move(transformed_properties), &request_router);
|
||||
auto va = VertexAccessor(vertex, properties, &request_router);
|
||||
|
||||
current_batch_ = {va};
|
||||
current_batch_ = {VertexAccessor(vertex, properties, &request_router)};
|
||||
}
|
||||
}
|
||||
current_vertex_it_ = current_batch_.begin();
|
||||
request_state_ = State::COMPLETED;
|
||||
|
@ -372,6 +372,8 @@ class RequestRouter : public RequestRouterInterface {
|
||||
}
|
||||
|
||||
std::vector<msgs::GetPropertiesResultRow> GetProperties(msgs::GetPropertiesRequest requests) override {
|
||||
// Add HLC to GetProperties request
|
||||
requests.transaction_id = transaction_id_;
|
||||
// create requests
|
||||
std::vector<ShardRequestState<msgs::GetPropertiesRequest>> requests_to_be_sent =
|
||||
RequestsForGetProperties(std::move(requests));
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -535,13 +535,17 @@ msgs::ReadResponses ShardRsm::HandleRead(msgs::GetPropertiesRequest &&req) {
|
||||
return result;
|
||||
};
|
||||
|
||||
auto collect_props = [&req](const VertexAccessor &v_acc,
|
||||
const std::optional<EdgeAccessor> &e_acc) -> ShardResult<std::map<PropertyId, Value>> {
|
||||
auto collect_props = [this, &req](
|
||||
const VertexAccessor &v_acc,
|
||||
const std::optional<EdgeAccessor> &e_acc) -> ShardResult<std::map<PropertyId, Value>> {
|
||||
if (!req.property_ids) {
|
||||
const auto *schema = shard_->GetSchema(shard_->PrimaryLabel());
|
||||
MG_ASSERT(schema);
|
||||
|
||||
if (e_acc) {
|
||||
return CollectAllPropertiesFromAccessor(*e_acc, view);
|
||||
}
|
||||
return CollectAllPropertiesFromAccessor(v_acc, view);
|
||||
return CollectAllPropertiesFromAccessor(v_acc, view, *schema);
|
||||
}
|
||||
|
||||
if (e_acc) {
|
||||
|
Loading…
Reference in New Issue
Block a user