Details
-
Task
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
-
Incompatible change, Reviewed
-
Description
The way to add cp to TableDescriptorBuilder is shown below.
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; }
When loading our config to create table with multiple cps, we have to write the ugly for-loop.
val builder = TableDescriptorBuilder.newBuilde(tableName) .setAAA() .setBBB() cps.map(toHBaseCp).foreach(builder.addCoprocessor) cfs.map(toHBaseCf).foreach(builder.addColumnFamily) admin.createTable(builder.build())
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.
admin.createTable(TableDescriptorBuilder.newBuilde(tableName) .addCoprocessor(cps.map(toHBaseCp).asJavaCollection) .addColumnFamily(cf.map(toHBaseCf).asJavaCollection) .setAAA() .setBBB() .build)
Attachments
Attachments
Issue Links
- relates to
-
HBASE-18776 Update coprocessor docs after HBASE-17732
- Open
- links to