paolo@bimodesign.com | +34 608 61 64 10

NoSQL

        

HBase/Java migration to 1.1.2

There are several changes when migrating from HBase 0.98 to 1.1.2 and in case of using method java to interface to it, we have to consider to modify in this way. Note: using Thrift is not necesary change anything.
Connection
From

public HBaseDal(String hbaseZookeeperQuorum) throws IOException
{
	hbaseConf = HBaseConfiguration.create();
	hbaseConf.set("hbase.zookeeper.quorum", hbaseZookeeperQuorum);
	treeTableV2 = new HTable(hbaseConf, HBaseDefs.TestTable.TableName);
	nodeCache = new HashMap();
}

to

import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Connection;

public HBaseDal(String hbaseZookeeperQuorum) throws IOException
{
	hbaseConf = HBaseConfiguration.create();
	hbaseConf.set("hbase.zookeeper.quorum", hbaseZookeeperQuorum);
	Connection con = ConnectionFactory.createConnection(hbaseConf);
	treeTableV2 = (HTable) con.getTable(TableName.valueOf(algo.ruta.HBaseDefs.TestTable.TableName));
	nodeCache = new HashMap();
}


Row and GetFamily/GetValue
From

Result result = TestTable.get(vectorGet);
for(KeyValue kv : result.raw())
{
	VectorColumn vc = new VectorColumn(HBaseDefs.TestTable.FamilyEnumFromColumnFamily(kv.getFamily()),kv.getQualifier(), kv.getValue());
	if(!vc.deleted)
		return vc;
}

to

import org.apache.hadoop.hbase.Cell;
import util.hbase.CellUtils;

for(Cell kv : result.rawCells())
{
	VectorColumn vc = new VectorColumn(HBaseDefs.TestTable.FamilyEnumFromColumnFamily(CellUtils.GetCellFamily(kv)), CellUtils.GetCellQualifier(kv), CellUtils.GetCellValue(kv));
	if(!vc.deleted)
		return vc;
}


put add
From

put.add()

to

put.addColumn()


Delete family
From

delete.deleteFamily(HBaseDefs.TestTable.TestFamily.FamilyName);

to

delete.addFamily(HBaseDefs.TestTable.TestFamily.FamilyName);