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/26 17:20:48 UTC
[02/32] 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/43ce8bc2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/43ce8bc2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/43ce8bc2
Branch: refs/heads/0.8.0
Commit: 43ce8bc2528867121c8cb02a381e326079f69e3d
Parents: 8e1d6f5
Author: honma <ho...@ebay.com>
Authored: Mon May 25 10:32:03 2015 +0800
Committer: honma <ho...@ebay.com>
Committed: Tue May 26 23:11:52 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/43ce8bc2/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/43ce8bc2/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();
- }
-
- }
-}