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

Matteo Bertozzi commented on HBASE-11733:
-----------------------------------------

ok, instead of going in this discussion is the extra allocation costing more..
I'll propose another change, which will result in the same number of 
allocations.

We already allocate 1 object, which is the ObserverContext
if the CoprocessorOperation extends the ObserverContext, you have 1 allocations 
that does both.
if we want to push also for the coprocessor list may be empty and in the old 
code we avoided the allocation we can also do: coprocessors.isEmpty() ? null : 
new CoprocessorOperation()
{code}
public void preCreateTable(final HTableDescriptor htd, final HRegionInfo[] 
regions)
    throws IOException {
  execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() {
    @Override
    public void call(MasterObserver oserver, 
ObserverContext<MasterCoprocessorEnvironment> ctx)
        throws IOException {
      oserver.preCreateTable(ctx, htd, regions);
    }
  });
}
{code}
thoughts?

> Avoid copy-paste in Master/Region CoprocessorHost
> -------------------------------------------------
>
>                 Key: HBASE-11733
>                 URL: https://issues.apache.org/jira/browse/HBASE-11733
>             Project: HBase
>          Issue Type: Bug
>          Components: Coprocessors
>            Reporter: Matteo Bertozzi
>            Assignee: Matteo Bertozzi
>            Priority: Trivial
>             Fix For: 2.0.0
>
>         Attachments: HBASE-11733-0.98-v1.patch, HBASE-11733-v0.patch
>
>
> all the methods of MasterCoprocessorHost and RegionCoprocessorHost are 
> copy-paste, and a couple of them have some missing fixes.
> The body of each function is the same, the only difference is the call to the 
> specific coprocessor.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to