Skip to content

EN C02 simplehbase config

zhang-xzhi edited this page Dec 21, 2014 · 5 revisions

To use simplehbaseclient, we need the following config.

  • HBaseDataSource config hbase data source.
  • HBaseTableConfig config mapping of htable and HQL.
  • SimpleHbaseRuntimeSetting config simplehbase runtime setting and plug-in.

HBaseDataSource

Config info about hbase.

hbaseConfigResources

//hbase native config recource, such as hbase,zk file.
private List<Resource>      hbaseConfigResources;

htablePoolType(optional)

default to use HTablePool.    
if set to SimpleHbaseHTablePool, use SimpleHbaseHTablePool of simplehbase.
SimpleHbaseHTablePool support periodic flush HTable.

poolMaxSize(optional)

default to 10.
Pool'maxSize, apply on HTablePool and SimpleHbaseHTablePool.

tableFactory(optional)

default to use HTableFactory of HBase.
client can customize tableFactory. simplehbase provides SimpleHbaseHTableFactory, can config HTable's autoflush and executorService.
apply on HTablePool and SimpleHbaseHTablePool.

flushInterval(optional)

when use SimpleHbaseHTablePool, set the interval of flushCommits for HTable.

htablePoolService(optional)

client can customize htablePoolService.

HBaseTableConfig

Resource configResource simplehbase config file per htable.

One simple sample

	<HBaseTableSchema tableName="MyRecordV_Allen3" defaultFamily="MyRecordFamily">
		<HBaseColumnSchema qualifier="id" typeName="int" />
		<HBaseColumnSchema qualifier="name" typeName="string" />
		<HBaseColumnSchema qualifier="date" typeName="date" />
		<HBaseColumnSchema qualifier="gender" typeName="allen.demo.Gender" />
		<HBaseColumnSchema qualifier="age" typeName="int" />
	</HBaseTableSchema>
	
	
	<statements>	
		
		<statement id="queryByNameAndAge">
			select where id greaterequal #id#
			<isPropertyAvailable prepend="and" property="name">
				name equal #name#
			</isPropertyAvailable>
			<isPropertyAvailable prepend="and" property="age">
				age greater #age#
			</isPropertyAvailable>
		</statement>	
		
		<statement id="queryById">
			select where id equal #id#			
		</statement>			
				
	</statements>	
</SimpleHbase>   

###HBaseTableSchema

tableName mandatory

defaultFamily optional

rowKeyHandlerName optional convert hbase rowkey bytes to RowKey java object. default is BytesRowKeyHandler.

###HBaseColumnSchema

family : If defaultFamily is not specifed, then family must be specifed.	

qualifier : mandatory	

typeName : mandatory java type name
We can use abbreviation on following type, otherwise the full class name must be specifed.
byte short int long char float double boolean 
Byte Short Int Long Char Float Double Boolean 
string String date Date

handler
optional. The handler which convert java object and bytes in hbase back and forth, if not present, the default handler will be used.	

###statements simplehbase's query statement.

id : mandatory.

##SimpleHbaseRuntimeSetting(optional) config scan caching size, delete batch size,user-defined rowkey generating func,user-defined literal value interpreter.

###scanCachingSize default to 20

###deleteBatchSize default to 50

###intelligentScanSize if intelligentScanSize is ture, the simplehbase will use startIndex and length of QueryExtInfo to compute scanCachingSize. e.g. startIndex is 5, length is 10, compute 15 of scancachingsize. default to false.

###literalInterpreterList(optional)

###rowKeyTextFuncList(optional)