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
a836c804
Commit
a836c804
authored
13 years ago
by
Russell Sears
Browse files
Options
Downloads
Plain Diff
Merge branch 'fnv64' of github.com:sears/YCSB
parents
e92b9d9c
72832a88
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
src/com/yahoo/ycsb/Utils.java
+2
-2
2 additions, 2 deletions
src/com/yahoo/ycsb/Utils.java
src/com/yahoo/ycsb/workloads/CoreWorkload.java
+44
-67
44 additions, 67 deletions
src/com/yahoo/ycsb/workloads/CoreWorkload.java
with
46 additions
and
69 deletions
src/com/yahoo/ycsb/Utils.java
+
2
−
2
View file @
a836c804
...
...
@@ -48,9 +48,9 @@ public class Utils
/**
* Hash an integer value.
*/
public
static
int
hash
(
int
val
)
public
static
long
hash
(
long
val
)
{
return
FNVhash
32
(
val
);
return
FNVhash
64
(
val
);
}
public
static
final
int
FNV_offset_basis_32
=
0x811c9dc5
;
...
...
This diff is collapsed.
Click to expand it.
src/com/yahoo/ycsb/workloads/CoreWorkload.java
+
44
−
67
View file @
a836c804
...
...
@@ -411,6 +411,33 @@ public class CoreWorkload extends Workload
}
}
public
String
buildKeyName
(
long
keynum
)
{
if
(!
orderedinserts
)
{
keynum
=
Utils
.
hash
(
keynum
);
}
return
"user"
+
keynum
;
}
HashMap
<
String
,
ByteIterator
>
buildValues
()
{
HashMap
<
String
,
ByteIterator
>
values
=
new
HashMap
<
String
,
ByteIterator
>();
for
(
int
i
=
0
;
i
<
fieldcount
;
i
++)
{
String
fieldkey
=
"field"
+
i
;
ByteIterator
data
=
new
RandomByteIterator
(
fieldlengthgenerator
.
nextInt
());
values
.
put
(
fieldkey
,
data
);
}
return
values
;
}
HashMap
<
String
,
ByteIterator
>
buildUpdate
()
{
//update a random field
HashMap
<
String
,
ByteIterator
>
values
=
new
HashMap
<
String
,
ByteIterator
>();
String
fieldname
=
"field"
+
fieldchooser
.
nextString
();
ByteIterator
data
=
new
RandomByteIterator
(
fieldlengthgenerator
.
nextInt
());
values
.
put
(
fieldname
,
data
);
return
values
;
}
/**
* Do one insert operation. Because it will be called concurrently from multiple client threads, this
* function must be thread safe. However, avoid synchronized, or the threads will block waiting for each
...
...
@@ -420,19 +447,8 @@ public class CoreWorkload extends Workload
public
boolean
doInsert
(
DB
db
,
Object
threadstate
)
{
int
keynum
=
keysequence
.
nextInt
();
if
(!
orderedinserts
)
{
keynum
=
Utils
.
hash
(
keynum
);
}
String
dbkey
=
"user"
+
keynum
;
HashMap
<
String
,
ByteIterator
>
values
=
new
HashMap
<
String
,
ByteIterator
>();
for
(
int
i
=
0
;
i
<
fieldcount
;
i
++)
{
String
fieldkey
=
"field"
+
i
;
ByteIterator
data
=
new
RandomByteIterator
(
fieldlengthgenerator
.
nextInt
());
values
.
put
(
fieldkey
,
data
);
}
String
dbkey
=
buildKeyName
(
keynum
);
HashMap
<
String
,
ByteIterator
>
values
=
buildValues
();
if
(
db
.
insert
(
table
,
dbkey
,
values
)
==
0
)
return
true
;
else
...
...
@@ -483,12 +499,8 @@ public class CoreWorkload extends Workload
}
while
(
keynum
>
transactioninsertkeysequence
.
lastInt
());
if
(!
orderedinserts
)
{
keynum
=
Utils
.
hash
(
keynum
);
}
String
keyname
=
"user"
+
keynum
;
String
keyname
=
buildKeyName
(
keynum
);
HashSet
<
String
>
fields
=
null
;
if
(!
readallfields
)
...
...
@@ -513,11 +525,7 @@ public class CoreWorkload extends Workload
}
while
(
keynum
>
transactioninsertkeysequence
.
lastInt
());
if
(!
orderedinserts
)
{
keynum
=
Utils
.
hash
(
keynum
);
}
String
keyname
=
"user"
+
keynum
;
String
keyname
=
buildKeyName
(
keynum
);
HashSet
<
String
>
fields
=
null
;
...
...
@@ -530,24 +538,17 @@ public class CoreWorkload extends Workload
fields
.
add
(
fieldname
);
}
HashMap
<
String
,
ByteIterator
>
values
=
new
HashMap
<
String
,
ByteIterator
>()
;
HashMap
<
String
,
ByteIterator
>
values
;
if
(
writeallfields
)
{
//new data for all the fields
for
(
int
i
=
0
;
i
<
fieldcount
;
i
++)
{
String
fieldname
=
"field"
+
i
;
ByteIterator
data
=
new
RandomByteIterator
(
fieldlengthgenerator
.
nextInt
());
values
.
put
(
fieldname
,
data
);
}
values
=
buildValues
();
}
else
{
//update a random field
String
fieldname
=
"field"
+
fieldchooser
.
nextString
();
ByteIterator
data
=
new
RandomByteIterator
(
fieldlengthgenerator
.
nextInt
());
values
.
put
(
fieldname
,
data
);
values
=
buildUpdate
();
}
//do the transaction
...
...
@@ -573,11 +574,7 @@ public class CoreWorkload extends Workload
}
while
(
keynum
>
transactioninsertkeysequence
.
lastInt
());
if
(!
orderedinserts
)
{
keynum
=
Utils
.
hash
(
keynum
);
}
String
startkeyname
=
"user"
+
keynum
;
String
startkeyname
=
buildKeyName
(
keynum
);
//choose a random scan length
int
len
=
scanlength
.
nextInt
();
...
...
@@ -606,30 +603,19 @@ public class CoreWorkload extends Workload
}
while
(
keynum
>
transactioninsertkeysequence
.
lastInt
());
if
(!
orderedinserts
)
{
keynum
=
Utils
.
hash
(
keynum
);
}
String
keyname
=
"user"
+
keynum
;
String
keyname
=
buildKeyName
(
keynum
);
HashMap
<
String
,
ByteIterator
>
values
=
new
HashMap
<
String
,
ByteIterator
>()
;
HashMap
<
String
,
ByteIterator
>
values
;
if
(
writeallfields
)
{
//new data for all the fields
for
(
int
i
=
0
;
i
<
fieldcount
;
i
++)
{
String
fieldname
=
"field"
+
i
;
ByteIterator
data
=
new
RandomByteIterator
(
fieldlengthgenerator
.
nextInt
());
values
.
put
(
fieldname
,
data
);
}
values
=
buildValues
();
}
else
{
//update a random field
String
fieldname
=
"field"
+
fieldchooser
.
nextString
();
ByteIterator
data
=
new
RandomByteIterator
(
fieldlengthgenerator
.
nextInt
());
values
.
put
(
fieldname
,
data
);
values
=
buildUpdate
();
}
db
.
update
(
table
,
keyname
,
values
);
...
...
@@ -639,19 +625,10 @@ public class CoreWorkload extends Workload
{
//choose the next key
int
keynum
=
transactioninsertkeysequence
.
nextInt
();
if
(!
orderedinserts
)
{
keynum
=
Utils
.
hash
(
keynum
);
}
String
dbkey
=
"user"
+
keynum
;
HashMap
<
String
,
ByteIterator
>
values
=
new
HashMap
<
String
,
ByteIterator
>();
for
(
int
i
=
0
;
i
<
fieldcount
;
i
++)
{
String
fieldkey
=
"field"
+
i
;
ByteIterator
data
=
new
RandomByteIterator
(
fieldlengthgenerator
.
nextInt
());
values
.
put
(
fieldkey
,
data
);
}
String
dbkey
=
buildKeyName
(
keynum
);
HashMap
<
String
,
ByteIterator
>
values
=
buildValues
();
db
.
insert
(
table
,
dbkey
,
values
);
}
}
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