Repository: kylin
Updated Branches:
  refs/heads/2.x-staging 95d952da5 -> 9e25b2374


minor, replace HBaseResourceStore.getByScan() with a simpler Get request


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/9e25b237
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/9e25b237
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/9e25b237

Branch: refs/heads/2.x-staging
Commit: 9e25b237415fed2f94f4c5518285dd71931cc84c
Parents: 95d952d
Author: Li, Yang <yang...@ebay.com>
Authored: Thu Dec 31 11:46:34 2015 +0800
Committer: Li, Yang <yang...@ebay.com>
Committed: Thu Dec 31 11:47:27 2015 +0800

----------------------------------------------------------------------
 .../kylin/storage/hbase/HBaseResourceStore.java | 28 ++++++++------------
 1 file changed, 11 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/9e25b237/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/HBaseResourceStore.java
----------------------------------------------------------------------
diff --git 
a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/HBaseResourceStore.java
 
b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/HBaseResourceStore.java
index f1659c3..10ef6c0 100644
--- 
a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/HBaseResourceStore.java
+++ 
b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/HBaseResourceStore.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HConnection;
 import org.apache.hadoop.hbase.client.HTableInterface;
 import org.apache.hadoop.hbase.client.Put;
@@ -147,7 +148,7 @@ public class HBaseResourceStore extends ResourceStore {
 
     @Override
     protected boolean existsImpl(String resPath) throws IOException {
-        Result r = getByScan(resPath, false, false);
+        Result r = getFromHTable(resPath, false, false);
         return r != null;
     }
 
@@ -250,7 +251,7 @@ public class HBaseResourceStore extends ResourceStore {
 
     @Override
     protected RawResource getResourceImpl(String resPath) throws IOException {
-        Result r = getByScan(resPath, true, true);
+        Result r = getFromHTable(resPath, true, true);
         if (r == null)
             return null;
         else
@@ -259,7 +260,7 @@ public class HBaseResourceStore extends ResourceStore {
 
     @Override
     protected long getResourceTimestampImpl(String resPath) throws IOException 
{
-        return getTimestamp(getByScan(resPath, false, true));
+        return getTimestamp(getFromHTable(resPath, false, true));
     }
 
     @Override
@@ -320,30 +321,23 @@ public class HBaseResourceStore extends ResourceStore {
         return getAllInOneTableName() + "(key='" + resPath + "')@" + 
kylinConfig.getMetadataUrl();
     }
 
-    private Result getByScan(String path, boolean fetchContent, boolean 
fetchTimestamp) throws IOException {
-        byte[] startRow = Bytes.toBytes(path);
-        byte[] endRow = plusZero(startRow);
+    private Result getFromHTable(String path, boolean fetchContent, boolean 
fetchTimestamp) throws IOException {
+        byte[] rowkey = Bytes.toBytes(path);
 
-        Scan scan = new Scan(startRow, endRow);
-        scan.setCaching(1);
-        scan.setMaxResultSize(kylinConfig.getHBaseScanMaxResultSize());
+        Get get = new Get(rowkey);
         
         if (!fetchContent && !fetchTimestamp) {
-            scan.setFilter(new KeyOnlyFilter());
+            get.setCheckExistenceOnly(true);
         } else {
             if (fetchContent)
-                scan.addColumn(B_FAMILY, B_COLUMN);
+                get.addColumn(B_FAMILY, B_COLUMN);
             if (fetchTimestamp)
-                scan.addColumn(B_FAMILY, B_COLUMN_TS);
+                get.addColumn(B_FAMILY, B_COLUMN_TS);
         }
 
         HTableInterface table = 
getConnection().getTable(getAllInOneTableName());
         try {
-            ResultScanner scanner = table.getScanner(scan);
-            Result result = null;
-            for (Result r : scanner) {
-                result = r;
-            }
+            Result result = table.get(get);
             return result == null || result.isEmpty() ? null : result;
         } finally {
             IOUtils.closeQuietly(table);

Reply via email to