You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Chia-Ping Tsai (JIRA)" <ji...@apache.org> on 2018/03/02 10:26:00 UTC
[jira] [Comment Edited] (HBASE-20119) Introduce a pojo class to
carry coprocessor information in order to make TableDescriptorBuilder
accept multiple cp at once
[ https://issues.apache.org/jira/browse/HBASE-20119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16383401#comment-16383401 ]
Chia-Ping Tsai edited comment on HBASE-20119 at 3/2/18 10:25 AM:
-----------------------------------------------------------------
-Also we can remove the TableDescriptorBuilder#addCoprocessorWithSpec if we enable the new pojo class to parse the passed string-
TableDescriptorBuilder#addCoprocessorWithSpec should be removed since it exposes how we format the cp information.
was (Author: chia7712):
Also we can remove the TableDescriptorBuilder#addCoprocessorWithSpec if we enable the new pojo class to parse the passed string
> Introduce a pojo class to carry coprocessor information in order to make TableDescriptorBuilder accept multiple cp at once
> --------------------------------------------------------------------------------------------------------------------------
>
> Key: HBASE-20119
> URL: https://issues.apache.org/jira/browse/HBASE-20119
> Project: HBase
> Issue Type: Task
> Reporter: Chia-Ping Tsai
> Assignee: Chia-Ping Tsai
> Priority: Minor
> Fix For: 2.0.0
>
>
> The way to add cp to TableDescriptorBuilder is shown below.
> {code:java}
> public TableDescriptorBuilder addCoprocessor(String className) throws IOException {
> return addCoprocessor(className, null, Coprocessor.PRIORITY_USER, null);
> }
> public TableDescriptorBuilder addCoprocessor(String className, Path jarFilePath,
> int priority, final Map<String, String> kvs) throws IOException {
> desc.addCoprocessor(className, jarFilePath, priority, kvs);
> return this;
> }
> public TableDescriptorBuilder addCoprocessorWithSpec(final String specStr) throws IOException {
> desc.addCoprocessorWithSpec(specStr);
> return this;
> }{code}
> When loading our config to create table with multiple cps, we have to write the ugly for-loop.
> {code:java}
> val builder = TableDescriptorBuilder.newBuilde(tableName)
> .setAAA()
> .setBBB()
> cps.map(toHBaseCp).foreach(builder.addCoprocessor)
> cfs.map(toHBaseCf).foreach(builder.addColumnFamily)
> admin.createTable(builder.build())
> {code}
> If we introduce a pojo to carry the cp data and add the method accepting multiple cps and cfs, it is easier to exercise the fluent interface of TableDescriptorBuilder.
> {code:java}
> admin.createTable(TableDescriptorBuilder.newBuilde(tableName)
> .addCoprocessor(cps.map(toHBaseCp).asJavaCollection)
> .addColumnFamily(cf.map(toHBaseCf).asJavaCollection)
> .setAAA()
> .setBBB()
> .build){code}
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)