Skip to content

HBase Specific Features

xamry edited this page Mar 8, 2013 · 11 revisions

Zookeeper host and port

Add below entry into XML configuration file:

<property name="hbase.zookeeper.quorum" value="localhost"></property>
<property name="hbase.zookeeper.property.clientPort" value="2181"></property>

Column Family related configuration

You can specify column-family specific configurations and they will be applied on corresponding column families. Just put below comma-separated entry into XML file. A sample file is given below:

<?xml version="1.0" encoding="UTF-8"?>
<clientProperties>
    <datastores>
        <dataStore>
	    <name>hbase</name>
	        <connection>
		    <properties>
		        <property name="hbase.zookeeper.quorum" value="localhost"></property>
			<property name="hbase.zookeeper.property.clientPort" value="2181"></property>
                    </properties>
		</connection>
	        <schemas>
		    <schema>
		        <name>USERXYZ</name>
			<tables>
			    <table>
			        <name>age</name>
				<properties>
				    <property name="TTL" value="12345678" />
				    <property name="VERSIONS" value="6" />
				    <property name="MIN_VERSIONS" value="3" />
				    <property name="COMPRESSION" value="GZ" />
				    <property name="COMPRESSION_COMPACT" value="GZ" />
				</properties>
			    </table>
			    <table>
			        <name>address</name>
				<properties>
				    <property name="TTL" value="1234567" />
				    <property name="VERSIONS" value="5" />
				    <property name="MIN_VERSIONS" value="2" />
				    <property name="COMPRESSION" value="GZ" />
				    <property name="COMPRESSION_COMPACT" value="GZ" />
				</properties>
			    </table>
			</tables>
		    </schema>
		</schemas>
	    </dataStore>
	</datastores>
</clientProperties>

Filters and Filter Lists

Kundera supports HBase Client Request Filters in order to perform even more granular queries. An example code snippet from here is shown below.

EntityManagerFactory emf = Persistence.createEntityManagerFactory("hbase_pu");
EntityManager em = emf.createEntityManager();

/* Returns you a map of persistence unit and Kundera Clients */ 
Map<String, Client> clients = (Map<String, Client>) em.getDelegate();

Client client = clients.get("hbase_pu");

//Create filter, it will apply on all operation on this entity manager
Filter f = new QualifierFilter();
f = new SingleColumnValueFilter("PERSON_NAME".getBytes(), "PERSON_NAME".getBytes(), CompareOp.EQUAL,
                "vivek".getBytes());
((HBaseClient) client).setFilter(f);  // Set filter in client

em.clear();    

Query q = em.createQuery("Select p from Person p");
List<Person> results = q.getResultList();   //Filter on PERSON_NAME automatically applied

em.close();
emf.close();

<<< Back to Datastore Specific Configuration

Home

Clone this wiki locally