hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Busbey (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HBASE-12329) Table create with duplicate column family names quietly succeeds
Date Fri, 31 Oct 2014 14:23:34 GMT

    [ https://issues.apache.org/jira/browse/HBASE-12329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14191840#comment-14191840
] 

Sean Busbey commented on HBASE-12329:
-------------------------------------

{quote}
I think it's better to be done by Misty for the ref guide? 
Hi, Misty Stanley-Jones, do you want to update the ref guide(currently Example 10.2 to show
"update an existing CF" with the new API modifyFamily in master) after this JIRA is committed?
Thanks a lot!
{quote}

Please file as a follow on ticket. If Misty wants to take it up, then she can. Otherwise someone
else can do it.

{code}
+  @Test
+  public void testModifyFamily() {
+    HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("table"));
+    byte[] familyName = Bytes.toBytes("cf");
+    HColumnDescriptor hcd = new HColumnDescriptor(familyName);
+    hcd.setBlocksize(1000);
+    htd.addFamily(hcd);
+    assertEquals(1000, htd.getFamily(familyName).getBlocksize());
+    hcd.setBlocksize(2000);
+    htd.modifyFamily(hcd);
+    assertEquals(2000, htd.getFamily(familyName).getBlocksize());
+  }
{code}

Make a second HColumnDescriptor for the update to make sure we're not just mutating state
on an old version in the htd.

{code}
+  @Test
+  public void testModifyInexistentFamily() {
+    HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("table"));
+    byte[] familyName = Bytes.toBytes("cf");
+    HColumnDescriptor hcd = new HColumnDescriptor(familyName);
+    boolean hasException = false;
+    try {
+      htd.modifyFamily(hcd);
+    } catch (Exception e) {
+      hasException = true;
+    }
+    assertTrue(hasException);
+  }
+
+  @Test
+  public void testAddDuplicateFamilies() {
+    HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("table"));
+    byte[] familyName = Bytes.toBytes("cf");
+    HColumnDescriptor hcd = new HColumnDescriptor(familyName);
+    hcd.setBlocksize(1000);
+    htd.addFamily(hcd);
+    assertEquals(1000, htd.getFamily(familyName).getBlocksize());
+    hcd.setBlocksize(2000);
+    boolean hasException = false;
+    try {
+      htd.addFamily(hcd);
+    } catch (Exception e) {
+      hasException = true;
+    }
+    assertTrue(hasException);
+  }
{code}

Use the {{@Test(expected=IllegalArgumentException.class)}} form for both of these instead.

{code}
+    if (htd.hasFamily(hcd.getName())) {
+      htd.modifyFamily(hcd);
+    } else {
+      htd.addFamily(hcd);
+    }
{code}

I'm just thinking out loud here, but do we think this is going to be a common idiom? Should
we add a third method "setFamily" that behaves like the old add?

> Table create with duplicate column family names quietly succeeds
> ----------------------------------------------------------------
>
>                 Key: HBASE-12329
>                 URL: https://issues.apache.org/jira/browse/HBASE-12329
>             Project: HBase
>          Issue Type: Bug
>          Components: Client, shell
>            Reporter: Sean Busbey
>            Assignee: Jingcheng Du
>            Priority: Minor
>         Attachments: HBASE-12329-V2.diff, HBASE-12329.diff
>
>
> From the mailing list
> {quote}
> I was expecting that it is forbidden, **but** this call does not throw any
> exception
> {code}
>         String[] families = {"cf", "cf"};
>         HTableDescriptor desc = new HTableDescriptor(name);
>         for (String cf : families) {
>           HColumnDescriptor coldef = new HColumnDescriptor(cf);
>           desc.addFamily(coldef);
>         }
>         try {
>             admin.createTable(desc);
>         } catch (TableExistsException e) {
>             throw new IOException("table \'" + name + "\' already exists");
>         }
> {code}
> {quote}
> And Ted's follow up replicates in the shell
> {code}
> hbase(main):001:0> create 't2', {NAME => 'f1'}, {NAME => 'f1'}
> The table got created - with 1 column family:
> hbase(main):002:0> describe 't2'
> DESCRIPTION
>                        ENABLED
>  't2', {NAME => 'f1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW',
> REPLICATION_SCOPE => '0 true
>  ', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL =>
> '2147483647', KEEP_DELETED
>  _CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE
> => 'true'}
> 1 row(s) in 0.1000 seconds
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message