-
Notifications
You must be signed in to change notification settings - Fork 1k
PHOENIX-5565 Unify index update structures in IndexRegionObserver and… #625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| import java.util.Collection; | ||
| import java.util.List; | ||
|
|
||
| import com.google.common.collect.ListMultimap; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.hbase.Cell; | ||
| import org.apache.hadoop.hbase.Stoppable; | ||
|
|
@@ -34,6 +35,8 @@ | |
| import org.apache.phoenix.coprocessor.BaseScannerRegionObserver.ReplayWrite; | ||
| import org.apache.phoenix.hbase.index.Indexer; | ||
| import org.apache.phoenix.hbase.index.covered.IndexMetaData; | ||
| import org.apache.phoenix.hbase.index.table.HTableInterfaceReference; | ||
| import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr; | ||
| import org.apache.phoenix.index.PhoenixIndexMetaData; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
@@ -79,28 +82,20 @@ public IndexMetaData getIndexMetaData(MiniBatchOperationInProgress<Mutation> min | |
| return this.delegate.getIndexMetaData(miniBatchOp); | ||
| } | ||
|
|
||
| public Collection<Pair<Pair<Mutation, byte[]>, byte[]>> getIndexUpdates( | ||
| public void getIndexUpdates(ListMultimap<HTableInterfaceReference, Pair<Mutation, byte[]>> indexUpdates, | ||
| MiniBatchOperationInProgress<Mutation> miniBatchOp, | ||
| Collection<? extends Mutation> mutations, | ||
| IndexMetaData indexMetaData) throws Throwable { | ||
| // notify the delegate that we have started processing a batch | ||
| this.delegate.batchStarted(miniBatchOp, indexMetaData); | ||
|
|
||
| // Avoid the Object overhead of the executor when it's not actually parallelizing anything. | ||
| ArrayList<Pair<Pair<Mutation, byte[]>, byte[]>> results = new ArrayList<>(mutations.size()); | ||
| for (Mutation m : mutations) { | ||
| Collection<Pair<Mutation, byte[]>> updates = delegate.getIndexUpdate(m, indexMetaData); | ||
| if (PhoenixIndexMetaData.isIndexRebuild(m.getAttributesMap())) { | ||
| for (Pair<Mutation, byte[]> update : updates) { | ||
| update.getFirst().setAttribute(BaseScannerRegionObserver.REPLAY_WRITES, | ||
| BaseScannerRegionObserver.REPLAY_INDEX_REBUILD_WRITES); | ||
| } | ||
| } | ||
| for (Pair<Mutation, byte[]> update : updates) { | ||
| results.add(new Pair<>(update, m.getRow())); | ||
| indexUpdates.put(new HTableInterfaceReference(new ImmutableBytesPtr(update.getSecond())), new Pair<>(update.getFirst(), m.getRow())); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: wouldn't it be more efficient to reuse HTableInterfaceReference rather than create N of them when we're likely mutating only a small number of tables?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not easy to optimize this as for each data table mutation we get updates for all index tables. If we do not create a separate reference for each update, then we need to maintain a hash or list of references and then need to look up on or search them. This may not be more efficient. Let me know if you had something else to suggest here. |
||
| } | ||
| } | ||
| return results; | ||
| } | ||
|
|
||
| public Collection<Pair<Mutation, byte[]>> getIndexUpdate( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't have to be this patch, but we should consider extracting this ListMultimap<HTableInterfaceReference, Mutation> into a class of some kind with named accessor methods so that code dealing with it can be at a higher level of abstraction / more self-documenting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a jira for this? @gjacoby126 If not, I ll file one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no JIRA that I know of, @swaroopak. Thanks!
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is a JIRA on this. It is https://issues.apache.org/jira/browse/PHOENIX-5339
@swaroopak