Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
eos
QuarkDB
Commits
0597941d
Commit
0597941d
authored
May 16, 2018
by
Georgios Bitzes
Browse files
Implement LHDEL with fallback
parent
2ba03b36
Pipeline
#386853
passed with stages
in 22 minutes and 14 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Dispatcher.cc
View file @
0597941d
...
...
@@ -88,6 +88,13 @@ RedisEncodedResponse RedisDispatcher::dispatchHDEL(StagingArea &stagingArea, con
return
Formatter
::
integer
(
count
);
}
RedisEncodedResponse
RedisDispatcher
::
dispatchLHDEL
(
StagingArea
&
stagingArea
,
const
std
::
string
&
key
,
const
VecIterator
&
start
,
const
VecIterator
&
end
)
{
int64_t
count
=
0
;
rocksdb
::
Status
st
=
store
.
lhdel
(
stagingArea
,
key
,
start
,
end
,
count
);
if
(
!
st
.
ok
())
return
Formatter
::
fromStatus
(
st
);
return
Formatter
::
integer
(
count
);
}
RedisEncodedResponse
RedisDispatcher
::
dispatchWrite
(
StagingArea
&
stagingArea
,
RedisRequest
&
request
)
{
qdb_assert
(
request
.
getCommandType
()
==
CommandType
::
WRITE
);
...
...
@@ -226,10 +233,7 @@ RedisEncodedResponse RedisDispatcher::dispatchWrite(StagingArea &stagingArea, Re
}
case
RedisCommand
::
LHDEL
:
{
if
(
request
.
size
()
<=
2
)
return
errArgs
(
request
);
int64_t
count
=
0
;
rocksdb
::
Status
st
=
store
.
lhdel
(
stagingArea
,
request
[
1
],
request
.
begin
()
+
2
,
request
.
end
(),
count
);
if
(
!
st
.
ok
())
return
Formatter
::
fromStatus
(
st
);
return
Formatter
::
integer
(
count
);
return
dispatchLHDEL
(
stagingArea
,
request
[
1
],
request
.
begin
()
+
2
,
request
.
end
());
}
case
RedisCommand
::
LHMSET
:
{
if
(
request
.
size
()
<=
4
||
(
request
.
size
()
-
2
)
%
3
!=
0
)
return
Formatter
::
errArgs
(
request
[
0
]);
...
...
@@ -243,6 +247,15 @@ RedisEncodedResponse RedisDispatcher::dispatchWrite(StagingArea &stagingArea, Re
dispatchHDEL
(
stagingArea
,
request
[
5
],
request
.
begin
()
+
2
,
request
.
begin
()
+
3
);
return
resp
;
}
case
RedisCommand
::
LHDEL_WITH_FALLBACK
:
{
if
(
request
.
size
()
!=
4
)
return
errArgs
(
request
);
RedisEncodedResponse
resp
=
dispatchLHDEL
(
stagingArea
,
request
[
1
],
request
.
begin
()
+
2
,
request
.
begin
()
+
3
);
if
(
resp
.
val
!=
Formatter
::
integer
(
1
).
val
)
{
return
dispatchHDEL
(
stagingArea
,
request
[
3
],
request
.
begin
()
+
2
,
request
.
begin
()
+
3
);
}
return
resp
;
}
default:
{
qdb_throw
(
"internal dispatching error in RedisDispatcher for "
<<
request
);
}
...
...
src/Dispatcher.hh
View file @
0597941d
...
...
@@ -65,7 +65,7 @@ private:
RedisEncodedResponse
dispatchLHGET
(
StagingArea
&
stagingArea
,
const
std
::
string
&
key
,
const
std
::
string
&
field
,
const
std
::
string
&
hint
);
RedisEncodedResponse
dispatchLHSET
(
StagingArea
&
stagingArea
,
const
std
::
string
&
key
,
const
std
::
string
&
field
,
const
std
::
string
&
hint
,
const
std
::
string
&
value
);
RedisEncodedResponse
dispatchHDEL
(
StagingArea
&
stagingArea
,
const
std
::
string
&
key
,
const
VecIterator
&
start
,
const
VecIterator
&
end
);
RedisEncodedResponse
dispatchLHDEL
(
StagingArea
&
stagingArea
,
const
std
::
string
&
key
,
const
VecIterator
&
start
,
const
VecIterator
&
end
);
};
}
...
...
test/e2e.cc
View file @
0597941d
...
...
@@ -1119,11 +1119,13 @@ TEST_F(Raft_e2e, LocalityHash) {
ASSERT_REPLY
(
tunnel
(
leaderID
)
->
exec
(
"lhget-with-fallback"
,
"mykey"
,
"f9"
,
"fb"
),
"ZZZ"
);
ASSERT_REPLY
(
tunnel
(
leaderID
)
->
exec
(
"lhget"
,
"mykey"
,
"f9"
),
"ZZZ"
);
ASSERT_REPLY
(
tunnel
(
leaderID
)
->
exec
(
"lhdel-with-fallback"
,
"mykey"
,
"f9"
,
"fb"
),
1
);
ASSERT_REPLY
(
tunnel
(
leaderID
)
->
exec
(
"lhdel-with-fallback"
,
"mykey"
,
"f9"
,
"fb"
),
0
);
ASSERT_REPLY
(
tunnel
(
leaderID
)
->
exec
(
"lhlen"
,
"mykey"
),
3
);
ASSERT_REPLY
(
tunnel
(
leaderID
)
->
exec
(
"lhget-with-fallback"
,
"mykey"
,
"f9"
,
"fb"
),
""
);
ASSERT_REPLY
(
tunnel
(
leaderID
)
->
exec
(
"lhdel-with-fallback"
,
"mykey"
,
"f8"
,
"fb"
),
1
);
ASSERT_REPLY
(
tunnel
(
leaderID
)
->
exec
(
"lhlen"
,
"mykey"
),
3
);
ASSERT_REPLY
(
tunnel
(
leaderID
)
->
exec
(
"hlen"
,
"fb"
),
0
);
ASSERT_REPLY
(
tunnel
(
leaderID
)
->
exec
(
"hget"
,
"fb"
,
"f8"
),
""
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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