2017-02-24 104 views

回答

1

HBase API不提供checkAnd*方法的批量選項。 HBase API由本地異步的gRPC protobuf API支持。您可以使用基礎API構建高吞吐量應用程序。

警告的一句話:這在我們面向公衆的文檔中基本沒有記載,但源代碼應該提供足夠的指導來說明如何構建應用程序。此API的活躍用戶包括Apache Beam的BigtableIO。 TODO:document this feature,隨時對該功能發表評論或投票。

在高級別,這裏是你必須做的:

AbstractBigtableConnection btConn = (AbstractBigtableConnection) connection; 

    // BigtableSession can also be constructed by passing in a BigtableOptions. 
    BigtableSession session = btConn.getSession(); 

    // AsyncExecutor encapsulates the notion of a "batch" of RPCs 
    // that need to be completed as a unit. 
    AsyncExecutor executor = session.createAsyncExecutor(); 

    // This listenable future will inform you when the request is done, 
    // and if there were any exceptions. 
    // You can attach a FutureCallback 
    ListenableFuture<CheckAndMutateRowResponse> response = 
     executor.checkAndMutateRowAsync(checkAndMutateRowRequest); 

    // do more async work 

    // Make sure all of the RPCs are complete. 
    asyncExecutor.flush(); 

僅供參考,這裏是關於ListenableFuture and FutureCallback的更多信息。您也可以深入探討BigtableBufferedMutator以獲得有關如何處理異常的建議。您可以通過執行BigtableTable.checkAndDelete來創建CheckAndMutateRowRequest

+0

非常感謝!對我有意義 –

+0

嗨,我也嘗試在'BigtableTable.checkAndDelete(..)'中創建'CheckAndMutateRowRequest'。但我一直無法弄清楚如何獲得'HBaseRequestAdapter'。我可否知道最簡單的方法是什麼?我有一個'AbstractBigtableConnection'和'BigtableTable'。謝謝! –