You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by "steve.boyle@connexity.com" <st...@connexity.com> on 2011/08/12 08:01:11 UTC

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!

RE: autoFlush

Posted by "steve.boyle@connexity.com" <st...@connexity.com>.
Thanks for the direction on autoFlush, I'll give it a shot.

Regards,
Steve

-----Original Message-----
From: zizon [mailto:zzdtsv@gmail.com] 
Sent: Friday, August 12, 2011 12:43 AM
To: user@hbase.apache.org
Subject: Re: autoFlush

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 <ha...@gmail.com> 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 
> <Th...@scch.at> 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: steve.boyle@connexity.com [mailto:steve.boyle@connexity.com]
> > Sent: Freitag, 12. August 2011 08:01
> > To: user@hbase.apache.org
> > 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!
> >
>

Re: autoFlush

Posted by zizon <zz...@gmail.com>.
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 <ha...@gmail.com> 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
> <Th...@scch.at> 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: steve.boyle@connexity.com [mailto:steve.boyle@connexity.com]
> > Sent: Freitag, 12. August 2011 08:01
> > To: user@hbase.apache.org
> > 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!
> >
>

Re: autoFlush

Posted by Allan Yan <ha...@gmail.com>.
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
<Th...@scch.at> 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: steve.boyle@connexity.com [mailto:steve.boyle@connexity.com]
> Sent: Freitag, 12. August 2011 08:01
> To: user@hbase.apache.org
> 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!
>

RE: autoFlush

Posted by Steinmaurer Thomas <Th...@scch.at>.
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: steve.boyle@connexity.com [mailto:steve.boyle@connexity.com] 
Sent: Freitag, 12. August 2011 08:01
To: user@hbase.apache.org
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!