Skip to content

PHOENIX-5565 Unify index update structures in IndexRegionObserver and…#625

Closed
kadirozde wants to merge 1 commit intoapache:masterfrom
kadirozde:5565
Closed

PHOENIX-5565 Unify index update structures in IndexRegionObserver and…#625
kadirozde wants to merge 1 commit intoapache:masterfrom
kadirozde:5565

Conversation

@kadirozde
Copy link
Contributor

… IndexCommitter

@kadirozde kadirozde requested a review from gjacoby126 November 10, 2019 20:49
HTableInterfaceReference hTableInterfaceReference =
new HTableInterfaceReference(new ImmutableBytesPtr(tableName));
List<Pair<Mutation, byte[]>> localIndexUpdates = indexUpdates.removeAll(hTableInterfaceReference);
if (localIndexUpdates == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think removeAll will return an empty list rather than null. Let's add a size check here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you think so? Please notice the removeAll returns List.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood your comment. I thought you implied that we cannot use removeAll here. I will add the size check although it is not needed for correctness as the rest of the code will not do anything if the list is empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@gjacoby126 gjacoby126 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good simplification

// The collection of index mutations that will be applied before the data table mutations. The empty column (i.e.,
// the verified column) will have the value false ("unverified") on these mutations
private Collection<Pair<Mutation, byte[]>> preIndexUpdates = Collections.emptyList();
private ListMultimap<HTableInterfaceReference, Mutation> preIndexUpdates;
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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!

Copy link
Contributor Author

@kadirozde kadirozde Dec 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
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()));
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@swaroopak swaroopak closed this Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants