From d8874fbc21525a5af2db3d8b9edd6e67fa1b5572 Mon Sep 17 00:00:00 2001 From: Ashish Singhi Date: Thu, 30 Oct 2014 12:33:07 +0530 Subject: [PATCH] HBASE-12375 LoadIncrementalHFiles fails to load data in table when CF name starts with '_' Signed-off-by: stack --- .../mapreduce/LoadIncrementalHFiles.java | 4 --- .../mapreduce/TestLoadIncrementalHFiles.java | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.java index 855417d6634..8376e8556c8 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.java @@ -203,8 +203,6 @@ public class LoadIncrementalHFiles extends Configured implements Tool { continue; } Path familyDir = stat.getPath(); - // Skip _logs, etc - if (familyDir.getName().startsWith("_")) continue; byte[] family = familyDir.getName().getBytes(); Path[] hfiles = FileUtil.stat2Paths(fs.listStatus(familyDir)); for (Path hfile : hfiles) { @@ -850,8 +848,6 @@ public class LoadIncrementalHFiles extends Configured implements Tool { continue; } Path familyDir = stat.getPath(); - // Skip _logs, etc - if (familyDir.getName().startsWith("_")) continue; byte[] family = familyDir.getName().getBytes(); hcd = new HColumnDescriptor(family); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java index b13e28e8df6..cf7dcea65d7 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestLoadIncrementalHFiles.java @@ -431,5 +431,33 @@ public class TestLoadIncrementalHFiles { String[] args = { "directory", "nonExistingTable" }; loader.run(args); } + + @Test + public void testTableWithCFNameStartWithUnderScore() throws Exception { + Path dir = util.getDataTestDirOnTestFS("cfNameStartWithUnderScore"); + FileSystem fs = util.getTestFileSystem(); + dir = dir.makeQualified(fs.getUri(), fs.getWorkingDirectory()); + String family = "_cf"; + Path familyDir = new Path(dir, family); + + byte[] from = Bytes.toBytes("begin"); + byte[] to = Bytes.toBytes("end"); + Configuration conf = util.getConfiguration(); + String tableName = "mytable_cfNameStartWithUnderScore"; + Table table = util.createTable(TableName.valueOf(tableName), family); + HFileTestUtil.createHFile(conf, fs, new Path(familyDir, "hfile"), Bytes.toBytes(family), + QUALIFIER, from, to, 1000); + + LoadIncrementalHFiles loader = new LoadIncrementalHFiles(conf); + String[] args = { dir.toString(), tableName }; + try { + loader.run(args); + assertEquals(1000, util.countRows(table)); + } finally { + if (null != table) { + table.close(); + } + } + } }