This is an automated email from the ASF dual-hosted git repository. larsh pushed a commit to branch 4.x in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x by this push: new 93a85f0 PHOENIX-6115 Avoid scanning prior row state for uncovered local indexes on immutable tables. 93a85f0 is described below commit 93a85f0e67a771408be4840906dbd854415cf207 Author: Lars <la...@apache.org> AuthorDate: Tue Sep 1 10:47:34 2020 -0700 PHOENIX-6115 Avoid scanning prior row state for uncovered local indexes on immutable tables. --- .../hbase/index/covered/data/CachedLocalTable.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 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 7091178..83bec4b 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,13 +46,11 @@ 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 CachedLocalTable(HashMap<ImmutableBytesPtr, List<Cell>> rowKeyPtrToCells) { + private CachedLocalTable(Map<ImmutableBytesPtr, List<Cell>> rowKeyPtrToCells) { this.rowKeyPtrToCells = rowKeyPtrToCells; } @@ -86,7 +86,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); } @@ -111,12 +111,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.<ImmutableBytesPtr, List<Cell>>emptyMap()); } + List<IndexMaintainer> indexTableMaintainers = indexMetaData.getIndexMaintainers(); Set<ColumnReference> getterColumnReferences = Sets.newHashSet(); for (IndexMaintainer indexTableMaintainer : indexTableMaintainers) { getterColumnReferences.addAll( @@ -149,7 +154,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;