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
fd00f12a
Commit
fd00f12a
authored
Jun 22, 2018
by
Georgios Bitzes
Browse files
Add locator for expiration events
parent
14ca1e59
Pipeline
#423022
passed with stages
in 33 minutes and 1 second
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/storage/KeyLocators.hh
View file @
fd00f12a
...
...
@@ -31,11 +31,13 @@
namespace
quarkdb
{
using
KeyBuffer
=
SmartBuffer
<
512
>
;
using
ClockValue
=
uint64_t
;
enum
class
InternalKeyType
:
char
{
kInternal
=
'_'
,
kConfiguration
=
'~'
,
kDescriptor
=
'!'
kDescriptor
=
'!'
,
kExpirationEvent
=
'@'
};
class
DescriptorLocator
{
...
...
@@ -264,6 +266,28 @@ private:
KeyBuffer
keyBuffer
;
};
class
ExpirationEventLocator
{
public:
ExpirationEventLocator
(
ClockValue
deadline
,
const
std
::
string
&
redisKey
)
{
reset
(
deadline
,
redisKey
);
}
void
reset
(
ClockValue
deadline
,
const
std
::
string
&
redisKey
)
{
keyBuffer
.
resize
(
1
+
sizeof
(
ClockValue
)
+
redisKey
.
size
());
keyBuffer
[
0
]
=
char
(
InternalKeyType
::
kExpirationEvent
);
unsignedIntToBinaryString
(
deadline
,
keyBuffer
.
data
()
+
1
);
memcpy
(
keyBuffer
.
data
()
+
1
+
sizeof
(
ClockValue
),
redisKey
.
data
(),
redisKey
.
size
());
}
rocksdb
::
Slice
toSlice
()
{
return
keyBuffer
.
toSlice
();
}
private:
KeyBuffer
keyBuffer
;
};
}
#endif
test/state-machine.cc
View file @
fd00f12a
...
...
@@ -881,6 +881,11 @@ TEST(LeaseLocator, BasicSanity) {
ASSERT_EQ
(
locator2
.
toSlice
().
ToString
(),
"fmy#key"
);
}
TEST
(
ExpirationEventLocator
,
BasicSanity
)
{
ExpirationEventLocator
locator1
(
ClockValue
(
123u
),
"some-key"
);
ASSERT_EQ
(
locator1
.
toSlice
().
ToString
(),
SSTR
(
"@"
<<
unsignedIntToBinaryString
(
123u
)
<<
"some-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