Skip to content

Commit

Permalink
address laura-ding's comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ayyt committed Jun 12, 2019
1 parent 5a61e43 commit 4f687cf
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/graph/AlterEdgeExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Status AlterEdgeExecutor::prepare() {
alterSchemaProp.set_value(folly::to<std::string>(retInt.value()));
break;
case SchemaPropItem::TTL_COL:
// The legality of the column name need be to check in meta
// Check the legality of the column in meta
retStr = schemaProp->getTtlCol();
if (!retStr.ok()) {
return retStr.status();
Expand Down
2 changes: 1 addition & 1 deletion src/graph/AlterTagExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Status AlterTagExecutor::prepare() {
alterSchemaProp.set_value(folly::to<std::string>(retInt.value()));
break;
case SchemaPropItem::TTL_COL:
// The legality of the column name need be to check in meta
// Check the legality of ttl_col in meta
retStr = schemaProp->getTtlCol();
if (!retStr.ok()) {
return retStr.status();
Expand Down
15 changes: 8 additions & 7 deletions src/graph/CreateEdgeExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ Status CreateEdgeExecutor::prepare() {
schema_.columns.emplace_back(std::move(column));
}

// set schema_.schema_prop default
// 0 means infinity
schema_.schema_prop.set_ttl_duration(0);
schema_.schema_prop.set_ttl_col("");

if (schemaProps.size() != 0) {
for (auto& schemaProp : schemaProps) {
switch (schemaProp->getPropType()) {
Expand All @@ -59,9 +54,10 @@ Status CreateEdgeExecutor::prepare() {
if (schema_.schema_prop.ttl_duration != 0) {
// Disable implicit TTL mode
if (schema_.schema_prop.ttl_col.empty()) {
return Status::Error("implicit ttl_col not support");
return Status::Error("Implicit ttl_col not support");
}

// 0 means infinity
if (schema_.schema_prop.ttl_duration < 0) {
schema_.schema_prop.set_ttl_duration(0);
}
Expand Down Expand Up @@ -91,9 +87,14 @@ Status CreateEdgeExecutor::setTTLCol(SchemaPropItem* schemaProp) {
}

auto ttlColName = ret.value();
// check the legality of the ttl column name
// Check the legality of the ttl column name
for (auto& col : schema_.columns) {
if (col.name == ttlColName) {
// Only integer columns and timestamp columns can be used as ttl_col
if (col.type.type != nebula::cpp2::SupportedType::INT &&
col.type.type != nebula::cpp2::SupportedType::TIMESTAMP) {
return Status::Error("Ttl column type illegal");
}
schema_.schema_prop.set_ttl_col(ttlColName);
return Status::OK();
}
Expand Down
15 changes: 8 additions & 7 deletions src/graph/CreateTagExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ Status CreateTagExecutor::prepare() {
schema_.columns.emplace_back(std::move(column));
}

// set schema_.schema_prop default
// 0 means infinity
schema_.schema_prop.set_ttl_duration(0);
schema_.schema_prop.set_ttl_col("");

if (schemaProps.size() != 0) {
for (auto& schemaProp : schemaProps) {
switch (schemaProp->getPropType()) {
Expand All @@ -60,9 +55,10 @@ Status CreateTagExecutor::prepare() {
if (schema_.schema_prop.ttl_duration != 0) {
// Disable implicit TTL mode
if (schema_.schema_prop.ttl_col.empty()) {
return Status::Error("implicit ttl_col not support");
return Status::Error("Implicit ttl_col not support");
}

// 0 means infinity
if (schema_.schema_prop.ttl_duration < 0) {
schema_.schema_prop.set_ttl_duration(0);
}
Expand Down Expand Up @@ -92,9 +88,14 @@ Status CreateTagExecutor::setTTLCol(SchemaPropItem* schemaProp) {
}

auto ttlColName = ret.value();
// check the legality of the ttl column name
// Check the legality of the ttl column name
for (auto& col : schema_.columns) {
if (col.name == ttlColName) {
// Only integer columns and timestamp columns can be used as ttl_col
if (col.type.type != nebula::cpp2::SupportedType::INT &&
col.type.type != nebula::cpp2::SupportedType::TIMESTAMP) {
return Status::Error("Ttl column type illegal");
}
schema_.schema_prop.set_ttl_col(ttlColName);
return Status::OK();
}
Expand Down
Loading

0 comments on commit 4f687cf

Please sign in to comment.