Convert existing tuple usages to use Tuple::makeTuple()

This commit is contained in:
A.J. Beamon 2022-07-19 13:45:59 -07:00
parent 1b81e72604
commit 190ad8c7e9
21 changed files with 78 additions and 155 deletions

View File

@ -941,13 +941,13 @@ static Value dataOfRecord(const int i) {
return Value(format("data-of-record-%08d", i));
}
static std::string indexEntryKey(const int i) {
return Tuple().append(StringRef(prefix)).append(INDEX).append(indexKey(i)).append(primaryKey(i)).pack().toString();
return Tuple::makeTuple(prefix, INDEX, indexKey(i), primaryKey(i)).pack().toString();
}
static std::string recordKey(const int i, const int split) {
return Tuple().append(prefix).append(RECORD).append(primaryKey(i)).append(split).pack().toString();
return Tuple::makeTuple(prefix, RECORD, primaryKey(i), split).pack().toString();
}
static std::string recordValue(const int i, const int split) {
return Tuple().append(dataOfRecord(i)).append(split).pack().toString();
return Tuple::makeTuple(dataOfRecord(i), split).pack().toString();
}
const static int SPLIT_SIZE = 3;
@ -993,13 +993,8 @@ GetMappedRangeResult getMappedIndexEntries(int beginId,
fdb::Transaction& tr,
int matchIndex,
bool allMissing) {
std::string mapper = Tuple()
.append(prefix)
.append(RECORD)
.append(allMissing ? "{K[2]}"_sr : "{K[3]}"_sr)
.append("{...}"_sr)
.pack()
.toString();
std::string mapper =
Tuple::makeTuple(prefix, RECORD, (allMissing ? "{K[2]}"_sr : "{K[3]}"_sr), "{...}"_sr).pack().toString();
return getMappedIndexEntries(beginId, endId, tr, mapper, matchIndex);
}
@ -1037,7 +1032,7 @@ TEST_CASE("tuple_support_versionstamp") {
// a random 12 bytes long StringRef as a versionstamp
StringRef str = "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12"_sr;
Versionstamp vs(str);
const Tuple t = Tuple().append(prefix).append(RECORD).append(vs).append("{K[3]}"_sr).append("{...}"_sr);
const Tuple t = Tuple::makeTuple(prefix, RECORD, vs, "{K[3]}"_sr, "{...}"_sr);
ASSERT(t.getVersionstamp(2) == vs);
// verify the round-way pack-unpack path for a Tuple containing a versionstamp
@ -1181,7 +1176,7 @@ TEST_CASE("fdb_transaction_get_mapped_range_missing_all_secondary") {
}
TEST_CASE("fdb_transaction_get_mapped_range_restricted_to_serializable") {
std::string mapper = Tuple().append(prefix).append(RECORD).append("{K[3]}"_sr).pack().toString();
std::string mapper = Tuple::makeTuple(prefix, RECORD, "{K[3]}"_sr).pack().toString();
fdb::Transaction tr(db);
auto result = get_mapped_range(
tr,
@ -1200,7 +1195,7 @@ TEST_CASE("fdb_transaction_get_mapped_range_restricted_to_serializable") {
}
TEST_CASE("fdb_transaction_get_mapped_range_restricted_to_ryw_enable") {
std::string mapper = Tuple().append(prefix).append(RECORD).append("{K[3]}"_sr).pack().toString();
std::string mapper = Tuple::makeTuple(prefix, RECORD, "{K[3]}"_sr).pack().toString();
fdb::Transaction tr(db);
fdb_check(tr.set_option(FDB_TR_OPTION_READ_YOUR_WRITES_DISABLE, nullptr, 0)); // Not disable RYW
auto result = get_mapped_range(

View File

@ -85,7 +85,7 @@ Values must always be encoded according to the :ref:`api-python-tuple-layer`.
const KeyRef myGlobalConfigKey = LiteralStringRef("config/key");
// When you want to set the value..
Tuple value = Tuple().append((double)1.5);
Tuple value = Tuple::makeTuple((double)1.5);
FDBTransaction* tr = ...;
tr->setOption(FDBTransactionOptions::SPECIAL_KEY_SPACE_ENABLE_WRITES);

View File

@ -97,8 +97,8 @@ ACTOR Future<bool> profileCommandActor(Database db,
}
}
Tuple rate = Tuple().append(sampleRate);
Tuple size = Tuple().append(sizeLimit);
Tuple rate = Tuple::makeTuple(sampleRate);
Tuple size = Tuple::makeTuple(sizeLimit);
tr->setOption(FDBTransactionOptions::SPECIAL_KEY_SPACE_ENABLE_WRITES);
tr->set(GlobalConfig::prefixedKey(fdbClientInfoTxnSampleRate), rate.pack());
tr->set(GlobalConfig::prefixedKey(fdbClientInfoTxnSizeLimit), size.pack());

View File

@ -144,10 +144,7 @@ std::string configDBTypeToString(ConfigDBType configDBType) {
}
TEST_CASE("/fdbclient/ConfigDB/ConfigKey/EncodeDecode") {
Tuple tuple;
tuple << "class-A"_sr
<< "test_long"_sr;
auto packed = tuple.pack();
auto packed = Tuple::makeTuple("class-A"_sr, "test_long"_sr).pack();
auto unpacked = ConfigKeyRef::decodeKey(packed);
ASSERT(unpacked.configClass.get() == "class-A"_sr);
ASSERT(unpacked.knobName == "test_long"_sr);
@ -169,18 +166,8 @@ void decodeFailureTest(KeyRef key) {
} // namespace
TEST_CASE("/fdbclient/ConfigDB/ConfigKey/DecodeFailure") {
{
Tuple tuple;
tuple << "s1"_sr
<< "s2"_sr
<< "s3"_sr;
decodeFailureTest(tuple.pack());
}
{
Tuple tuple;
tuple << "s1"_sr << 5;
decodeFailureTest(tuple.pack());
}
decodeFailureTest(Tuple::makeTuple("s1"_sr, "s2"_sr, "s3"_sr).pack());
decodeFailureTest(Tuple::makeTuple("s1"_sr, 5).pack());
decodeFailureTest("non-tuple-key"_sr);
return Void();
}

View File

@ -200,13 +200,7 @@ public:
Version endVersion{ ::invalidVersion }; // not meaningful for range files
Tuple pack() const {
return Tuple()
.append(version)
.append(StringRef(fileName))
.append((int)isRange)
.append(fileSize)
.append(blockSize)
.append(endVersion);
return Tuple::makeTuple(version, fileName, (int)isRange, fileSize, blockSize, endVersion);
}
static RestoreFile unpack(Tuple const& t) {
RestoreFile r;

View File

@ -183,13 +183,13 @@ ACTOR Future<Void> GlobalConfig::migrate(GlobalConfig* self) {
if (sampleRate.present()) {
const double sampleRateDbl =
BinaryReader::fromStringRef<double>(sampleRate.get().contents(), Unversioned());
Tuple rate = Tuple().append(sampleRateDbl);
Tuple rate = Tuple::makeTuple(sampleRateDbl);
tr->set(GlobalConfig::prefixedKey(fdbClientInfoTxnSampleRate), rate.pack());
}
if (sizeLimit.present()) {
const int64_t sizeLimitInt =
BinaryReader::fromStringRef<int64_t>(sizeLimit.get().contents(), Unversioned());
Tuple size = Tuple().append(sizeLimitInt);
Tuple size = Tuple::makeTuple(sizeLimitInt);
tr->set(GlobalConfig::prefixedKey(fdbClientInfoTxnSizeLimit), size.pack());
}

View File

@ -1132,10 +1132,9 @@ ACTOR static Future<Void> handleTssMismatches(DatabaseContext* cx) {
for (const DetailedTSSMismatch& d : data.second) {
// <tssid, time, mismatchid> -> mismatch data
tssMismatchDB.set(
tr,
Tuple().append(data.first.toString()).append(d.timestamp).append(d.mismatchId.toString()),
d.traceString);
tssMismatchDB.set(tr,
Tuple::makeTuple(data.first.toString(), d.timestamp, d.mismatchId.toString()),
d.traceString);
}
wait(tr->commit());

View File

@ -2005,7 +2005,7 @@ Future<Optional<std::string>> ClientProfilingImpl::commit(ReadYourWritesTransact
} else {
try {
double sampleRate = boost::lexical_cast<double>(sampleRateStr);
Tuple rate = Tuple().append(sampleRate);
Tuple rate = Tuple::makeTuple(sampleRate);
insertions.push_back_deep(insertions.arena(), KeyValueRef(fdbClientInfoTxnSampleRate, rate.pack()));
} catch (boost::bad_lexical_cast& e) {
return Optional<std::string>(ManagementAPIError::toJsonString(
@ -2024,7 +2024,7 @@ Future<Optional<std::string>> ClientProfilingImpl::commit(ReadYourWritesTransact
} else {
try {
int64_t sizeLimit = boost::lexical_cast<int64_t>(sizeLimitStr);
Tuple size = Tuple().append(sizeLimit);
Tuple size = Tuple::makeTuple(sizeLimit);
insertions.push_back_deep(insertions.arena(), KeyValueRef(fdbClientInfoTxnSizeLimit, size.pack()));
} catch (boost::bad_lexical_cast& e) {
return Optional<std::string>(ManagementAPIError::toJsonString(

View File

@ -141,12 +141,7 @@ bool ThrottleApi::TagQuotaValue::isValid() const {
}
Value ThrottleApi::TagQuotaValue::toValue() const {
Tuple tuple;
tuple.append(reservedReadQuota);
tuple.append(totalReadQuota);
tuple.append(reservedWriteQuota);
tuple.append(totalWriteQuota);
return tuple.pack();
return Tuple::makeTuple(reservedReadQuota, totalReadQuota, reservedWriteQuota, totalWriteQuota).pack();
}
ThrottleApi::TagQuotaValue ThrottleApi::TagQuotaValue::fromValue(ValueRef value) {

View File

@ -651,10 +651,7 @@ public:
Reference<Task> task) {
taskBucket->setOptions(tr);
Tuple t;
t.append(task->timeoutVersion);
t.append(task->key);
Tuple t = Tuple::makeTuple(task->timeoutVersion, task->key);
RangeResult values = wait(tr->getRange(taskBucket->timeouts.range(t), 1));
if (values.size() > 0)
return false;
@ -996,9 +993,7 @@ Future<bool> TaskBucket::isEmpty(Reference<ReadYourWritesTransaction> tr) {
Future<Void> TaskBucket::finish(Reference<ReadYourWritesTransaction> tr, Reference<Task> task) {
setOptions(tr);
Tuple t;
t.append(task->timeoutVersion);
t.append(task->key);
Tuple t = Tuple::makeTuple(task->timeoutVersion, task->key);
tr->atomicOp(prefix.pack(LiteralStringRef("task_count")),
LiteralStringRef("\xff\xff\xff\xff\xff\xff\xff\xff"),

View File

@ -361,7 +361,7 @@ public:
template <>
inline Standalone<StringRef> TupleCodec<FileBackupAgent::ERestoreState>::pack(
FileBackupAgent::ERestoreState const& val) {
return Tuple().append(static_cast<int>(val)).pack();
return Tuple::makeTuple(static_cast<int>(val)).pack();
}
template <>
inline FileBackupAgent::ERestoreState TupleCodec<FileBackupAgent::ERestoreState>::unpack(
@ -578,7 +578,7 @@ ACTOR Future<Void> cleanupBackup(Database cx, DeleteData deleteData);
using EBackupState = BackupAgentBase::EnumState;
template <>
inline Standalone<StringRef> TupleCodec<EBackupState>::pack(EBackupState const& val) {
return Tuple().append(static_cast<int>(val)).pack();
return Tuple::makeTuple(static_cast<int>(val)).pack();
}
template <>
inline EBackupState TupleCodec<EBackupState>::unpack(Standalone<StringRef> const& val) {
@ -727,8 +727,7 @@ protected:
template <>
inline Standalone<StringRef> TupleCodec<Reference<IBackupContainer>>::pack(Reference<IBackupContainer> const& bc) {
Tuple tuple;
tuple.append(StringRef(bc->getURL()));
Tuple tuple = Tuple::makeTuple(bc->getURL());
if (bc->getEncryptionKeyFileName().present()) {
tuple.append(bc->getEncryptionKeyFileName().get());
@ -775,9 +774,7 @@ public:
Version version;
std::string fileName;
int64_t fileSize;
Tuple pack() const {
return Tuple().append(begin).append(version).append(StringRef(fileName)).append(fileSize);
}
Tuple pack() const { return Tuple::makeTuple(begin, version, fileName, fileSize); }
static RangeSlice unpack(Tuple const& t) {
RangeSlice r;
int i = 0;

View File

@ -134,7 +134,7 @@ private:
if (!candidateValueFuture.get().present()) {
tr->addWriteConflictRange(singleKeyRange(self->recent.get(candidate).key()));
return Tuple().append(candidate).pack();
return Tuple::makeTuple(candidate).pack();
}
}
}

View File

@ -59,7 +59,7 @@ inline Tuple TupleCodec<Tuple>::unpack(Standalone<StringRef> const& val) {
template <>
inline Standalone<StringRef> TupleCodec<int64_t>::pack(int64_t const& val) {
return Tuple().append(val).pack();
return Tuple::makeTuple(val).pack();
}
template <>
inline int64_t TupleCodec<int64_t>::unpack(Standalone<StringRef> const& val) {
@ -68,7 +68,7 @@ inline int64_t TupleCodec<int64_t>::unpack(Standalone<StringRef> const& val) {
template <>
inline Standalone<StringRef> TupleCodec<bool>::pack(bool const& val) {
return Tuple().append(val ? 1 : 0).pack();
return Tuple::makeTuple(val ? 1 : 0).pack();
}
template <>
inline bool TupleCodec<bool>::unpack(Standalone<StringRef> const& val) {
@ -77,7 +77,7 @@ inline bool TupleCodec<bool>::unpack(Standalone<StringRef> const& val) {
template <>
inline Standalone<StringRef> TupleCodec<Standalone<StringRef>>::pack(Standalone<StringRef> const& val) {
return Tuple().append(val).pack();
return Tuple::makeTuple(val).pack();
}
template <>
inline Standalone<StringRef> TupleCodec<Standalone<StringRef>>::unpack(Standalone<StringRef> const& val) {
@ -96,7 +96,7 @@ inline UID TupleCodec<UID>::unpack(Standalone<StringRef> const& val) {
// This is backward compatible with TupleCodec<Standalone<StringRef>>
template <>
inline Standalone<StringRef> TupleCodec<std::string>::pack(std::string const& val) {
return Tuple().append(StringRef(val)).pack();
return Tuple::makeTuple(val).pack();
}
template <>
inline std::string TupleCodec<std::string>::unpack(Standalone<StringRef> const& val) {
@ -143,7 +143,7 @@ struct TupleCodec<std::vector<T>> {
template <>
inline Standalone<StringRef> TupleCodec<KeyRange>::pack(KeyRange const& val) {
return Tuple().append(val.begin).append(val.end).pack();
return Tuple::makeTuple(val.begin, val.end).pack();
}
template <>
inline KeyRange TupleCodec<KeyRange>::unpack(Standalone<StringRef> const& val) {

View File

@ -42,9 +42,7 @@ public:
template <class T>
Key pack(T const& item) const {
Tuple t;
t.append(item);
return pack(t);
return pack(Tuple::makeTuple(item));
}
Key pack(StringRef const& item, bool utf8 = false) const {
@ -58,9 +56,7 @@ public:
template <class T>
Subspace get(T const& item) const {
Tuple t;
t.append(item);
return get(t);
return get(Tuple::makeTuple(item));
}
Subspace get(StringRef const& item, bool utf8 = false) const {

View File

@ -40,13 +40,7 @@ struct MetricsRule {
int minLevel;
Tuple pack() const {
return Tuple()
.append(namePattern)
.append(typePattern)
.append(addressPattern)
.append(idPattern)
.append(enabled ? 1 : 0)
.append(minLevel);
return Tuple::makeTuple(namePattern, typePattern, addressPattern, idPattern, enabled ? 1 : 0, minLevel);
}
static inline MetricsRule unpack(Tuple const& t) {

View File

@ -112,13 +112,7 @@ public:
Tuple pack() const {
// fprintf(stderr, "Filename:%s\n", fileName.c_str());
return Tuple()
.append(version)
.append(StringRef(fileName))
.append((int)isRange)
.append(fileSize)
.append(blockSize)
.append(endVersion);
return Tuple::makeTuple(version, fileName, (int)isRange, fileSize, blockSize, endVersion);
}
static RestoreFile unpack(Tuple const& t) {
RestoreFile r;
@ -190,17 +184,16 @@ struct RestoreFileFR {
int partitionId = -1; // Partition ID (Log Router Tag ID) for mutation files.
Tuple pack() const {
return Tuple()
.append(version)
.append(StringRef(fileName))
.append((int)isRange)
.append(fileSize)
.append(blockSize)
.append(endVersion)
.append(beginVersion)
.append(cursor)
.append(fileIndex)
.append(partitionId);
return Tuple::makeTuple(version,
fileName,
(int)isRange,
fileSize,
blockSize,
endVersion,
beginVersion,
cursor,
fileIndex,
partitionId);
}
static RestoreFileFR unpack(Tuple const& t) {
RestoreFileFR r;

View File

@ -3675,9 +3675,7 @@ void preprocessMappedKey(Tuple& mappedKeyFormatTuple, std::vector<Optional<Tuple
bool escaped = unescapeLiterals(s, "{{", "{");
escaped = unescapeLiterals(s, "}}", "}") || escaped;
if (escaped) {
Tuple escapedTuple;
escapedTuple.append(s);
vt.emplace_back(escapedTuple);
vt.emplace_back(Tuple::makeTuple(s));
} else if (singleKeyOrValue(s, sz)) {
// when it is SingleKeyOrValue, insert an empty Tuple to vector as placeholder
vt.emplace_back(Tuple());
@ -3749,16 +3747,12 @@ Key constructMappedKey(KeyValueRef* keyValue,
}
TEST_CASE("/fdbserver/storageserver/constructMappedKey") {
Key key = Tuple().append("key-0"_sr).append("key-1"_sr).append("key-2"_sr).getDataAsStandalone();
Value value = Tuple().append("value-0"_sr).append("value-1"_sr).append("value-2"_sr).getDataAsStandalone();
Key key = Tuple::makeTuple("key-0"_sr, "key-1"_sr, "key-2"_sr).getDataAsStandalone();
Value value = Tuple::makeTuple("value-0"_sr, "value-1"_sr, "value-2"_sr).getDataAsStandalone();
state KeyValueRef kvr(key, value);
{
Tuple mappedKeyFormatTuple = Tuple()
.append("normal"_sr)
.append("{{escaped}}"_sr)
.append("{K[2]}"_sr)
.append("{V[0]}"_sr)
.append("{...}"_sr);
Tuple mappedKeyFormatTuple =
Tuple::makeTuple("normal"_sr, "{{escaped}}"_sr, "{K[2]}"_sr, "{V[0]}"_sr, "{...}"_sr);
Tuple mappedKeyTuple;
std::vector<Optional<Tuple>> vt;
@ -3767,19 +3761,15 @@ TEST_CASE("/fdbserver/storageserver/constructMappedKey") {
Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, mappedKeyFormatTuple);
Key expectedMappedKey = Tuple()
.append("normal"_sr)
.append("{escaped}"_sr)
.append("key-2"_sr)
.append("value-0"_sr)
.getDataAsStandalone();
Key expectedMappedKey =
Tuple::makeTuple("normal"_sr, "{escaped}"_sr, "key-2"_sr, "value-0"_sr).getDataAsStandalone();
// std::cout << printable(mappedKey) << " == " << printable(expectedMappedKey) << std::endl;
ASSERT(mappedKey.compare(expectedMappedKey) == 0);
ASSERT(isRangeQuery == true);
}
{
Tuple mappedKeyFormatTuple = Tuple().append("{{{{}}"_sr).append("}}"_sr);
Tuple mappedKeyFormatTuple = Tuple::makeTuple("{{{{}}"_sr, "}}"_sr);
Tuple mappedKeyTuple;
std::vector<Optional<Tuple>> vt;
@ -3787,13 +3777,13 @@ TEST_CASE("/fdbserver/storageserver/constructMappedKey") {
preprocessMappedKey(mappedKeyFormatTuple, vt, isRangeQuery);
Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, mappedKeyFormatTuple);
Key expectedMappedKey = Tuple().append("{{}"_sr).append("}"_sr).getDataAsStandalone();
Key expectedMappedKey = Tuple::makeTuple("{{}"_sr, "}"_sr).getDataAsStandalone();
// std::cout << printable(mappedKey) << " == " << printable(expectedMappedKey) << std::endl;
ASSERT(mappedKey.compare(expectedMappedKey) == 0);
ASSERT(isRangeQuery == false);
}
{
Tuple mappedKeyFormatTuple = Tuple().append("{{{{}}"_sr).append("}}"_sr);
Tuple mappedKeyFormatTuple = Tuple::makeTuple("{{{{}}"_sr, "}}"_sr);
Tuple mappedKeyTuple;
std::vector<Optional<Tuple>> vt;
@ -3801,13 +3791,13 @@ TEST_CASE("/fdbserver/storageserver/constructMappedKey") {
preprocessMappedKey(mappedKeyFormatTuple, vt, isRangeQuery);
Key mappedKey = constructMappedKey(&kvr, vt, mappedKeyTuple, mappedKeyFormatTuple);
Key expectedMappedKey = Tuple().append("{{}"_sr).append("}"_sr).getDataAsStandalone();
Key expectedMappedKey = Tuple::makeTuple("{{}"_sr, "}"_sr).getDataAsStandalone();
// std::cout << printable(mappedKey) << " == " << printable(expectedMappedKey) << std::endl;
ASSERT(mappedKey.compare(expectedMappedKey) == 0);
ASSERT(isRangeQuery == false);
}
{
Tuple mappedKeyFormatTuple = Tuple().append("{K[100]}"_sr);
Tuple mappedKeyFormatTuple = Tuple::makeTuple("{K[100]}"_sr);
state bool throwException = false;
try {
Tuple mappedKeyTuple;
@ -3823,7 +3813,7 @@ TEST_CASE("/fdbserver/storageserver/constructMappedKey") {
ASSERT(throwException);
}
{
Tuple mappedKeyFormatTuple = Tuple().append("{...}"_sr).append("last-element"_sr);
Tuple mappedKeyFormatTuple = Tuple::makeTuple("{...}"_sr, "last-element"_sr);
state bool throwException2 = false;
try {
Tuple mappedKeyTuple;
@ -3839,7 +3829,7 @@ TEST_CASE("/fdbserver/storageserver/constructMappedKey") {
ASSERT(throwException2);
}
{
Tuple mappedKeyFormatTuple = Tuple().append("{K[not-a-number]}"_sr);
Tuple mappedKeyFormatTuple = Tuple::makeTuple("{K[not-a-number]}"_sr);
state bool throwException3 = false;
try {
Tuple mappedKeyTuple;

View File

@ -294,8 +294,8 @@ struct ClientTransactionProfileCorrectnessWorkload : TestWorkload {
wait(runRYWTransaction(cx, [=](Reference<ReadYourWritesTransaction> tr) -> Future<Void> {
tr->setOption(FDBTransactionOptions::SPECIAL_KEY_SPACE_ENABLE_WRITES);
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
Tuple rate = Tuple().append(sampleProbability);
Tuple size = Tuple().append(sizeLimit);
Tuple rate = Tuple::makeTuple(sampleProbability);
Tuple size = Tuple::makeTuple(sizeLimit);
tr->set(GlobalConfig::prefixedKey(fdbClientInfoTxnSampleRate), rate.pack());
tr->set(GlobalConfig::prefixedKey(fdbClientInfoTxnSizeLimit), size.pack());
return Void();

View File

@ -36,12 +36,7 @@ class ConfigIncrementWorkload : public TestWorkload {
PerfIntCounter transactions, retries, commitUnknownResult;
static Key getConfigKey() {
Tuple tuple;
tuple.appendNull(); // config class
tuple << testKnobName;
return tuple.pack();
}
static Key getConfigKey() { return Tuple::makeTuple(/* config class */ nullptr, testKnobName).pack(); }
ACTOR static Future<int> get(Reference<ISingleThreadTransaction> tr) {
TraceEvent(SevDebug, "ConfigIncrementGet");

View File

@ -83,15 +83,11 @@ struct GetMappedRangeWorkload : ApiWorkload {
static Value dataOfRecord(int i) { return Key(format("data-of-record-%08d", i)); }
static Value dataOfRecord(int i, int split) { return Key(format("data-of-record-%08d-split-%08d", i, split)); }
static Key indexEntryKey(int i) {
return Tuple().append(prefix).append(INDEX).append(indexKey(i)).append(primaryKey(i)).pack();
}
static Key recordKey(int i) { return Tuple().append(prefix).append(RECORD).append(primaryKey(i)).pack(); }
static Key recordKey(int i, int split) {
return Tuple().append(prefix).append(RECORD).append(primaryKey(i)).append(split).pack();
}
static Value recordValue(int i) { return Tuple().append(dataOfRecord(i)).pack(); }
static Value recordValue(int i, int split) { return Tuple().append(dataOfRecord(i, split)).pack(); }
static Key indexEntryKey(int i) { return Tuple::makeTuple(prefix, INDEX, indexKey(i), primaryKey(i)).pack(); }
static Key recordKey(int i) { return Tuple::makeTuple(prefix, RECORD, primaryKey(i)).pack(); }
static Key recordKey(int i, int split) { return Tuple::makeTuple(prefix, RECORD, primaryKey(i), split).pack(); }
static Value recordValue(int i) { return Tuple::makeTuple(dataOfRecord(i)).pack(); }
static Value recordValue(int i, int split) { return Tuple::makeTuple(dataOfRecord(i, split)).pack(); }
ACTOR Future<Void> fillInRecords(Database cx, int n, GetMappedRangeWorkload* self) {
state Transaction tr(cx);
@ -270,9 +266,9 @@ struct GetMappedRangeWorkload : ApiWorkload {
GetMappedRangeWorkload* self,
int matchIndex,
bool allMissing = false) {
Key beginTuple = Tuple().append(prefix).append(INDEX).append(indexKey(beginId)).getDataAsStandalone();
Key beginTuple = Tuple::makeTuple(prefix, INDEX, indexKey(beginId)).getDataAsStandalone();
state KeySelector beginSelector = KeySelector(firstGreaterOrEqual(beginTuple));
Key endTuple = Tuple().append(prefix).append(INDEX).append(indexKey(endId)).getDataAsStandalone();
Key endTuple = Tuple::makeTuple(prefix, INDEX, indexKey(endId)).getDataAsStandalone();
state KeySelector endSelector = KeySelector(firstGreaterOrEqual(endTuple));
state int limit = 100;
state int expectedBeginId = beginId;
@ -322,9 +318,9 @@ struct GetMappedRangeWorkload : ApiWorkload {
Reference<TransactionWrapper>& tr,
GetMappedRangeWorkload* self) {
Key mapper = getMapper(self, false);
Key beginTuple = Tuple().append(prefix).append(INDEX).append(indexKey(beginId)).getDataAsStandalone();
Key beginTuple = Tuple::makeTuple(prefix, INDEX, indexKey(beginId)).getDataAsStandalone();
KeySelector beginSelector = KeySelector(firstGreaterOrEqual(beginTuple));
Key endTuple = Tuple().append(prefix).append(INDEX).append(indexKey(endId)).getDataAsStandalone();
Key endTuple = Tuple::makeTuple(prefix, INDEX, indexKey(endId)).getDataAsStandalone();
KeySelector endSelector = KeySelector(firstGreaterOrEqual(endTuple));
return tr->getMappedRange(beginSelector,
endSelector,

View File

@ -359,8 +359,7 @@ TEST_CASE("/fdbclient/TaskBucket/Subspace") {
print_subspace_key(subspace_test1, 1);
ASSERT(subspace_test1.key() == LiteralStringRef("abc"));
Tuple t;
t.append(LiteralStringRef("user"));
Tuple t = Tuple::makeTuple("user"_sr);
Subspace subspace_test2(t);
print_subspace_key(subspace_test2, 2);
ASSERT(subspace_test2.key() == LiteralStringRef("\x01user\x00"));
@ -369,8 +368,7 @@ TEST_CASE("/fdbclient/TaskBucket/Subspace") {
print_subspace_key(subspace_test3, 3);
ASSERT(subspace_test3.key() == LiteralStringRef("abc\x01user\x00"));
Tuple t1;
t1.append(1);
Tuple t1 = Tuple::makeTuple(1);
Subspace subspace_test4(t1);
print_subspace_key(subspace_test4, 4);
ASSERT(subspace_test4.key() == LiteralStringRef("\x15\x01"));
@ -400,8 +398,7 @@ TEST_CASE("/fdbclient/TaskBucket/Subspace") {
ASSERT(subspace_test8.key() == LiteralStringRef("\x01subitem\x00"));
// pack
Tuple t3;
t3.append(StringRef());
Tuple t3 = Tuple::makeTuple(""_sr);
printf("%d==========%s===%d\n", 10, printable(subspace_test5.pack(t3)).c_str(), subspace_test5.pack(t3).size());
ASSERT(subspace_test5.pack(t3) == subspace_test5.pack(StringRef()));
ASSERT(subspace_test5.pack(t3) == LiteralStringRef("abc\x01user\x00\x15\x7b\x01\x00"));