You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Sean Laurent <or...@gmail.com> on 2009/03/04 23:24:42 UTC
Truncate Table with API
Hi all,
How do you truncate an entire table using the Java API? Shell has a TRUNCATE
command, but I can't find any matching functionality in the API itself...
all of the HTable.deleteAll() methods require a row-key.
Any suggestions would be greatly appreciated.
-Sean
Re: Truncate Table with API
Posted by Sean Laurent <or...@gmail.com>.
D'oh! I didn't even think to look at HBase.rb. Sorry 'bout that.
Thanks!
On Wed, Mar 4, 2009 at 4:34 PM, stack <st...@duboce.net> wrote:
> Here is how it works in shell Sean (from bin/HBase.rb):
>
> def truncate(tableName)
> now = Time.now
> @formatter.header()
> hTable = HTable.new(tableName)
> tableDescription = hTable.getTableDescriptor()
> puts 'Truncating ' + tableName + '; it may take a while'
> puts 'Disabling table...'
> disable(tableName)
> puts 'Dropping table...'
> drop(tableName)
> puts 'Creating table...'
> @admin.createTable(tableDescription)
> @formatter.footer(now)
> end
>
> St.Ack
>
> On Wed, Mar 4, 2009 at 2:24 PM, Sean Laurent <organicveggie@gmail.com
> >wrote:
>
> > Hi all,
> > How do you truncate an entire table using the Java API? Shell has a
> > TRUNCATE
> > command, but I can't find any matching functionality in the API itself...
> > all of the HTable.deleteAll() methods require a row-key.
> >
> > Any suggestions would be greatly appreciated.
> >
> > -Sean
> >
>
Re: Truncate Table with API
Posted by stack <st...@duboce.net>.
Here is how it works in shell Sean (from bin/HBase.rb):
def truncate(tableName)
now = Time.now
@formatter.header()
hTable = HTable.new(tableName)
tableDescription = hTable.getTableDescriptor()
puts 'Truncating ' + tableName + '; it may take a while'
puts 'Disabling table...'
disable(tableName)
puts 'Dropping table...'
drop(tableName)
puts 'Creating table...'
@admin.createTable(tableDescription)
@formatter.footer(now)
end
St.Ack
On Wed, Mar 4, 2009 at 2:24 PM, Sean Laurent <or...@gmail.com>wrote:
> Hi all,
> How do you truncate an entire table using the Java API? Shell has a
> TRUNCATE
> command, but I can't find any matching functionality in the API itself...
> all of the HTable.deleteAll() methods require a row-key.
>
> Any suggestions would be greatly appreciated.
>
> -Sean
>