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
e62af2cf
Commit
e62af2cf
authored
14 years ago
by
Todd Lipcon
Committed by
Brian Cooper
14 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Avoid needless conversion to/from Bytes in HBase benchmark
parent
ed39c110
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
src/com/yahoo/ycsb/db/HBaseClient.java
+11
-10
11 additions, 10 deletions
src/com/yahoo/ycsb/db/HBaseClient.java
with
11 additions
and
10 deletions
src/com/yahoo/ycsb/db/HBaseClient.java
+
11
−
10
View file @
e62af2cf
...
...
@@ -47,6 +47,7 @@ public class HBaseClient extends com.yahoo.ycsb.DB
public
String
_table
=
""
;
public
HTable
_hTable
=
null
;
public
String
_columnFamily
=
""
;
public
byte
_columnFamilyBytes
[];
public
static
final
int
Ok
=
0
;
public
static
final
int
ServerError
=-
1
;
...
...
@@ -73,7 +74,7 @@ public class HBaseClient extends com.yahoo.ycsb.DB
System
.
err
.
println
(
"Error, must specify a columnfamily for HBase table"
);
throw
new
DBException
(
"No columnfamily specified"
);
}
_columnFamilyBytes
=
Bytes
.
toBytes
(
_columnFamily
);
}
...
...
@@ -155,7 +156,7 @@ public class HBaseClient extends com.yahoo.ycsb.DB
//now parse out all desired fields
if
(
fields
!=
null
)
{
for
(
String
field
:
fields
)
{
byte
[]
value
=
r
.
getValue
(
Bytes
.
toBytes
(
_columnFamily
),
Bytes
.
toBytes
(
field
));
byte
[]
value
=
r
.
getValue
(
_columnFamily
Bytes
,
Bytes
.
toBytes
(
field
));
result
.
put
(
field
,
Bytes
.
toString
(
value
));
if
(
_debug
)
{
System
.
out
.
println
(
"Result for field: "
+
field
+
" is: "
+
Bytes
.
toString
(
value
));
...
...
@@ -200,13 +201,13 @@ public class HBaseClient extends com.yahoo.ycsb.DB
//add specified fields or else all fields
if
(
fields
==
null
)
{
s
.
addFamily
(
Bytes
.
toBytes
(
_columnFamily
)
);
s
.
addFamily
(
_columnFamily
Bytes
);
}
else
{
for
(
String
field
:
fields
)
{
s
.
addColumn
(
Bytes
.
toBytes
(
_columnFamily
)
,
Bytes
.
toBytes
(
field
));
s
.
addColumn
(
_columnFamily
Bytes
,
Bytes
.
toBytes
(
field
));
}
}
...
...
@@ -230,7 +231,7 @@ public class HBaseClient extends com.yahoo.ycsb.DB
if
(
fields
!=
null
)
//parse specified field list
{
for
(
String
field
:
fields
)
{
byte
[]
value
=
rr
.
getValue
(
Bytes
.
toBytes
(
_columnFamily
)
,
Bytes
.
toBytes
(
field
));
byte
[]
value
=
rr
.
getValue
(
_columnFamily
Bytes
,
Bytes
.
toBytes
(
field
));
rowResult
.
put
(
field
,
Bytes
.
toString
(
value
));
if
(
_debug
)
{
...
...
@@ -241,7 +242,7 @@ public class HBaseClient extends com.yahoo.ycsb.DB
else
//get all fields
{
//HBase can return a mapping for all columns in a column family
NavigableMap
<
byte
[],
byte
[]>
scanMap
=
rr
.
getFamilyMap
(
Bytes
.
toBytes
(
_columnFamily
)
);
NavigableMap
<
byte
[],
byte
[]>
scanMap
=
rr
.
getFamilyMap
(
_columnFamily
Bytes
);
for
(
byte
[]
fieldkey
:
scanMap
.
keySet
())
{
String
value
=
Bytes
.
toString
(
scanMap
.
get
(
fieldkey
));
...
...
@@ -311,13 +312,13 @@ public class HBaseClient extends com.yahoo.ycsb.DB
System
.
out
.
println
(
"Setting up put for key: "
+
key
);
}
Put
p
=
new
Put
(
Bytes
.
toBytes
(
key
));
for
(
String
fieldke
y
:
values
.
k
eySet
())
for
(
Map
.
Entry
<
String
,
String
>
entr
y
:
values
.
e
ntr
ySet
())
{
String
value
=
values
.
get
(
fieldkey
);
if
(
_debug
)
{
System
.
out
.
println
(
"Adding field/value "
+
fieldkey
+
"/"
+
value
+
" to put request"
);
System
.
out
.
println
(
"Adding field/value "
+
entry
.
getKey
()
+
"/"
+
entry
.
getValue
()
+
" to put request"
);
}
p
.
add
(
Bytes
.
toBytes
(
_columnFamily
)
,
Bytes
.
toBytes
(
fieldkey
),
Bytes
.
toBytes
(
v
alue
));
p
.
add
(
_columnFamily
Bytes
,
Bytes
.
toBytes
(
entry
.
getKey
()
),
Bytes
.
toBytes
(
entry
.
getV
alue
()
));
}
try
...
...
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