Skip to content

Commit 2c032b9

Browse files
committed
Merge pull request brianfrankcooper#392 from cmccoy/separate-hbase
[hbase] Separate HBase v0.9x and v1.x bindings
2 parents 9283913 + 9975f0b commit 2c032b9

File tree

11 files changed

+196
-19
lines changed

11 files changed

+196
-19
lines changed

bin/ycsb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ DATABASES = {
5555
"dynamodb" : "com.yahoo.ycsb.db.DynamoDBClient",
5656
"elasticsearch": "com.yahoo.ycsb.db.ElasticSearchClient",
5757
"gemfire" : "com.yahoo.ycsb.db.GemFireClient",
58-
"hbase" : "com.yahoo.ycsb.db.HBaseClient",
59-
"hbase-10" : "com.yahoo.ycsb.db.HBaseClient10",
58+
"hbase094" : "com.yahoo.ycsb.db.HBaseClient",
59+
"hbase098" : "com.yahoo.ycsb.db.HBaseClient",
60+
"hbase10" : "com.yahoo.ycsb.db.HBaseClient10",
6061
"hypertable" : "com.yahoo.ycsb.db.HypertableClient",
6162
"infinispan-cs": "com.yahoo.ycsb.db.InfinispanRemoteClient",
6263
"infinispan" : "com.yahoo.ycsb.db.InfinispanClient",

distribution/pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,17 @@ LICENSE file.
7676
</dependency>
7777
<dependency>
7878
<groupId>com.yahoo.ycsb</groupId>
79-
<artifactId>hbase-binding</artifactId>
79+
<artifactId>hbase094-binding</artifactId>
80+
<version>${project.version}</version>
81+
</dependency>
82+
<dependency>
83+
<groupId>com.yahoo.ycsb</groupId>
84+
<artifactId>hbase098-binding</artifactId>
85+
<version>${project.version}</version>
86+
</dependency>
87+
<dependency>
88+
<groupId>com.yahoo.ycsb</groupId>
89+
<artifactId>hbase10-binding</artifactId>
8090
<version>${project.version}</version>
8191
</dependency>
8292
<dependency>

hbase094/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!--
2+
Copyright (c) 2015 YCSB contributors. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License"); you
5+
may not use this file except in compliance with the License. You
6+
may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13+
implied. See the License for the specific language governing
14+
permissions and limitations under the License. See accompanying
15+
LICENSE file.
16+
-->
17+
18+
# HBase (0.94.x) Driver for YCSB
19+
This driver is a binding for the YCSB facilities to operate against a HBase 0.94.x Server cluster. It may also work against 0.92.x
20+
To run against an HBase 0.98.x cluster, use the `hbase098` binding.
21+
To run against an HBase >= 1.0 cluster, use the `hbase10` binding.
22+
23+
See `hbase098/README.md` for configuration details.

hbase094/pom.xml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (c) 2012 - 2015 YCSB contributors. All rights reserved.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License"); you
6+
may not use this file except in compliance with the License. You
7+
may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14+
implied. See the License for the specific language governing
15+
permissions and limitations under the License. See accompanying
16+
LICENSE file.
17+
-->
18+
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
<parent>
22+
<groupId>com.yahoo.ycsb</groupId>
23+
<artifactId>binding-parent</artifactId>
24+
<version>0.4.0-SNAPSHOT</version>
25+
<relativePath>../binding-parent/</relativePath>
26+
</parent>
27+
28+
<artifactId>hbase094-binding</artifactId>
29+
<name>HBase 0.94.x DB Binding</name>
30+
31+
<dependencies>
32+
<!-- This binding is identical to the HBase 0.98, other than dependencies. -->
33+
<dependency>
34+
<groupId>org.apache.hbase</groupId>
35+
<artifactId>hbase</artifactId>
36+
<version>${hbase094.version}</version>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.apache.hadoop</groupId>
40+
<artifactId>hadoop-core</artifactId>
41+
<version>1.0.4</version>
42+
</dependency>
43+
<dependency>
44+
<groupId>com.yahoo.ycsb</groupId>
45+
<artifactId>hbase098-binding</artifactId>
46+
<version>${project.version}</version>
47+
<exclusions>
48+
<!-- HBase 0.98.0 depends on hbase-client, HBase 0.94.0 on hbase.
49+
Override all dependencies. -->
50+
<exclusion>
51+
<groupId>*</groupId>
52+
<artifactId>*</artifactId>
53+
</exclusion>
54+
</exclusions>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.slf4j</groupId>
58+
<artifactId>slf4j-simple</artifactId>
59+
<version>1.7.12</version>
60+
</dependency>
61+
<dependency>
62+
<groupId>com.yahoo.ycsb</groupId>
63+
<artifactId>core</artifactId>
64+
<version>${project.version}</version>
65+
<scope>provided</scope>
66+
</dependency>
67+
</dependencies>
68+
</project>

hbase/README.md renamed to hbase098/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ permissions and limitations under the License. See accompanying
1515
LICENSE file.
1616
-->
1717

18-
# HBase Driver for YCSB
19-
This driver is a binding for the YCSB facilities to operate against a HBase Server cluster.
18+
# HBase (0.98.x) Driver for YCSB
19+
This driver is a binding for the YCSB facilities to operate against a HBase 0.98.x Server cluster.
20+
To run against an HBase 0.94.x cluster, use the `hbase094` binding.
21+
To run against an HBase >= 1.0 cluster, use the `hbase10` binding.
2022

2123
## Quickstart
2224

@@ -68,6 +70,4 @@ bin/ycsb run hbase -P workloads/workloada -cp /HBASE-HOME-DIR/conf -p table=user
6870
Following options can be configurable using `-p`.
6971

7072
* `columnfamily`: The HBase column family to target.
71-
* `clientbuffering` : If true, buffer mutations on the client. The default is false.
72-
* `writebuffersize` : Buffer size to be used when `clientbuffering` is activated. The default is 12MB.
7373
* `debug` : If true, debugging logs are activated. The default is false.

hbase098/pom.xml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (c) 2012 - 2015 YCSB contributors. All rights reserved.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License"); you
6+
may not use this file except in compliance with the License. You
7+
may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14+
implied. See the License for the specific language governing
15+
permissions and limitations under the License. See accompanying
16+
LICENSE file.
17+
-->
18+
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
<parent>
22+
<groupId>com.yahoo.ycsb</groupId>
23+
<artifactId>binding-parent</artifactId>
24+
<version>0.4.0-SNAPSHOT</version>
25+
<relativePath>../binding-parent/</relativePath>
26+
</parent>
27+
28+
<artifactId>hbase098-binding</artifactId>
29+
<name>HBase 0.98.x DB Binding</name>
30+
31+
<dependencies>
32+
<dependency>
33+
<groupId>org.apache.hbase</groupId>
34+
<artifactId>hbase-client</artifactId>
35+
<version>${hbase098.version}</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>com.yahoo.ycsb</groupId>
39+
<artifactId>core</artifactId>
40+
<version>${project.version}</version>
41+
<scope>provided</scope>
42+
</dependency>
43+
</dependencies>
44+
</project>

hbase10/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!--
2+
Copyright (c) 2015 YCSB contributors. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License"); you
5+
may not use this file except in compliance with the License. You
6+
may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13+
implied. See the License for the specific language governing
14+
permissions and limitations under the License. See accompanying
15+
LICENSE file.
16+
-->
17+
18+
# HBase (1.0.x) Driver for YCSB
19+
This driver is a binding for the YCSB facilities to operate against a HBase 1.0.x Server cluster.
20+
To run against an HBase 0.94.x cluster, use the `hbase094` binding.
21+
To run against an HBase 0.98.x cluster, use the `hbase098` binding.
22+
23+
See `hbase098/README.md` for configuration details.

hbase/pom.xml renamed to hbase10/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!--
2+
<!--
33
Copyright (c) 2012 - 2015 YCSB contributors. All rights reserved.
44
55
Licensed under the Apache License, Version 2.0 (the "License"); you
@@ -25,14 +25,14 @@ LICENSE file.
2525
<relativePath>../binding-parent/</relativePath>
2626
</parent>
2727

28-
<artifactId>hbase-binding</artifactId>
29-
<name>HBase DB Binding</name>
28+
<artifactId>hbase10-binding</artifactId>
29+
<name>HBase 1.0 DB Binding</name>
3030

3131
<dependencies>
3232
<dependency>
3333
<groupId>org.apache.hbase</groupId>
3434
<artifactId>hbase-client</artifactId>
35-
<version>${hbase.version}</version>
35+
<version>${hbase10.version}</version>
3636
</dependency>
3737
<dependency>
3838
<groupId>com.yahoo.ycsb</groupId>

hbase/src/main/java/com/yahoo/ycsb/db/HBaseClient10.java renamed to hbase10/src/main/java/com/yahoo/ycsb/db/HBaseClient10.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.apache.hadoop.hbase.CellUtil;
2929
import org.apache.hadoop.hbase.HBaseConfiguration;
3030
import org.apache.hadoop.hbase.HTableDescriptor;
31-
import org.apache.hadoop.hbase.KeyValue;
3231
import org.apache.hadoop.hbase.TableName;
3332
import org.apache.hadoop.hbase.client.BufferedMutator;
3433
import org.apache.hadoop.hbase.client.BufferedMutatorParams;
@@ -250,7 +249,9 @@ public int read(String table, String key, Set<String> fields, HashMap<String,Byt
250249
if (r.isEmpty()) {
251250
return NoMatchingRecord;
252251
}
253-
for (Cell c : r.listCells()) {
252+
253+
while (r.advance()) {
254+
final Cell c = r.current();
254255
result.put(Bytes.toString(CellUtil.cloneQualifier(c)),
255256
new ByteArrayByteIterator(CellUtil.cloneValue(c)));
256257
if (_debug) {
@@ -316,18 +317,21 @@ public int scan(String table, String startkey, int recordcount, Set<String> fiel
316317
{
317318
//get row key
318319
String key = Bytes.toString(rr.getRow());
320+
319321
if (_debug)
320322
{
321323
System.out.println("Got scan result for key: "+key);
322324
}
323325

324326
HashMap<String,ByteIterator> rowResult = new HashMap<String, ByteIterator>();
325327

326-
for (KeyValue kv : rr.raw()) {
328+
while (rr.advance()) {
329+
final Cell cell = rr.current();
327330
rowResult.put(
328-
Bytes.toString(kv.getQualifier()),
329-
new ByteArrayByteIterator(kv.getValue()));
331+
Bytes.toString(CellUtil.cloneQualifier(cell)),
332+
new ByteArrayByteIterator(CellUtil.cloneValue(cell)));
330333
}
334+
331335
//add rowResult to result vector
332336
result.add(rowResult);
333337
numResults++;
@@ -397,7 +401,7 @@ public int update(String table, String key, HashMap<String,ByteIterator> values)
397401
System.out.println("Adding field/value " + entry.getKey() + "/"+
398402
Bytes.toStringBinary(value) + " to put request");
399403
}
400-
p.add(_columnFamilyBytes,Bytes.toBytes(entry.getKey()), value);
404+
p.addColumn(_columnFamilyBytes,Bytes.toBytes(entry.getKey()), value);
401405
}
402406

403407
try

0 commit comments

Comments
 (0)