You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ma...@apache.org on 2015/05/25 08:11:40 UTC

[08/11] incubator-kylin git commit: KYLIN-697 fix mock htable bug

KYLIN-697 fix mock htable bug


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

Branch: refs/heads/new697
Commit: 4d323f8b9763871f9acffd13137ae8df4e912c68
Parents: 6e74d6d
Author: honma <ho...@ebay.com>
Authored: Mon May 25 10:32:03 2015 +0800
Committer: honma <ho...@ebay.com>
Committed: Mon May 25 11:24:16 2015 +0800

----------------------------------------------------------------------
 .../apache/kylin/common/util/MockHTable.java    |  7 +-
 .../kylin/job/tools/HBaseRowDigestTest.java     | 84 --------------------
 2 files changed, 5 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/4d323f8b/common/src/main/java/org/apache/kylin/common/util/MockHTable.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/kylin/common/util/MockHTable.java b/common/src/main/java/org/apache/kylin/common/util/MockHTable.java
index d54fe4b..c60a7a5 100644
--- a/common/src/main/java/org/apache/kylin/common/util/MockHTable.java
+++ b/common/src/main/java/org/apache/kylin/common/util/MockHTable.java
@@ -516,7 +516,11 @@ public class MockHTable implements HTableInterface {
                 continue;
             }
             for (KeyValue kv : delete.getFamilyMap().get(family)) {
-                data.get(row).get(kv.getFamily()).remove(kv.getQualifier());
+                if (kv.isDeleteFamily()) {
+                    data.get(row).get(kv.getFamily()).clear();
+                } else {
+                    data.get(row).get(kv.getFamily()).remove(kv.getQualifier());
+                }
             }
             if (data.get(row).get(family).isEmpty()) {
                 data.get(row).remove(family);
@@ -676,7 +680,6 @@ public class MockHTable implements HTableInterface {
     public <R extends Message> void batchCoprocessorService(Descriptors.MethodDescriptor methodDescriptor, Message request, byte[] startKey, byte[] endKey, R responsePrototype, Batch.Callback<R> callback) throws ServiceException, Throwable {
         throw new NotImplementedException();
 
-
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/4d323f8b/job/src/test/java/org/apache/kylin/job/tools/HBaseRowDigestTest.java
----------------------------------------------------------------------
diff --git a/job/src/test/java/org/apache/kylin/job/tools/HBaseRowDigestTest.java b/job/src/test/java/org/apache/kylin/job/tools/HBaseRowDigestTest.java
deleted file mode 100644
index 95e4b7f..0000000
--- a/job/src/test/java/org/apache/kylin/job/tools/HBaseRowDigestTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.apache.kylin.job.tools;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.client.HConnection;
-import org.apache.hadoop.hbase.client.HTableInterface;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.ResultScanner;
-import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
-import org.apache.kylin.common.persistence.HBaseConnection;
-import org.apache.kylin.common.util.BytesUtil;
-import org.apache.kylin.common.util.HBaseMetadataTestCase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- */
-@Ignore
-public class HBaseRowDigestTest extends HBaseMetadataTestCase {
-
-    @Before
-    public void setUp() throws Exception {
-        this.createTestMetadata();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        this.cleanupTestMetadata();
-    }
-
-    private static final byte[] CF = "f".getBytes();
-    private static final byte[] QN = "c".getBytes();
-    static ImmutableBytesWritable k = new ImmutableBytesWritable();
-    static ImmutableBytesWritable v = new ImmutableBytesWritable();
-
-    @Test
-    public static void test() throws IOException {
-        String hbaseUrl = "hbase"; // use hbase-site.xml on classpath
-        HConnection conn = null;
-        HTableInterface table = null;
-        try {
-            conn = HBaseConnection.get(hbaseUrl);
-            table = conn.getTable("KYLIN_II_YTYWP3CQGJ");
-            ResultScanner scanner = table.getScanner(CF, QN);
-            StringBuffer sb = new StringBuffer();
-            while (true) {
-                Result r = scanner.next();
-                if (r == null)
-                    break;
-
-                Cell[] cells = r.rawCells();
-                Cell c = cells[0];
-
-                k.set(c.getRowArray(), c.getRowOffset(), c.getRowLength());
-                v.set(c.getValueArray(), c.getValueOffset(), c.getValueLength());
-
-                byte[] row = k.copyBytes();
-                byte[] value = v.copyBytes();
-                //                byte[] row = r.getRow();
-                //                byte[] value = r.getValue(CF, QN);
-                //
-                sb.append("row length: " + row.length + "\r\n");
-                sb.append(BytesUtil.toReadableText(row) + "\r\n");
-                sb.append("value length: " + value.length + "\r\n");
-                sb.append(BytesUtil.toReadableText(value) + "\r\n");
-            }
-            System.out.println(sb.toString());
-            FileUtils.writeStringToFile(new File("/Users/honma/Desktop/a3"), sb.toString());
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            if (table != null)
-                table.close();
-            if (conn != null)
-                conn.close();
-        }
-
-    }
-}