Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YCSB
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
c97afa18
Commit
c97afa18
authored
9 years ago
by
Sean Busbey
Browse files
Options
Downloads
Plain Diff
Merge pull request #288 from steffenfriedrich/randomByteIteratorAz
closes #279
parents
2973ea5a
b5bee232
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/java/com/yahoo/ycsb/ByteIterator.java
+7
-4
7 additions, 4 deletions
core/src/main/java/com/yahoo/ycsb/ByteIterator.java
core/src/main/java/com/yahoo/ycsb/RandomByteIterator.java
+4
-4
4 additions, 4 deletions
core/src/main/java/com/yahoo/ycsb/RandomByteIterator.java
with
11 additions
and
8 deletions
core/src/main/java/com/yahoo/ycsb/ByteIterator.java
+
7
−
4
View file @
c97afa18
...
...
@@ -16,8 +16,10 @@
*/
package
com.yahoo.ycsb
;
import
java.nio.ByteBuffer
;
import
java.nio.CharBuffer
;
import
java.nio.charset.Charset
;
import
java.util.Iterator
;
import
java.util.ArrayList
;
/**
* YCSB-specific buffer class. ByteIterators are designed to support
* efficient field generation, and to allow backend drivers that can stream
...
...
@@ -73,10 +75,11 @@ public abstract class ByteIterator implements Iterator<Byte> {
/** Consumes remaining contents of this object, and returns them as a string. */
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
(
);
while
(
this
.
hasNext
())
{
sb
.
append
((
char
)
nextByte
(
));
}
return
s
b
.
toString
();
Charset
cset
=
Charset
.
forName
(
"UTF-8"
);
CharBuffer
cb
=
cset
.
decode
(
ByteBuffer
.
wrap
(
this
.
toArray
()
));
return
c
b
.
toString
();
}
/** Consumes remaining contents of this object, and returns them as a byte array. */
public
byte
[]
toArray
()
{
long
left
=
bytesLeft
();
...
...
This diff is collapsed.
Click to expand it.
core/src/main/java/com/yahoo/ycsb/RandomByteIterator.java
+
4
−
4
View file @
c97afa18
...
...
@@ -34,11 +34,11 @@ public class RandomByteIterator extends ByteIterator {
int
bytes
=
Utils
.
random
().
nextInt
();
try
{
buffer
[
base
+
0
]
=
(
byte
)(((
bytes
)
&
31
)
+
' '
);
buffer
[
base
+
1
]
=
(
byte
)(((
bytes
>>
5
)
&
3
1
)
+
' '
);
buffer
[
base
+
2
]
=
(
byte
)(((
bytes
>>
10
)
&
31
)
+
' '
);
buffer
[
base
+
1
]
=
(
byte
)(((
bytes
>>
5
)
&
6
3
)
+
' '
);
buffer
[
base
+
2
]
=
(
byte
)(((
bytes
>>
10
)
&
95
)
+
' '
);
buffer
[
base
+
3
]
=
(
byte
)(((
bytes
>>
15
)
&
31
)
+
' '
);
buffer
[
base
+
4
]
=
(
byte
)(((
bytes
>>
20
)
&
3
1
)
+
' '
);
buffer
[
base
+
5
]
=
(
byte
)(((
bytes
>>
25
)
&
31
)
+
' '
);
buffer
[
base
+
4
]
=
(
byte
)(((
bytes
>>
20
)
&
6
3
)
+
' '
);
buffer
[
base
+
5
]
=
(
byte
)(((
bytes
>>
25
)
&
95
)
+
' '
);
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
/* ignore it */
}
}
...
...
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