Skip to content

Commit

Permalink
change time point calculate in ttl (#4683)
Browse files Browse the repository at this point in the history
* change time point calculate in ttl

* fix ttl test

* enlarge the ttl sleep interval in the test

* fix ttl in index

* Revert "enlarge the ttl sleep interval in the test"

This reverts commit e37bf51.

* change wall time in mock data

Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>
  • Loading branch information
pengweisong and Sophie-Xie authored Oct 9, 2022
1 parent 444a1f1 commit 42b0c9e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
7 changes: 3 additions & 4 deletions src/mock/MockData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "mock/MockData.h"

#include "common/expression/ConstantExpression.h"
#include "common/time/WallClock.h"
#include "common/utils/IndexKeyUtils.h"
#include "interface/gen-cpp2/meta_types.h"

Expand Down Expand Up @@ -686,7 +685,7 @@ std::vector<VertexData> MockData::mockVertices(bool upper) {

// Use insert time as ttl col
if (FLAGS_mock_ttl_col) {
props.emplace_back(time::WallClock::fastNowInSec());
props.emplace_back(std::time(NULL));
}
// Use default value and nullable
if (player.country_.compare("") != 0) {
Expand Down Expand Up @@ -809,7 +808,7 @@ std::vector<EdgeData> MockData::mockEdges(bool upper, bool hasInEdges) {

// Use insert time as ttl col
if (FLAGS_mock_ttl_col) {
props.emplace_back(time::WallClock::fastNowInSec());
props.emplace_back(std::time(NULL));
}
// Use default value and nullable
if (!serve.type_.empty()) {
Expand Down Expand Up @@ -929,7 +928,7 @@ std::unordered_map<VertexID, std::vector<EdgeData>> MockData::mockmMultiRankServ

// Use insert time as ttl col
if (FLAGS_mock_ttl_col) {
props.emplace_back(time::WallClock::fastNowInSec());
props.emplace_back(std::time(NULL));
}
// Use default value and nullable
if (!serve.type_.empty()) {
Expand Down
4 changes: 1 addition & 3 deletions src/storage/CommonUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#include "storage/CommonUtils.h"

#include "common/time/WallClock.h"

namespace nebula {
namespace storage {

Expand All @@ -27,7 +25,7 @@ bool CommonUtils::checkDataExpiredForTTL(const meta::SchemaProviderIf* schema,
ftype != nebula::cpp2::PropertyType::INT64) {
return false;
}
auto now = time::WallClock::fastNowInSec();
auto now = std::time(NULL);

// if the value is not INT type (sush as NULL), it will never expire.
// TODO (sky) : DateTime
Expand Down
22 changes: 11 additions & 11 deletions src/storage/test/IndexWithTTLTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int64_t verifyResultNum(GraphSpaceID spaceId,
std::unique_ptr<kvstore::KVIterator> iter;
EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, kv->prefix(spaceId, partId, prefix, &iter));
int64_t rowCount = 0;
auto now = time::WallClock::fastNowInSec();
auto now = std::time(NULL);
while (iter->valid()) {
if (ts > 0) {
EXPECT_TRUE(!iter->val().empty());
Expand Down Expand Up @@ -111,7 +111,7 @@ void insertVertex(storage::StorageEnv* env, size_t vIdLen, TagID tagId) {
newTag.tag_id_ref() = tagId;
std::vector<Value> props;
props.emplace_back(Value(1L));
props.emplace_back(Value(time::WallClock::fastNowInSec()));
props.emplace_back(Value(std::time(NULL)));
newTag.props_ref() = std::move(props);
std::vector<nebula::storage::cpp2::NewTag> newTags;
newTags.push_back(std::move(newTag));
Expand Down Expand Up @@ -140,7 +140,7 @@ void insertEdge(storage::StorageEnv* env, size_t vIdLen, EdgeType edgeType) {
newEdge.key_ref() = std::move(edgeKey);
std::vector<Value> props;
props.emplace_back(Value(1L));
props.emplace_back(Value(time::WallClock::fastNowInSec()));
props.emplace_back(Value(std::time(NULL)));
newEdge.props_ref() = std::move(props);
(*req.parts_ref())[partId].emplace_back(newEdge);
(*newEdge.key_ref()).edge_type_ref() = -edgeType;
Expand All @@ -160,7 +160,7 @@ TEST(IndexWithTTLTest, AddVerticesIndexWithTTL) {
auto* env = cluster.storageEnv_.get();
auto vIdLen = env->schemaMan_->getSpaceVidLen(1).value();

auto beginTime = time::WallClock::fastNowInSec();
auto beginTime = std::time(NULL);
createSchema(env->schemaMan_, 2021001, 1, false);
createIndex(env->indexMan_, 2021001, 2021002, false);
insertVertex(env, vIdLen, 2021001);
Expand Down Expand Up @@ -207,7 +207,7 @@ TEST(IndexWithTTLTest, AddEdgesIndexWithTTL) {
auto* env = cluster.storageEnv_.get();
auto vIdLen = env->schemaMan_->getSpaceVidLen(1).value();

auto beginTime = time::WallClock::fastNowInSec();
auto beginTime = std::time(NULL);
createSchema(env->schemaMan_, 2021001, 1, true);
createIndex(env->indexMan_, 2021001, 2021002, true);
insertEdge(env, vIdLen, 2021001);
Expand Down Expand Up @@ -254,7 +254,7 @@ TEST(IndexWithTTLTest, UpdateVerticesIndexWithTTL) {
auto* env = cluster.storageEnv_.get();
auto vIdLen = env->schemaMan_->getSpaceVidLen(1).value();

auto beginTime = time::WallClock::fastNowInSec();
auto beginTime = std::time(NULL);
createSchema(env->schemaMan_, 2021001, 1800, false);
createIndex(env->indexMan_, 2021001, 2021002, false);
insertVertex(env, vIdLen, 2021001);
Expand Down Expand Up @@ -325,7 +325,7 @@ TEST(IndexWithTTLTest, UpdateEdgesIndexWithTTL) {
auto* env = cluster.storageEnv_.get();
auto vIdLen = env->schemaMan_->getSpaceVidLen(1).value();

auto beginTime = time::WallClock::fastNowInSec();
auto beginTime = std::time(NULL);
createSchema(env->schemaMan_, 2021001, 1800, true);
createIndex(env->indexMan_, 2021001, 2021002, true);
insertEdge(env, vIdLen, 2021001);
Expand Down Expand Up @@ -402,7 +402,7 @@ TEST(IndexWithTTLTest, RebuildTagIndexWithTTL) {
auto* env = cluster.storageEnv_.get();
auto vIdLen = env->schemaMan_->getSpaceVidLen(1).value();

auto beginTime = time::WallClock::fastNowInSec();
auto beginTime = std::time(NULL);
createSchema(env->schemaMan_, 2021001, 180000, false);
insertVertex(env, vIdLen, 2021001);

Expand Down Expand Up @@ -471,7 +471,7 @@ TEST(IndexWithTTLTest, RebuildEdgeIndexWithTTL) {
auto* env = cluster.storageEnv_.get();
auto vIdLen = env->schemaMan_->getSpaceVidLen(1).value();

auto beginTime = time::WallClock::fastNowInSec();
auto beginTime = std::time(NULL);
createSchema(env->schemaMan_, 2021001, 180000, true);
insertEdge(env, vIdLen, 2021001);

Expand Down Expand Up @@ -540,7 +540,7 @@ TEST(IndexWithTTLTest, RebuildTagIndexWithTTLExpired) {
auto* env = cluster.storageEnv_.get();
auto vIdLen = env->schemaMan_->getSpaceVidLen(1).value();

auto beginTime = time::WallClock::fastNowInSec();
auto beginTime = std::time(NULL);
createSchema(env->schemaMan_, 2021001, 1, false);
insertVertex(env, vIdLen, 2021001);

Expand Down Expand Up @@ -611,7 +611,7 @@ TEST(IndexWithTTLTest, RebuildEdgeIndexWithTTLExpired) {
auto* env = cluster.storageEnv_.get();
auto vIdLen = env->schemaMan_->getSpaceVidLen(1).value();

auto beginTime = time::WallClock::fastNowInSec();
auto beginTime = std::time(NULL);
createSchema(env->schemaMan_, 2021001, 1, true);
insertEdge(env, vIdLen, 2021001);

Expand Down
4 changes: 2 additions & 2 deletions src/storage/test/QueryTestUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class QueryTestUtils {
}
auto indexes =
IndexKeyUtils::vertexIndexKeys(spaceVidLen, partId, indexId, vId, {std::move(row)});
auto val = FLAGS_mock_ttl_col ? IndexKeyUtils::indexVal(time::WallClock::fastNowInSec()) : "";
auto val = FLAGS_mock_ttl_col ? IndexKeyUtils::indexVal(std::time(NULL)) : "";
for (auto& index : indexes) {
data.emplace_back(std::move(index), std::move(val));
}
Expand All @@ -287,7 +287,7 @@ class QueryTestUtils {
}
auto indexes = IndexKeyUtils::edgeIndexKeys(
spaceVidLen, partId, indexId, srcId, rank, dstId, {std::move(row)});
auto val = FLAGS_mock_ttl_col ? IndexKeyUtils::indexVal(time::WallClock::fastNowInSec()) : "";
auto val = FLAGS_mock_ttl_col ? IndexKeyUtils::indexVal(std::time(NULL)) : "";
for (auto& index : indexes) {
data.emplace_back(std::move(index), val);
}
Expand Down

0 comments on commit 42b0c9e

Please sign in to comment.