Thank you! Mingtao Sent from iPhone
> On Aug 11, 2014, at 2:32 PM, Ted Yu <[email protected]> wrote: > > You don't need to close table for every Put. > > But table should be closed at some point - before your client exits. > > > On Mon, Aug 11, 2014 at 11:28 AM, Mingtao Zhang <[email protected]> > wrote: > >> Hi, >> >> I am looking at some code like this. >> >> public void put(String tableName, Put put) { >> HTableInterface table = null; >> try { >> table = connection.getTable(tableName); >> table.put(put); >> } catch (Throwable e) { >> log.error("put to HBase failed", e); >> } finally { >> if (null != table) { >> try { >> // >> http://hbase.apache.org/book/perf.writing.html#perf.hbase.client.autoflush >> table.close(); >> } catch (Exception e) { >> log.error("close HTable failed", e); >> } >> } >> } >> } >> >> By looking at the documentation, conncetion.getTable(tableName) will be a >> 'cheap' operation. But table.close() will flush things to network. >> >> I wonder do I need to call table.close()? or it will be managed by HBase >> client? >> >> Best Regards, >> Mingtao >>
