2017-03-06 68 views
0

使用hbase-client v。1.1.2。在HTableDescriptor中更改表名的建議方法是什麼?

HTableDescriptor API提供2層公共構造:

public HTableDescriptor(final TableName name) {... 
    ... 
    public HTableDescriptor(final HTableDescriptor desc) {... 

和2更改表名不贊成的方法:

@Deprecated 
    public HTableDescriptor setName(byte[] name) { 
    setName(TableName.valueOf(name)); 
    return this; 
    } 

    @Deprecated 
    public HTableDescriptor setName(TableName name) { 
    this.name = name; 
    setMetaFlags(this.name); 
    return this; 
    } 

沒有關於用戶應該做的事情,而不是評論。

因此,要克隆HTableDescriptor,選項是(a)使用第一個ctor並手動複製所有字段或(b)使用第二個ctor,並使用不贊成使用的方法更改表名稱。

這樣做的建議方法是什麼?爲什麼API似乎不鼓勵通過ctor直接更改名稱?

回答

0

看來你正在尋找this

/** 
    * Construct a table descriptor by cloning the descriptor passed as a parameter 
    * but using a different table name. 
    * <p> 
    * Makes a deep copy of the supplied descriptor. 
    * Can make a modifiable descriptor from an UnmodifyableHTableDescriptor. 
    * @param name Table name. 
    * @param desc The descriptor. 
    */ 
public HTableDescriptor(final TableName name, final HTableDescriptor desc) { 
+0

可悲的是,我使用1.12不包括此構造函數出於某種原因。 – jordanpg

+0

@jordanpg好吧,如果你看看github代碼,你會發現,即使在主分支已棄用的方法仍然是改變表名的唯一方法。 – AdamSkywalker