Skip to content
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

PHOENIX-5795 Supporting selective queries for index rows updated conc… #740

Closed
wants to merge 7 commits into from

Conversation

kadirozde
Copy link
Contributor

…urrently

Thread t = new Thread(runnables[i]);
t.start();
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't you wait for the threads to finish running?

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 there in the next line

for (Cell cell : cellList) {
if (Bytes.compareTo(CellUtil.cloneFamily(cell), family) == 0 &&
Bytes.compareTo(CellUtil.cloneQualifier(cell), columnReference.getQualifier() ) == 0) {
has = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Change cell names and family to indicate whether they belong to index or data table.

I am not sure I understand this loop. If we have index and and data cell having same family and qualifier we just break? Should not it be if they are not equal break?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see line 177. The multiMutationMap attribute holds the data table pending rows. Also indexMaintainer.getIndexedColumns() returns the data column references for indexed columns. The data columns are grouped into three classes, pk columns (data table pk columns), the indexed columns (the columns for which we want to have indexing; they form the prefix for the primary key for the index table (after salt and tenant id)) and covered columns. The purpose of the loop is to find out if all the indexed columns are included in the pending data table mutation pointed by multiMutation. I will add these comments to the code.

if (copyMutations) {
// Add the mutation to the batch set
ImmutableBytesPtr row = new ImmutableBytesPtr(m.getRow());
MultiMutation stored = mutationsMap.get(row);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please note I removed these lines for setting the timestamp on cells as they were redundant. It is already done before calling this method. Also note that this method is not called for the rebuild path. This another reason for restructuring. I think I also made the code for a bit more readable.

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 good, just a few nits.

// Truncate, rebuild and verify the index table
PTable pIndexTable = PhoenixRuntime.getTable(conn, indexName);
TableName physicalTableName =
org.apache.hadoop.hbase.TableName.valueOf(pIndexTable.getPhysicalName().getBytes());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: don't have to fully qualify TableName since it's imported

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

}
boolean has = false;
for (Cell cell : cellList) {
if (Bytes.compareTo(CellUtil.cloneFamily(cell), family) == 0 &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be replaced with CellUtil.matchingColumn(Cell, family, qualifier)

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 will use it. Thx

context.rowLocks.clear();
throw new IOException("One of the concurrent mutations does not have all indexed columns. " +
"The batch needs to be retried " +
c.getEnvironment().getRegion().getRegionInfo().getTable().getNameAsString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to pass the TableName in rather than the whole ObserverContext, which has a lot of important dependencies that don't relate to this method.

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.

+1, thanks @kadirozde . Looks like you need to rebase though.

@kadirozde kadirozde closed this Jun 19, 2020
@kadirozde kadirozde deleted the 5795 branch June 19, 2020 05:22
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