Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
eos
QuarkDB
Commits
f8c03c61
Commit
f8c03c61
authored
Jun 20, 2018
by
Georgios Bitzes
Browse files
Implement locator for lease keys
parent
6eea0e6b
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/storage/KeyDescriptor.hh
View file @
f8c03c61
...
...
@@ -38,7 +38,8 @@ enum class KeyType : char {
kHash
=
'b'
,
kSet
=
'c'
,
kList
=
'd'
,
kLocalityHash
=
'e'
kLocalityHash
=
'e'
,
kLease
=
'f'
};
inline
KeyType
parseKeyType
(
char
c
)
{
...
...
src/storage/KeyLocators.hh
View file @
f8c03c61
...
...
@@ -245,6 +245,25 @@ private:
KeyBuffer
keyBuffer
;
};
class
LeaseLocator
{
public:
LeaseLocator
(
const
std
::
string
&
redisKey
)
{
reset
(
redisKey
);
}
void
reset
(
const
std
::
string
&
redisKey
)
{
keyBuffer
.
resize
(
redisKey
.
size
()
+
1
);
keyBuffer
[
0
]
=
char
(
KeyType
::
kLease
);
memcpy
(
keyBuffer
.
data
()
+
1
,
redisKey
.
data
(),
redisKey
.
size
());
}
rocksdb
::
Slice
toSlice
()
{
return
keyBuffer
.
toSlice
();
}
private:
KeyBuffer
keyBuffer
;
};
}
#endif
test/state-machine.cc
View file @
f8c03c61
...
...
@@ -847,6 +847,14 @@ TEST(LocalityIndexLocator, BasicSanity) {
ASSERT_EQ
(
revlocator
.
getOriginalKey
().
ToString
(),
"key##with##hashes"
);
}
TEST
(
LeaseLocator
,
BasicSanity
)
{
LeaseLocator
locator1
(
"my-key"
);
ASSERT_EQ
(
locator1
.
toSlice
().
ToString
(),
"fmy-key"
);
LeaseLocator
locator2
(
"my#key"
);
ASSERT_EQ
(
locator2
.
toSlice
().
ToString
(),
"fmy#key"
);
}
TEST
(
PatternMatching
,
BasicSanity
)
{
ASSERT_EQ
(
extractPatternPrefix
(
"abc*"
),
"abc"
);
ASSERT_EQ
(
extractPatternPrefix
(
"abc"
),
"abc"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment