com.flipkart.hbaseobjectmapper.RecordsIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hbase-object-mapper Show documentation
Show all versions of hbase-object-mapper Show documentation
HBase ORM is a light-weight, thread-safe and performant library that enables:
[1] object-oriented access of HBase rows (Data Access Object) with minimal code and good testability.
[2] reading from and/or writing to HBase tables in Hadoop MapReduce jobs.
This can also be used as an ORM for Bigtable.
The newest version!
package com.flipkart.hbaseobjectmapper;
import org.apache.hadoop.hbase.client.Result;
import java.util.Iterator;
/**
* Iterator implementation, for internal use only
*
* @param Data type of record
*/
@SuppressWarnings("rawtypes")
class RecordsIterator implements Iterator {
private final HBObjectMapper hbObjectMapper;
private final Class clazz;
private final Iterator resultIterator;
public RecordsIterator(HBObjectMapper hbObjectMapper, Class clazz, Iterator resultIterator) {
this.hbObjectMapper = hbObjectMapper;
this.clazz = clazz;
this.resultIterator = resultIterator;
}
@Override
public boolean hasNext() {
return resultIterator.hasNext();
}
@Override
@SuppressWarnings("unchecked")
public T next() {
Result result = resultIterator.next();
return (T) hbObjectMapper.readValue(result, clazz);
}
}