Announcement Announcement Module
Collapse
No announcement yet.
How to use the Scan object with HbaseTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use the Scan object with HbaseTemplate

    Hi,

    I have posted this same question at stackoverflow also, but still did not get a reply for that. Can someone please give me an idea of this?

    I have plugged in Spring for Hadoop and it works well. Later I wanted to use a filter with a
    Code:
    org.apache.hadoop.hbase.client.Scan
    object to scan the data from HBase like I have shown below.

    Code:
    String regEx = "^" + "Tom Hanks";
    Filter regExFilter = new RowFilter(CompareFilter.CompareOp.EQUAL,
        new RegexStringComparator(regEx));
    
    Scan scanner = new Scan();
    scanner.setFilter(regExFilter);
    
    scanner.addColumn(Bytes.toBytes(dto.ColumnFamily()),
        Bytes.toBytes(dto.getQualifier()));
    scanner.addColumn(Bytes.toBytes(dto.ColumnFamily()),
        Bytes.toBytes(dto.getQualifier()));
    
    List<Object> list = hTemplate.find(dto.getableName(), scanner,
            new TestMapper());
    There are rows in the Hbase table. But the returned list from above statement is always zero. When I debug the code, debug pointer did not come to the TestMapper class, My TestMapper class is below.

    Code:
    public class TestMapper implements RowMapper<Object> {
    
        @Override
        public Object mapRow(Result result, int arg1) throws Exception {
    
        Test dto = Util.getDto();
        SmallDto smallDto = new SmallDto();
    
        int value = Util.getIntValue(result.getValue(
            Bytes.toBytes(dto.getColumnFamily()),
            Bytes.toBytes(dto.getCigaretteQual())));
    
        smallDto.setValueCount(value);
    
    return smallDto;
    }
    }
    Why I'am getting zero records each and every time. Is this not the way how I should use the
    Code:
    Scan
    object?
Working...
X