17
17
*/
18
18
package org .apache .drill .exec .store .hbase .config ;
19
19
20
- import static org .apache .drill .exec .store .hbase .config .HBasePersistentStoreProvider .FAMILY_NAME ;
21
20
import static org .apache .drill .exec .store .hbase .config .HBasePersistentStoreProvider .QUALIFIER_NAME ;
22
21
23
22
import java .io .IOException ;
@@ -48,17 +47,19 @@ public class HBasePersistentStore<V> extends BasePersistentStore<V> {
48
47
private final String hbaseTableName ;
49
48
50
49
private final String tableName ;
50
+ private final byte [] familyName ;
51
51
private final byte [] tableNameStartKey ;
52
52
private final byte [] tableNameStopKey ;
53
53
54
- public HBasePersistentStore (PersistentStoreConfig <V > config , Table table ) {
54
+ public HBasePersistentStore (PersistentStoreConfig <V > config , Table table , byte [] family ) {
55
55
this .tableName = config .getName () + '\0' ;
56
56
this .tableNameStartKey = Bytes .toBytes (tableName ); // "tableName\x00"
57
57
this .tableNameStopKey = this .tableNameStartKey .clone ();
58
58
this .tableNameStopKey [tableNameStartKey .length -1 ] = 1 ;
59
59
this .config = config ;
60
60
this .hbaseTable = table ;
61
61
this .hbaseTableName = table .getName ().getNameAsString ();
62
+ this .familyName = family ;
62
63
}
63
64
64
65
@ Override
@@ -70,7 +71,7 @@ public PersistentStoreMode getMode() {
70
71
public boolean contains (String key ) {
71
72
try {
72
73
Get get = new Get (row (key ));
73
- get .addColumn (FAMILY_NAME , QUALIFIER_NAME );
74
+ get .addColumn (familyName , QUALIFIER_NAME );
74
75
return hbaseTable .exists (get );
75
76
} catch (IOException e ) {
76
77
throw UserException
@@ -82,7 +83,7 @@ public boolean contains(String key) {
82
83
83
84
@ Override
84
85
public V get (String key ) {
85
- return get (key , FAMILY_NAME );
86
+ return get (key , familyName );
86
87
}
87
88
88
89
protected synchronized V get (String key , byte [] family ) {
@@ -103,7 +104,7 @@ protected synchronized V get(String key, byte[] family) {
103
104
104
105
@ Override
105
106
public void put (String key , V value ) {
106
- put (key , FAMILY_NAME , value );
107
+ put (key , familyName , value );
107
108
}
108
109
109
110
protected synchronized void put (String key , byte [] family , V value ) {
@@ -122,8 +123,8 @@ protected synchronized void put(String key, byte[] family, V value) {
122
123
public synchronized boolean putIfAbsent (String key , V value ) {
123
124
try {
124
125
Put put = new Put (row (key ));
125
- put .addColumn (FAMILY_NAME , QUALIFIER_NAME , bytes (value ));
126
- return hbaseTable .checkAndPut (put .getRow (), FAMILY_NAME , QUALIFIER_NAME , null /*absent*/ , put );
126
+ put .addColumn (familyName , QUALIFIER_NAME , bytes (value ));
127
+ return hbaseTable .checkAndPut (put .getRow (), familyName , QUALIFIER_NAME , null /*absent*/ , put );
127
128
} catch (IOException e ) {
128
129
throw UserException .dataReadError (e )
129
130
.message ("Caught error while putting row '%s' into table '%s'" , key , hbaseTableName )
@@ -183,7 +184,7 @@ private class Iter implements Iterator<Entry<String, V>> {
183
184
Iter (int take ) {
184
185
try {
185
186
Scan scan = new Scan (tableNameStartKey , tableNameStopKey );
186
- scan .addColumn (FAMILY_NAME , QUALIFIER_NAME );
187
+ scan .addColumn (familyName , QUALIFIER_NAME );
187
188
scan .setCaching (Math .min (take , 100 ));
188
189
scan .setBatch (take ); // set batch size
189
190
scanner = hbaseTable .getScanner (scan );
0 commit comments