Skip to content

Commit

Permalink
Fix bugs in storage (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
dangleptr authored and dutor committed Apr 16, 2019
1 parent b52a911 commit ef7f604
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/storage/AddVerticesProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "storage/AddVerticesProcessor.h"
#include <algorithm>
#include <limits>
#include "time/TimeUtils.h"
#include "storage/KeyUtils.h"

Expand All @@ -14,7 +15,7 @@ namespace storage {

void AddVerticesProcessor::process(const cpp2::AddVerticesRequest& req) {
VLOG(3) << "Receive AddVerticesRequest...";
auto now = time::TimeUtils::nowInMSeconds();
auto now = std::numeric_limits<int64_t>::max() - time::TimeUtils::nowInMSeconds();
const auto& partVertices = req.get_parts();
auto spaceId = req.get_space_id();
callingNum_ = partVertices.size();
Expand Down
11 changes: 9 additions & 2 deletions src/storage/QueryBaseProcessor.inl
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,28 @@ kvstore::ResultCode QueryBaseProcessor<REQ, RESP>::collectEdgeProps(
if (ret != kvstore::ResultCode::SUCCEEDED || !iter) {
return ret;
}
EdgeRanking lastRank = -1;
EdgeRanking lastRank = -1;
VertexID lastDstId = 0;
bool firstLoop = true;
for (; iter->valid(); iter->next()) {
auto key = iter->key();
auto val = iter->val();
auto rank = KeyUtils::getRank(key);
if (rank == lastRank) {
auto dstId = KeyUtils::getDstId(key);
if (!firstLoop && rank == lastRank && lastDstId == dstId) {
VLOG(3) << "Only get the latest version for each edge.";
continue;
}
lastRank = rank;
lastDstId = dstId;
std::unique_ptr<RowReader> reader;
if (type_ == BoundType::OUT_BOUND && !val.empty()) {
reader = RowReader::getEdgePropReader(this->schemaMan_, val, spaceId_, edgeType);
}
proc(reader.get(), key, props);
if (firstLoop) {
firstLoop = false;
}
}
return ret;
}
Expand Down
6 changes: 3 additions & 3 deletions src/storage/test/QueryBoundTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void mockData(kvstore::KVStore* kv) {
// Write multi versions, we should get the latest version.
for (auto version = 0; version < 3; version++) {
auto key = KeyUtils::edgeKey(partId, vertexId, 101,
dstId - 10001, dstId,
0, dstId,
std::numeric_limits<int>::max() - version);
RowWriter writer(nullptr);
for (uint64_t numInt = 0; numInt < 10; numInt++) {
Expand All @@ -58,7 +58,7 @@ void mockData(kvstore::KVStore* kv) {
VLOG(3) << "Write part " << partId << ", vertex " << vertexId << ", src " << srcId;
for (auto version = 0; version < 3; version++) {
auto key = KeyUtils::edgeKey(partId, vertexId, -101,
srcId - 20001, srcId,
0, srcId,
std::numeric_limits<int>::max() - version);
data.emplace_back(std::move(key), "");
}
Expand Down Expand Up @@ -147,7 +147,7 @@ void checkResponse(cpp2::QueryResponse& resp, bool outBound = true) {
// _rank
int64_t v;
EXPECT_EQ(ResultType::SUCCEEDED, it->getInt<int64_t>(1, v));
CHECK_EQ(rowNum, v);
CHECK_EQ(0, v);
}
if (outBound) {
// col_0, col_2 ... col_8
Expand Down

0 comments on commit ef7f604

Please sign in to comment.