Search code examples
javaapihbase

HBase setMaxVersions java API doesn't work


I have a problem: when I execute, with eclipse neon:

HTableDescriptor descriptor = new HTableDescriptor(TableName.valueOf("shoppingcart"));
HColumnDescriptor cd = new HColumnDescriptor(Bytes.toBytes("items"));
cd.setMaxVersions(4);

There is no change in hbase shell. If I execute:

decribe 'shoppingcart', 

It returns VERSION: 3

This is my java code. Is that false? Or, did I misunderstand the HBase functionality?


Solution

  • Update on HColumnDescriptor is not propagated to HBase server. Add these lines:

    HBaseAdmin hBaseAdmin = new HBaseAdmin(conf);
    hBaseAdmin.modifyTable("shoppingcart", descriptor);