Skip to content

update method in JdbcDBClient.java #132

Closed
getkumara opened this Issue Jun 21, 2013 · 1 comment

3 participants

@getkumara

In update method of JdbcDBClient.java, following lines of code get values from a map in order of entries:
for (Map.Entry entry : values.entrySet()) {
updateStatement.setString(index++, entry.getValue().toString());
}
Since, Map does not guarantee order of entries, though, it doesn't make a big difference for usertable as all the columns are of the same type, varchar and random values are passed, however, while verification, corresponding values are not reflected . It would be good to get the corresponding values from the map for desired fields.

Following is a excerpt from update() method:

public int update(String tableName, String key, HashMap values) {
........
.......
PreparedStatement updateStatement = cachedStatements.get(type);
....
......

int index = 1;
for (Map.Entry entry : values.entrySet()) {
updateStatement.setString(index++, entry.getValue().toString());
}
updateStatement.setString(index, key);

@kruthar
Collaborator
kruthar commented Nov 2, 2015

I ran into this as well. Here is a simple query against YCSB data in mysql:

mysql> select * from usertable where YCSB_KEY >= 'user4' group by YCSB_KEY limit 5;
+----------+-----------------+-----------------+-----------------+
| YCSB_KEY | FIELD1          | FIELD2          | FIELD3          |
+----------+-----------------+-----------------+-----------------+
| user4    | user4:field2:18 | user4:field1:18 | user4:field0:18 |
| user40   | user40:field2:2 | user40:field1:2 | user40:field0:2 |
| user400  | user400:field2: | user400:field1: | user400:field0: |
| user401  | user401:field2: | user401:field1: | user401:field0: |
| user402  | user402:field2: | user402:field1: | user402:field0: |
+----------+-----------------+-----------------+-----------------+

As you can see, with dataintegrity turned on the field values do not match the field names. Not sure if this is causing major issues within YCSB at the moment because the CoreWorkload doesn't seem to verify answers. But, in a recent benchmark I did I used YCSB for data insert and read/write load and wrote my own stuff to measure query workloads. This was only possible with dataintegrity turned on so that we can determine the value for fields to query against. This wouldn't currently be possible with the JDBC binding since the values don't match columns.

I can look into a PR to fix this, but looks like a significant change because of the way cached statements are built.

This was referenced Nov 3, 2015
@kruthar kruthar added a commit to kruthar/YCSB that referenced this issue Jan 27, 2016
@kruthar kruthar [jdbc] solidified field ordering
Changes to account for the field ordering. Now correctly inserting and
updating field values so that they can be verified when using
dataintegrity=true.

Fixes #132
abe4400
@kruthar kruthar added a commit to kruthar/YCSB that referenced this issue Jan 27, 2016
@kruthar kruthar [jdbc] solidified field ordering
Changes to account for the field ordering. Now correctly inserting and
updating field values so that they can be verified when using
dataintegrity=true.

Fixes #132
73ec3b1
@kruthar kruthar closed this in #600 Jan 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.