Commit 0ead6144 authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Make KeyDescriptors able to handle lease keys

parent fd00f12a
Pipeline #423188 passed with stages
in 38 minutes and 44 seconds
......@@ -59,6 +59,9 @@ inline KeyType parseKeyType(char c) {
case char(KeyType::kLocalityHash): {
return KeyType::kLocalityHash;
}
case char(KeyType::kLease): {
return KeyType::kLease;
}
default: {
return KeyType::kParseError;
}
......@@ -105,7 +108,8 @@ public:
// All done
return;
}
case KeyType::kList: {
case KeyType::kList:
case KeyType::kLease: {
qdb_assert(str.size() == kListDescriptorSize);
// Parse size.
......@@ -120,7 +124,7 @@ public:
return;
}
default: {
qdb_throw("error parsing key descriptor");
qdb_throw("error parsing key descriptor - unknown key type");
}
}
}
......@@ -139,12 +143,12 @@ public:
}
uint64_t getStartIndex() const {
qdb_assert(keyType == KeyType::kList);
qdb_assert(keyType == KeyType::kList || keyType == KeyType::kLease);
return startIndex;
}
uint64_t getEndIndex() const {
qdb_assert(keyType == KeyType::kList);
qdb_assert(keyType == KeyType::kList || keyType == KeyType::kLease);
return endIndex;
}
......@@ -158,12 +162,12 @@ public:
}
void setStartIndex(uint64_t newval) {
qdb_assert(keyType == KeyType::kList);
qdb_assert(keyType == KeyType::kList || keyType == KeyType::kLease);
startIndex = newval;
}
void setEndIndex(uint64_t newval) {
qdb_assert(keyType == KeyType::kList);
qdb_assert(keyType == KeyType::kList || keyType == KeyType::kLease);
endIndex = newval;
}
......@@ -181,7 +185,8 @@ public:
intToBinaryString(sz, serializationBuffer.data() + kOffsetSize);
return serializationBuffer.toSlice();
}
case KeyType::kList: {
case KeyType::kList:
case KeyType::kLease: {
serializationBuffer.shrink(kListDescriptorSize);
// Store the size..
......
......@@ -753,6 +753,17 @@ TEST(KeyDescriptor, BasicSanity) {
ASSERT_EQ(setDesc2.getKeyType(), KeyType::kSet);
ASSERT_EQ(setDesc2.getSize(), 9);
assertEqualDescriptors(setDesc, setDesc2);
KeyDescriptor leaseDescr;
leaseDescr.setKeyType(KeyType::kLease);
leaseDescr.setSize(10);
leaseDescr.setStartIndex(10);
leaseDescr.setEndIndex(15);
KeyDescriptor leaseDescr2(sliceToString(leaseDescr.serialize()));
ASSERT_EQ(leaseDescr.getKeyType(), KeyType::kLease);
ASSERT_EQ(leaseDescr.getStartIndex(), 10u);
ASSERT_EQ(leaseDescr.getEndIndex(), 15u);
}
TEST(FieldLocator, BasicSanity) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment