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
b5bee232
Commit
b5bee232
authored
9 years ago
by
Steffen Friedrich
Browse files
Options
Downloads
Patches
Plain Diff
[core] ByteIterators `toString()` method now uses java.nio.CharBuffer to decode the byte array.
parent
7bfe3bcd
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
core/src/main/java/com/yahoo/ycsb/ByteIterator.java
+7
-4
7 additions, 4 deletions
core/src/main/java/com/yahoo/ycsb/ByteIterator.java
with
7 additions
and
4 deletions
core/src/main/java/com/yahoo/ycsb/ByteIterator.java
+
7
−
4
View file @
b5bee232
...
@@ -16,8 +16,10 @@
...
@@ -16,8 +16,10 @@
*/
*/
package
com.yahoo.ycsb
;
package
com.yahoo.ycsb
;
import
java.nio.ByteBuffer
;
import
java.nio.CharBuffer
;
import
java.nio.charset.Charset
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.ArrayList
;
/**
/**
* YCSB-specific buffer class. ByteIterators are designed to support
* YCSB-specific buffer class. ByteIterators are designed to support
* efficient field generation, and to allow backend drivers that can stream
* efficient field generation, and to allow backend drivers that can stream
...
@@ -73,10 +75,11 @@ public abstract class ByteIterator implements Iterator<Byte> {
...
@@ -73,10 +75,11 @@ public abstract class ByteIterator implements Iterator<Byte> {
/** Consumes remaining contents of this object, and returns them as a string. */
/** Consumes remaining contents of this object, and returns them as a string. */
public
String
toString
()
{
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
(
);
Charset
cset
=
Charset
.
forName
(
"UTF-8"
);
while
(
this
.
hasNext
())
{
sb
.
append
((
char
)
nextByte
(
));
}
CharBuffer
cb
=
cset
.
decode
(
ByteBuffer
.
wrap
(
this
.
toArray
()
));
return
s
b
.
toString
();
return
c
b
.
toString
();
}
}
/** Consumes remaining contents of this object, and returns them as a byte array. */
/** Consumes remaining contents of this object, and returns them as a byte array. */
public
byte
[]
toArray
()
{
public
byte
[]
toArray
()
{
long
left
=
bytesLeft
();
long
left
=
bytesLeft
();
...
...
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