All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lordofthejars.nosqlunit.demo.hbase.PersonManager Maven / Gradle / Ivy

There is a newer version: 1.0.0-rc.5
Show newest version
package com.lordofthejars.nosqlunit.demo.hbase;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Result;

import ch.lambdaj.function.convert.Converter;

public class PersonManager {

	private Configuration configuration;
	
	public PersonManager(Configuration configuration) {
		this.configuration = configuration;		
	}
	
	public String getCarByPersonName(String personName) throws IOException {
		HTable table = new HTable(configuration, "person");
		Get get = new Get("john".getBytes());
		Result result = table.get(get);
		
		return new String(result.getValue(toByteArray().convert("personFamilyName"), toByteArray().convert("car")));
	}
	
	private Converter toByteArray() {
		return new Converter() {

			@Override
			public byte[] convert(String element) {
				return element.getBytes();
			}
		};
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy