Skip to content

Commit

Permalink
[fix][index] Fix TxnGet for vector.
Browse files Browse the repository at this point in the history
If the vector id is not exists, store do wrong value check for kv
returned from txn_engine_helper and return empty value of vector kv
value to sdk.

Signed-off-by: Ketor <[email protected]>
  • Loading branch information
ketor authored and rock-git committed Feb 19, 2024
1 parent af35815 commit 7b58c84
Showing 1 changed file with 30 additions and 36 deletions.
66 changes: 30 additions & 36 deletions src/server/index_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1194,20 +1194,18 @@ void DoTxnGetVector(StoragePtr storage, google::protobuf::RpcController* control

if (!kvs.empty()) {
for (auto& kv : kvs) {
if (kv.value().empty()) {
auto* err = response->mutable_error();
err->set_errcode(static_cast<Errno>(pb::error::EINTERNAL));
err->set_errmsg("empty value of vector kv value");
return;
}
pb::common::VectorWithId vector_with_id;
auto parse_ret = vector_with_id.ParseFromString(kv.value());
if (!parse_ret) {
auto* err = response->mutable_error();
err->set_errcode(static_cast<Errno>(pb::error::EINTERNAL));
err->set_errmsg("parse vector_with_id failed");
return;

if (!kv.value().empty()) {
auto parse_ret = vector_with_id.ParseFromString(kv.value());
if (!parse_ret) {
auto* err = response->mutable_error();
err->set_errcode(static_cast<Errno>(pb::error::EINTERNAL));
err->set_errmsg("parse vector_with_id failed");
return;
}
}

response->mutable_vector()->Swap(&vector_with_id);
}
}
Expand Down Expand Up @@ -1321,20 +1319,18 @@ void DoTxnScanVector(StoragePtr storage, google::protobuf::RpcController* contro

if (!kvs.empty()) {
for (auto& kv : kvs) {
if (kv.value().empty()) {
auto* err = response->mutable_error();
err->set_errcode(static_cast<Errno>(pb::error::EINTERNAL));
err->set_errmsg("empty value of vector kv value");
return;
}
pb::common::VectorWithId vector_with_id;
auto parse_ret = vector_with_id.ParseFromString(kv.value());
if (!parse_ret) {
auto* err = response->mutable_error();
err->set_errcode(static_cast<Errno>(pb::error::EINTERNAL));
err->set_errmsg("parse vector_with_id failed");
return;

if (!kv.value().empty()) {
auto parse_ret = vector_with_id.ParseFromString(kv.value());
if (!parse_ret) {
auto* err = response->mutable_error();
err->set_errcode(static_cast<Errno>(pb::error::EINTERNAL));
err->set_errmsg("parse vector_with_id failed");
return;
}
}

response->add_vectors()->Swap(&vector_with_id);
}
}
Expand Down Expand Up @@ -2095,20 +2091,18 @@ void DoTxnBatchGetVector(StoragePtr storage, google::protobuf::RpcController* co

if (!kvs.empty()) {
for (auto& kv : kvs) {
if (kv.value().empty()) {
auto* err = response->mutable_error();
err->set_errcode(static_cast<Errno>(pb::error::EINTERNAL));
err->set_errmsg("empty value of vector kv value");
return;
}
pb::common::VectorWithId vector_with_id;
auto parse_ret = vector_with_id.ParseFromString(kv.value());
if (!parse_ret) {
auto* err = response->mutable_error();
err->set_errcode(static_cast<Errno>(pb::error::EINTERNAL));
err->set_errmsg("parse vector_with_id failed");
return;

if (!kv.value().empty()) {
auto parse_ret = vector_with_id.ParseFromString(kv.value());
if (!parse_ret) {
auto* err = response->mutable_error();
err->set_errcode(static_cast<Errno>(pb::error::EINTERNAL));
err->set_errmsg("parse vector_with_id failed");
return;
}
}

response->add_vectors()->Swap(&vector_with_id);
}
}
Expand Down

0 comments on commit 7b58c84

Please sign in to comment.