fork of https://github.com/oxigraph/rocksdb and https://github.com/facebook/rocksdb for nextgraph and oxigraph
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.4 KiB
70 lines
2.4 KiB
8 years ago
|
// Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
|
||
8 years ago
|
// This source code is licensed under the BSD-style license found in the
|
||
|
// LICENSE file in the root directory of this source tree. An additional grant
|
||
|
// of patent rights can be found in the PATENTS file in the same directory.
|
||
8 years ago
|
// This source code is also licensed under the GPLv2 license found in the
|
||
|
// COPYING file in the root directory of this source tree.
|
||
|
|
||
|
#include "test_utils.h"
|
||
|
|
||
|
namespace rocksdb {
|
||
|
namespace cassandra {
|
||
|
const char kData[] = {'d', 'a', 't', 'a'};
|
||
|
const char kExpiringData[] = {'e', 'd', 'a', 't', 'a'};
|
||
|
const int32_t kLocalDeletionTime = 1;
|
||
8 years ago
|
const int32_t kTtl = 86400;
|
||
8 years ago
|
const int8_t kColumn = 0;
|
||
|
const int8_t kTombstone = 1;
|
||
|
const int8_t kExpiringColumn = 2;
|
||
|
|
||
8 years ago
|
std::shared_ptr<ColumnBase> CreateTestColumn(int8_t mask,
|
||
8 years ago
|
int8_t index,
|
||
|
int64_t timestamp) {
|
||
|
if ((mask & ColumnTypeMask::DELETION_MASK) != 0) {
|
||
8 years ago
|
return std::shared_ptr<Tombstone>(new Tombstone(
|
||
8 years ago
|
mask, index, kLocalDeletionTime, timestamp));
|
||
|
} else if ((mask & ColumnTypeMask::EXPIRATION_MASK) != 0) {
|
||
8 years ago
|
return std::shared_ptr<ExpiringColumn>(new ExpiringColumn(
|
||
8 years ago
|
mask, index, timestamp, sizeof(kExpiringData), kExpiringData, kTtl));
|
||
|
} else {
|
||
8 years ago
|
return std::shared_ptr<Column>(
|
||
8 years ago
|
new Column(mask, index, timestamp, sizeof(kData), kData));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
RowValue CreateTestRowValue(
|
||
|
std::vector<std::tuple<int8_t, int8_t, int64_t>> column_specs) {
|
||
8 years ago
|
std::vector<std::shared_ptr<ColumnBase>> columns;
|
||
8 years ago
|
int64_t last_modified_time = 0;
|
||
|
for (auto spec: column_specs) {
|
||
|
auto c = CreateTestColumn(std::get<0>(spec), std::get<1>(spec),
|
||
|
std::get<2>(spec));
|
||
|
last_modified_time = std::max(last_modified_time, c -> Timestamp());
|
||
|
columns.push_back(std::move(c));
|
||
|
}
|
||
|
return RowValue(std::move(columns), last_modified_time);
|
||
|
}
|
||
|
|
||
|
RowValue CreateRowTombstone(int64_t timestamp) {
|
||
|
return RowValue(kLocalDeletionTime, timestamp);
|
||
|
}
|
||
|
|
||
|
void VerifyRowValueColumns(
|
||
8 years ago
|
std::vector<std::shared_ptr<ColumnBase>> &columns,
|
||
8 years ago
|
std::size_t index_of_vector,
|
||
|
int8_t expected_mask,
|
||
|
int8_t expected_index,
|
||
|
int64_t expected_timestamp
|
||
|
) {
|
||
|
EXPECT_EQ(expected_timestamp, columns[index_of_vector]->Timestamp());
|
||
|
EXPECT_EQ(expected_mask, columns[index_of_vector]->Mask());
|
||
|
EXPECT_EQ(expected_index, columns[index_of_vector]->Index());
|
||
|
}
|
||
|
|
||
8 years ago
|
int64_t ToMicroSeconds(int64_t seconds) {
|
||
|
return seconds * (int64_t)1000000;
|
||
|
}
|
||
|
|
||
8 years ago
|
}
|
||
|
}
|