Skip to content

Commit

Permalink
rebase master
Browse files Browse the repository at this point in the history
  • Loading branch information
ayyt committed Sep 26, 2019
1 parent 158e8de commit 791c2e3
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 30 deletions.
4 changes: 0 additions & 4 deletions src/dataman/RowReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,6 @@ class RowReader {
// TODO getMap(const std::string& name) const noexcept;
// TODO getMap(int64_t index) const noexcept;

const meta::SchemaProviderIf* getSchema() const noexcept {
return schema_.get();
}

folly::StringPiece getData() const noexcept {
return data_;
}
Expand Down
10 changes: 3 additions & 7 deletions src/storage/QueryBaseProcessor.inl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ cpp2::ErrorCode QueryBaseProcessor<REQ, RESP>::checkAndBuildContexts(const REQ&

template<typename REQ, typename RESP>
bool QueryBaseProcessor<REQ, RESP>::checkDataExpiredForTTL(RowReader* reader) {
const meta::SchemaProviderIf* schema = reader->getSchema();
auto schema = reader->getSchema();
const nebula::cpp2::SchemaProp schemaProp = schema->getProp();
int ttlDuration = 0;
if (schemaProp.get_ttl_duration()) {
Expand All @@ -193,8 +193,9 @@ bool QueryBaseProcessor<REQ, RESP>::checkDataExpiredForTTL(RowReader* reader) {

int64_t v;
switch (ftype.type) {
case nebula::cpp2::SupportedType::TIMESTAMP:
case nebula::cpp2::SupportedType::INT: {
auto ret = reader->getInt<int64_t>(ttlCol, v);
auto ret = reader->getInt<int64_t>(ttlCol, v);
CHECK(ret == ResultType::SUCCEEDED);
break;
}
Expand All @@ -203,11 +204,6 @@ bool QueryBaseProcessor<REQ, RESP>::checkDataExpiredForTTL(RowReader* reader) {
CHECK(ret == ResultType::SUCCEEDED);
break;
}
case nebula::cpp2::SupportedType::TIMESTAMP: {
auto ret = reader->getTimestamp(ttlCol, v);
CHECK(ret == ResultType::SUCCEEDED);
break;
}
default: {
VLOG(1) << "Unsupport TTL column type";
break;
Expand Down
2 changes: 1 addition & 1 deletion src/storage/test/QueryBoundBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ cpp2::GetNeighborsRequest buildRequest(bool outBound = true) {
// Return tag props col_0, col_2, col_4
decltype(req.return_columns) tmpColumns;
for (int i = 0; i < 3; i++) {
tmpColumns.emplace_back(TestUtils::vetexPropDef(
tmpColumns.emplace_back(TestUtils::vertexPropDef(
folly::stringPrintf("tag_%d_col_%d", 3001 + i * 2, i * 2), 3001 + i * 2));
}
tmpColumns.emplace_back(
Expand Down
2 changes: 1 addition & 1 deletion src/storage/test/QueryBoundTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void buildRequest(cpp2::GetNeighborsRequest& req, const std::vector<EdgeType>& e
// Return tag props col_0, col_2, col_4
decltype(req.return_columns) tmpColumns;
for (int i = 0; i < 3; i++) {
tmpColumns.emplace_back(TestUtils::vetexPropDef(
tmpColumns.emplace_back(TestUtils::vertexPropDef(
folly::stringPrintf("tag_%d_col_%d", 3001 + i * 2, i * 2), 3001 + i * 2));
}

Expand Down
2 changes: 1 addition & 1 deletion src/storage/test/QueryStatsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void buildRequest(cpp2::GetNeighborsRequest& req) {
decltype(req.return_columns) tmpColumns;
for (int i = 0; i < 2; i++) {
tmpColumns.emplace_back(
TestUtils::vetexPropDef(folly::stringPrintf("tag_%d_col_%d", 3001 + i * 2, i * 2),
TestUtils::vertexPropDef(folly::stringPrintf("tag_%d_col_%d", 3001 + i * 2, i * 2),
cpp2::StatType::AVG, 3001 + i * 2));
}
// Return edge props col_0, col_2, col_4 ... col_18
Expand Down
29 changes: 20 additions & 9 deletions src/storage/test/QueryVertexPropsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ TEST(QueryVertexPropsTest, SimpleTest) {
// Return tag props col_0, col_2, col_4
decltype(req.return_columns) tmpColumns;
for (int i = 0; i < 3; i++) {
tmpColumns.emplace_back(TestUtils::vetexPropDef(
tmpColumns.emplace_back(TestUtils::vertexPropDef(
folly::stringPrintf("tag_%d_col_%d", 3001 + i * 2, i * 2), 3001 + i * 2));
}
req.set_return_columns(std::move(tmpColumns));
Expand Down Expand Up @@ -130,13 +130,17 @@ TEST(QueryVertexPropsTest, TTLTest) {
auto val = writer.encode();
data.emplace_back(std::move(key), std::move(val));
}

folly::Baton<true, std::atomic> baton;
kv->asyncMultiPut(
0,
partId,
std::move(data),
[&](kvstore::ResultCode code) {
EXPECT_EQ(code, kvstore::ResultCode::SUCCEEDED);
baton.post();
});
baton.wait();
}

LOG(INFO) << "Build VertexPropsRequest...";
Expand All @@ -153,9 +157,8 @@ TEST(QueryVertexPropsTest, TTLTest) {
req.set_parts(std::move(tmpIds));
// Return tag props col_0
decltype(req.return_columns) tmpColumns;
tmpColumns.emplace_back(TestUtils::propDef(cpp2::PropOwner::SOURCE,
folly::stringPrintf("tag_%d_col_%d", 3001, 0),
3001));
tmpColumns.emplace_back(TestUtils::vertexPropDef(
folly::stringPrintf("tag_%d_col_%d", 3001, 0), 3001));
req.set_return_columns(std::move(tmpColumns));

LOG(INFO) << "Test QueryVertexPropsRequest...";
Expand All @@ -170,14 +173,22 @@ TEST(QueryVertexPropsTest, TTLTest) {
LOG(INFO) << "Check the results...";
EXPECT_EQ(0, resp.result.failed_codes.size());

EXPECT_EQ(1, resp.vertex_schema.columns.size());
auto tagProvider = std::make_shared<ResultSchemaProvider>(resp.vertex_schema);
EXPECT_EQ(30, resp.vertices.size());

auto* vschema = resp.get_vertex_schema();
DCHECK(vschema != nullptr);

for (auto& vp : resp.vertices) {
auto tagReader = RowReader::getRowReader(vp.vertex_data, tagProvider);
EXPECT_EQ(1, tagReader->numFields());
EXPECT_EQ(0, tagReader->getData().size());
auto it = std::find_if(vp.tag_data.cbegin(), vp.tag_data.cend(), [](auto& td) {
if (td.tag_id == 3001) {
return true;
}
return false;
});

DCHECK(it == vp.tag_data.cend());
auto it2 = vschema->find(3001);
DCHECK(it2 != vschema->end());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/storage/test/StorageClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ TEST(StorageClientTest, VerticesInterfacesTest) {
vIds.emplace_back(vId);
}
for (int i = 0; i < 3; i++) {
retCols.emplace_back(TestUtils::vetexPropDef(
retCols.emplace_back(TestUtils::vertexPropDef(
folly::stringPrintf("tag_%d_col_%d", 3001 + i * 2, i * 2), 3001 + i * 2));
}
auto f = client->getVertexProps(spaceId, std::move(vIds), std::move(retCols));
Expand Down Expand Up @@ -314,7 +314,7 @@ TEST(StorageClientTest, VerticesInterfacesTest) {
std::vector<VertexID> vIds{srcId};
std::vector<cpp2::PropDef> retCols;
retCols.emplace_back(
TestUtils::vetexPropDef(folly::stringPrintf("tag_%d_col_%d", 3001, 0), 3001));
TestUtils::vertexPropDef(folly::stringPrintf("tag_%d_col_%d", 3001, 0), 3001));
auto cf = client->getVertexProps(spaceId, std::move(vIds), std::move(retCols));
auto cresp = std::move(cf).get();
ASSERT_TRUE(cresp.succeeded());
Expand Down
10 changes: 5 additions & 5 deletions src/storage/test/TestUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ class TestUtils {
auto* schemaMan = new AdHocSchemaManager();
for (auto edgeType = 101; edgeType < 110; edgeType++) {
schemaMan->addEdgeSchema(spaceId /*space id*/,
edgeType /*edge type*/,
edgeType /*edge type*/,
TestUtils::genEdgeSchemaProvider(10, 10));
}

for (auto tagId = 3001; tagId < 3010; tagId++) {
for (auto tagId = 3001; tagId < 3010; tagId++) {
schemaMan->addTagSchema(spaceId /*space id*/,
tagId,
TestUtils::genTagSchemaProvider(tagId, 3, 3));
Expand Down Expand Up @@ -204,7 +204,7 @@ class TestUtils {
return std::make_shared<ResultSchemaProvider>(std::move(schema));
}

static cpp2::PropDef vetexPropDef(std::string name, TagID tagId) {
static cpp2::PropDef vertexPropDef(std::string name, TagID tagId) {
cpp2::PropDef prop;
prop.set_name(std::move(name));
prop.set_owner(cpp2::PropOwner::SOURCE);
Expand Down Expand Up @@ -248,8 +248,8 @@ class TestUtils {
return prop;
}

static cpp2::PropDef vetexPropDef(std::string name, cpp2::StatType type, TagID tagId) {
auto prop = TestUtils::vetexPropDef(std::move(name), tagId);
static cpp2::PropDef vertexPropDef(std::string name, cpp2::StatType type, TagID tagId) {
auto prop = TestUtils::vertexPropDef(std::move(name), tagId);
prop.set_stat(type);
return prop;
}
Expand Down

0 comments on commit 791c2e3

Please sign in to comment.