From 169a4aaa32c149c8112eb61857fad864b99b13d9 Mon Sep 17 00:00:00 2001 From: MansurAshraf Date: Sun, 12 Jan 2014 19:33:07 -0600 Subject: [PATCH] clean up htable after finishing get and put. Fixes #206 --- .../main/scala/com/twitter/storehaus/hbase/HBaseStore.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/storehaus-hbase/src/main/scala/com/twitter/storehaus/hbase/HBaseStore.scala b/storehaus-hbase/src/main/scala/com/twitter/storehaus/hbase/HBaseStore.scala index b583c755..8b43336d 100644 --- a/storehaus-hbase/src/main/scala/com/twitter/storehaus/hbase/HBaseStore.scala +++ b/storehaus-hbase/src/main/scala/com/twitter/storehaus/hbase/HBaseStore.scala @@ -1,5 +1,5 @@ /* - * Copyright 2013 Twitter inc. + * Copyright 2014 Twitter inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,6 +74,7 @@ trait HBaseStore { val result = tbl.get(g) val value = result.getValue(columnFamily.as[StringBytes], column.as[StringBytes]) + tbl.close() Option(value).map(v => valueInj.invert(v).get) } @@ -84,11 +85,13 @@ trait HBaseStore { p.add(columnFamily.as[StringBytes], column.as[StringBytes], valueInj(v)) val tbl = pool.getTable(table) tbl.put(p) + tbl.close() } case (k, None) => futurePool { val delete = new Delete(keyInj(k)) val tbl = pool.getTable(table) tbl.delete(delete) + tbl.close() } } }