or do something like this:
HTablePool pool = new HTablePool(config, maxSize, new HTableFactory() {
@Override
public HTableInterface createHTableInterface(Configuration config,
byte[] tableName) {
try {
HTable table= new HTable(config, tableName);
*table.setAutoFlush(false);*
return table;
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}
});
pass a user define HTableInterfaceFactory to instantiate htabl pool
On Fri, Aug 12, 2011 at 3:33 PM, Allan Yan <[email protected]> wrote:
> HTablePool uses HTableInterfaceFactory to return a HTableInterface.
> While HTable implements HTableInterface, it doesn't mean calling
> getTable method will always return HTable. Depends on how your
> HTablePool is instantiated, your HTablePool instance may or may not
> gives you HTable instance when you call getTable. For example, if you
> create HTablePool instance without passing your own
> HTableInterfaceFactory instance, as following:
>
> HTablePool htablePool = new HTablePool(config, 10);
>
> Internally, a HTableFactory is created and used for returning a HTable
> instance whenever the htablePool.getTable() method is called.
>
> However, to make your code bug free, you could check the object type
> first before you cast it , like this:
>
> HTableInterface table = tablePool.getTable(myTable);
> if(table instanceof HTable)
> ((HTable)table).setAutoFlush(true)
>
>
> On Thu, Aug 11, 2011 at 11:32 PM, Steinmaurer Thomas
> <[email protected]> wrote:
> > Typecast the return value of the table pool to HTable and you shoud be
> > fine. E.g. I'm doing this:
> >
> > ...
> > HTable table = (HTable) tablePool.getTable(this.hbaseTable);
> > table.setAutoFlush(this.hbaseAPIuseAutoFlush);
> > table.setWriteBufferSize(this.hbaseAPIwriteBufferSize);
> > ...
> >
> >
> > lg,
> > Thomas
> >
> > -----Original Message-----
> > From: [email protected] [mailto:[email protected]]
> > Sent: Freitag, 12. August 2011 08:01
> > To: [email protected]
> > Subject: autoFlush
> >
> > I want to do client-side write-caching to hbase. I see the setAutoFlush
> > method in HTable. I do not see that in the HTableInterface that is
> > returned from HTablePool. Is there something equivalent to setAutoFlush
> > on table instances from HTablePool?
> >
> > Thanks!
> >
>