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
102ada09
Commit
102ada09
authored
Jan 20, 2018
by
Georgios Bitzes
Browse files
Treat underscores and dashes as equal in command names
parent
2771e3d5
Pipeline
#283550
passed with stages
in 24 minutes and 11 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/Commands.cc
View file @
102ada09
...
...
@@ -26,7 +26,7 @@ using namespace quarkdb;
std
::
map
<
std
::
string
,
std
::
pair
<
RedisCommand
,
CommandType
>
,
caseInsensitive
Comparator
>
Command
Comparator
>
quarkdb
::
redis_cmd_map
;
struct
cmdMapInit
{
...
...
@@ -85,7 +85,7 @@ struct cmdMapInit {
redis_cmd_map
[
"raft_heartbeat"
]
=
{
RedisCommand
::
RAFT_HEARTBEAT
,
CommandType
::
RAFT
};
redis_cmd_map
[
"raft_invalid_command"
]
=
{
RedisCommand
::
RAFT_INVALID_COMMAND
,
CommandType
::
RAFT
};
redis_cmd_map
[
"raft_fetch_last"
]
=
{
RedisCommand
::
RAFT_FETCH_LAST
,
CommandType
::
RAFT
};
redis_cmd_map
[
"activate
-
stale
-
reads"
]
=
{
RedisCommand
::
ACTIVATE_STALE_READS
,
CommandType
::
RAFT
};
redis_cmd_map
[
"activate
_
stale
_
reads"
]
=
{
RedisCommand
::
ACTIVATE_STALE_READS
,
CommandType
::
RAFT
};
redis_cmd_map
[
"quarkdb_info"
]
=
{
RedisCommand
::
QUARKDB_INFO
,
CommandType
::
QUARKDB
};
redis_cmd_map
[
"quarkdb_detach"
]
=
{
RedisCommand
::
QUARKDB_DETACH
,
CommandType
::
QUARKDB
};
...
...
@@ -96,7 +96,7 @@ struct cmdMapInit {
redis_cmd_map
[
"quarkdb_cancel_resilvering"
]
=
{
RedisCommand
::
QUARKDB_CANCEL_RESILVERING
,
CommandType
::
QUARKDB
};
redis_cmd_map
[
"quarkdb_bulkload_finalize"
]
=
{
RedisCommand
::
QUARKDB_BULKLOAD_FINALIZE
,
CommandType
::
QUARKDB
};
redis_cmd_map
[
"quarkdb_invalid_command"
]
=
{
RedisCommand
::
QUARKDB_INVALID_COMMAND
,
CommandType
::
QUARKDB
};
redis_cmd_map
[
"recovery
-
info"
]
=
{
RedisCommand
::
RECOVERY_INFO
,
CommandType
::
QUARKDB
};
redis_cmd_map
[
"recovery
_
info"
]
=
{
RedisCommand
::
RECOVERY_INFO
,
CommandType
::
QUARKDB
};
}
}
cmd_map_init
;
src/Commands.hh
View file @
102ada09
...
...
@@ -113,11 +113,26 @@ enum class CommandType {
QUARKDB
};
struct
caseInsensitiveComparator
{
#define QDB_ALWAYS_INLINE __attribute__((always_inline))
struct
CommandComparator
{
QDB_ALWAYS_INLINE
char
normalize
(
char
c
)
const
{
char
ret
=
tolower
(
c
);
if
(
ret
==
'-'
)
{
ret
=
'_'
;
}
return
ret
;
}
bool
operator
()
(
const
std
::
string
&
lhs
,
const
std
::
string
&
rhs
)
const
{
for
(
size_t
i
=
0
;
i
<
std
::
min
(
lhs
.
size
(),
rhs
.
size
());
i
++
)
{
if
(
tolower
(
lhs
[
i
])
!=
tolower
(
rhs
[
i
]))
{
return
tolower
(
lhs
[
i
])
<
tolower
(
rhs
[
i
]);
char
left
=
normalize
(
lhs
[
i
]);
char
right
=
normalize
(
rhs
[
i
]);
if
(
left
!=
right
)
{
return
left
<
right
;
}
}
return
lhs
.
size
()
<
rhs
.
size
();
...
...
@@ -126,7 +141,7 @@ struct caseInsensitiveComparator {
extern
std
::
map
<
std
::
string
,
std
::
pair
<
RedisCommand
,
CommandType
>
,
caseInsensitive
Comparator
>
Command
Comparator
>
redis_cmd_map
;
}
...
...
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