This is an automated email from the ASF dual-hosted git repository. larsh pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push: new b0f22e6 PHOENIX-6115 Avoid scanning prior row state for uncovered local indexes on immutable tables. b0f22e6 is described below commit b0f22e66874676806b12a9abaf4e72570aadfff9 Author: Lars <la...@apache.org> AuthorDate: Tue Sep 1 10:10:39 2020 -0700 PHOENIX-6115 Avoid scanning prior row state for uncovered local indexes on immutable tables. --- .../hbase/index/covered/data/CachedLocalTable.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/data/CachedLocalTable.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/data/CachedLocalTable.java index 2fd91f7..c04796d 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/data/CachedLocalTable.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/data/CachedLocalTable.java @@ -21,8 +21,10 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import org.apache.hadoop.hbase.Cell; @@ -44,14 +46,12 @@ import org.apache.phoenix.schema.types.PVarbinary; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Sets; -import java.util.HashMap; - public class CachedLocalTable implements LocalHBaseState { - private final HashMap<ImmutableBytesPtr, List<Cell>> rowKeyPtrToCells; + private final Map<ImmutableBytesPtr, List<Cell>> rowKeyPtrToCells; private final Region region; - private CachedLocalTable(HashMap<ImmutableBytesPtr, List<Cell>> rowKeyPtrToCells, Region region) { + private CachedLocalTable(Map<ImmutableBytesPtr, List<Cell>> rowKeyPtrToCells, Region region) { this.rowKeyPtrToCells = rowKeyPtrToCells; this.region = region; } @@ -95,7 +95,7 @@ public class CachedLocalTable implements LocalHBaseState { } @VisibleForTesting - public static CachedLocalTable build(HashMap<ImmutableBytesPtr, List<Cell>> rowKeyPtrToCells) { + public static CachedLocalTable build(Map<ImmutableBytesPtr, List<Cell>> rowKeyPtrToCells) { return new CachedLocalTable(rowKeyPtrToCells, null); } @@ -105,7 +105,7 @@ public class CachedLocalTable implements LocalHBaseState { Region region) throws IOException { if(indexMetaData.getReplayWrite() != null) { - return new CachedLocalTable(new HashMap<ImmutableBytesPtr,List<Cell>>(), region); + return new CachedLocalTable(Collections.emptyMap(), region); } return preScanAllRequiredRows(dataTableMutationsWithSameRowKeyAndTimestamp, indexMetaData, region); } @@ -124,12 +124,17 @@ public class CachedLocalTable implements LocalHBaseState { Collection<? extends Mutation> dataTableMutationsWithSameRowKeyAndTimestamp, PhoenixIndexMetaData indexMetaData, Region region) throws IOException { - List<IndexMaintainer> indexTableMaintainers = indexMetaData.getIndexMaintainers(); Set<KeyRange> keys = new HashSet<KeyRange>(dataTableMutationsWithSameRowKeyAndTimestamp.size()); for (Mutation mutation : dataTableMutationsWithSameRowKeyAndTimestamp) { + if (indexMetaData.requiresPriorRowState(mutation)) { keys.add(PVarbinary.INSTANCE.getKeyRange(mutation.getRow())); + } + } + if (keys.isEmpty()) { + return new CachedLocalTable(Collections.emptyMap(), region); } + List<IndexMaintainer> indexTableMaintainers = indexMetaData.getIndexMaintainers(); Set<ColumnReference> getterColumnReferences = Sets.newHashSet(); for (IndexMaintainer indexTableMaintainer : indexTableMaintainers) { getterColumnReferences.addAll( @@ -162,7 +167,7 @@ public class CachedLocalTable implements LocalHBaseState { scan.setFilter(skipScanFilter); } - HashMap<ImmutableBytesPtr, List<Cell>> rowKeyPtrToCells = + Map<ImmutableBytesPtr, List<Cell>> rowKeyPtrToCells = new HashMap<ImmutableBytesPtr, List<Cell>>(); try (RegionScanner scanner = region.getScanner(scan)) { boolean more = true;