Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YCSB
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adnan Ahmad
YCSB
Commits
60e2345f
Commit
60e2345f
authored
13 years ago
by
Robert Lehmann
Committed by
Robert Lehmann
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
implemented scan operations in redis
parent
4cf6f109
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
db/redis/com/yahoo/ycsb/db/RedisClient.java
+28
-3
28 additions, 3 deletions
db/redis/com/yahoo/ycsb/db/RedisClient.java
with
28 additions
and
3 deletions
db/redis/com/yahoo/ycsb/db/RedisClient.java
+
28
−
3
View file @
60e2345f
/**
* Redis client binding for YCSB.
*
* All YCSB records are mapped to a Redis *hash field*. For scanning
* operations, all keys are saved (by an arbitrary hash) in a sorted set.
*/
package
com.yahoo.ycsb.db
;
...
...
@@ -25,6 +27,8 @@ public class RedisClient extends DB {
public
static
final
String
PORT_PROPERTY
=
"redis.port"
;
public
static
final
String
PASSWORD_PROPERTY
=
"redis.password"
;
public
static
final
String
INDEX_KEY
=
"_indices"
;
public
void
init
()
throws
DBException
{
Properties
props
=
getProperties
();
int
port
;
...
...
@@ -52,6 +56,14 @@ public class RedisClient extends DB {
jedis
.
disconnect
();
}
/* Calculate a hash for a key to store it in an index. The actual return
* value of this function is not interesting -- it primarily needs to be
* fast and scattered along the whole space of doubles.
*/
private
double
hash
(
String
key
)
{
return
key
.
hashCode
();
}
//XXX jedis.select(int index) to switch to `table`
@Override
...
...
@@ -77,12 +89,16 @@ public class RedisClient extends DB {
@Override
public
int
insert
(
String
table
,
String
key
,
HashMap
<
String
,
String
>
values
)
{
return
jedis
.
hmset
(
key
,
values
).
equals
(
"OK"
)
?
0
:
1
;
return
jedis
.
hmset
(
key
,
values
).
equals
(
"OK"
)
&&
jedis
.
zadd
(
INDEX_KEY
,
hash
(
key
),
key
)
==
1
?
0
:
1
;
}
@Override
public
int
delete
(
String
table
,
String
key
)
{
return
jedis
.
del
(
key
)
==
0
?
1
:
0
;
return
jedis
.
del
(
key
)
==
0
&&
jedis
.
zrem
(
INDEX_KEY
,
key
)
==
0
?
1
:
0
;
}
@Override
...
...
@@ -93,7 +109,16 @@ public class RedisClient extends DB {
@Override
public
int
scan
(
String
table
,
String
startkey
,
int
recordcount
,
Set
<
String
>
fields
,
Vector
<
HashMap
<
String
,
String
>>
result
)
{
//XXX
Set
<
String
>
keys
=
jedis
.
zrangeByScore
(
INDEX_KEY
,
hash
(
startkey
),
Double
.
POSITIVE_INFINITY
,
0
,
recordcount
);
HashMap
<
String
,
String
>
values
;
for
(
String
key
:
keys
)
{
values
=
new
HashMap
<
String
,
String
>();
read
(
table
,
key
,
fields
,
values
);
result
.
add
(
values
);
}
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment