You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ya...@apache.org on 2021/01/07 22:41:10 UTC
[phoenix] branch 4.x updated: PHOENIX-6295 : Fix non-static inner
classes for better memory utilization (#1054)
This is an automated email from the ASF dual-hosted git repository.
yanxinyi 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 a747c3a PHOENIX-6295 : Fix non-static inner classes for better memory utilization (#1054)
a747c3a is described below
commit a747c3ad873d8a33510c7c5916e9030237ef750e
Author: Viraj Jasani <vj...@apache.org>
AuthorDate: Fri Jan 8 04:11:02 2021 +0530
PHOENIX-6295 : Fix non-static inner classes for better memory utilization (#1054)
---
.../main/java/org/apache/phoenix/cache/TenantCacheImpl.java | 8 ++++----
.../java/org/apache/phoenix/compile/ExpressionCompiler.java | 4 ++--
.../org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java | 7 ++++---
.../java/org/apache/phoenix/filter/RowKeyComparisonFilter.java | 4 ++--
.../index/covered/filter/ApplyAndFilterDeletesFilter.java | 2 +-
.../phoenix/hbase/index/covered/update/IndexUpdateManager.java | 5 ++++-
.../java/org/apache/phoenix/iterate/BaseResultIterators.java | 2 +-
.../org/apache/phoenix/iterate/RoundRobinResultIterator.java | 2 +-
.../main/java/org/apache/phoenix/join/HashCacheFactory.java | 2 +-
.../org/apache/phoenix/mapreduce/index/IndexScrutinyTool.java | 6 +++---
.../org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java | 4 ++--
.../main/java/org/apache/phoenix/schema/MetaDataClient.java | 4 ++--
.../phoenix/schema/stats/StatisticsCollectionRunTracker.java | 10 +++++-----
13 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
index 22a7050..e7fc43d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
@@ -65,7 +65,7 @@ public class TenantCacheImpl implements TenantCache {
private final long EVICTION_MARGIN_BYTES = 10000000;
- private class CacheEntry implements Comparable<CacheEntry>, Closeable {
+ private static class CacheEntry implements Comparable<CacheEntry>, Closeable {
private ImmutableBytesPtr cacheId;
private ImmutableBytesWritable cachePtr;
private int hits;
@@ -247,9 +247,9 @@ public class TenantCacheImpl implements TenantCache {
entry = getIfPresent(cacheId);
if (entry == null) {
entry = new CacheEntry(
- cacheId, cachePtr, cacheFactory, txState, chunk,
- usePersistentCache, useProtoForIndexMaintainer,
- clientVersion);
+ cacheId, cachePtr, cacheFactory, txState, chunk,
+ usePersistentCache, useProtoForIndexMaintainer,
+ clientVersion);
getServerCaches().put(cacheId, entry);
if (usePersistentCache) {
getPersistentServerCaches().put(cacheId, entry);
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
index a993cea..0addea9 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
@@ -1237,7 +1237,7 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
return new PDatumImpl(expression, pDataTypeInput);
}
- private class PDatumImpl implements PDatum {
+ private static class PDatumImpl implements PDatum {
private final boolean isNullable;
private final PDataType dataType;
@@ -1280,7 +1280,7 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
}
- private class ExpressionDeterminism {
+ private static class ExpressionDeterminism {
private ArithmeticParseNode node;
private List<Expression> children;
private PDataType theType;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index e25e055..cde1eaf 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@ -2402,8 +2402,8 @@ TABLE_FAMILY_BYTES, TABLE_SEQ_NUM_BYTES);
releaseRowLocks(region, locks);
if(dropTableStats) {
Thread statsDeleteHandler = new Thread(new StatsDeleteHandler(env,
- loadedTable, tableNamesToDelete, sharedTablesToDelete),
- "thread-statsdeletehandler");
+ loadedTable, tableNamesToDelete, sharedTablesToDelete),
+ "thread-statsdeletehandler");
statsDeleteHandler.setDaemon(true);
statsDeleteHandler.start();
}
@@ -2421,7 +2421,7 @@ TABLE_FAMILY_BYTES, TABLE_SEQ_NUM_BYTES);
}
}
- class StatsDeleteHandler implements Runnable {
+ private static class StatsDeleteHandler implements Runnable {
PTable deletedTable;
List<byte[]> physicalTableNames;
List<MetaDataProtocol.SharedTableState> sharedTableStates;
@@ -2465,6 +2465,7 @@ TABLE_FAMILY_BYTES, TABLE_SEQ_NUM_BYTES);
}
}
}
+
private RowLock acquireLock(Region region, byte[] lockKey, List<RowLock> locks) throws IOException {
RowLock rowLock = region.getRowLock(lockKey, false);
if (rowLock == null) {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/filter/RowKeyComparisonFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/filter/RowKeyComparisonFilter.java
index df81957..9655cd8 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/filter/RowKeyComparisonFilter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/RowKeyComparisonFilter.java
@@ -43,7 +43,7 @@ public class RowKeyComparisonFilter extends BooleanExpressionFilter {
private boolean evaluate = true;
private boolean keepRow = false;
- private RowKeyTuple inputTuple = new RowKeyTuple();
+ private final RowKeyTuple inputTuple = new RowKeyTuple();
private byte[] essentialCF;
public RowKeyComparisonFilter() {
@@ -79,7 +79,7 @@ public class RowKeyComparisonFilter extends BooleanExpressionFilter {
return keepRow ? ReturnCode.INCLUDE_AND_NEXT_COL : ReturnCode.NEXT_ROW;
}
- private final class RowKeyTuple extends BaseTuple {
+ private static final class RowKeyTuple extends BaseTuple {
private byte[] buf;
private int offset;
private int length;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java
index de04e9a..38b77a6 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/filter/ApplyAndFilterDeletesFilter.java
@@ -199,7 +199,7 @@ public class ApplyAndFilterDeletesFilter extends FilterBase {
* Hint the next column-qualifier after the given keyvalue. We can't be smart like in the
* ScanQueryMatcher since we don't know the columns ahead of time.
*/
- class DeleteColumnHinter implements Hinter {
+ private static class DeleteColumnHinter implements Hinter {
@Override
public KeyValue getHint(KeyValue kv) {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/update/IndexUpdateManager.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/update/IndexUpdateManager.java
index 99234f0..ad72cb4 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/update/IndexUpdateManager.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/update/IndexUpdateManager.java
@@ -17,6 +17,7 @@
*/
package org.apache.phoenix.hbase.index.covered.update;
+import java.io.Serializable;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
@@ -43,7 +44,9 @@ import com.google.common.primitives.Longs;
public class IndexUpdateManager {
public Comparator<Mutation> COMPARATOR = new MutationComparator();
- class MutationComparator implements Comparator<Mutation> {
+
+ private static class MutationComparator implements Comparator<Mutation>,
+ Serializable {
@Override
public int compare(Mutation o1, Mutation o2) {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
index 151216c..3023ad9 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
@@ -1282,7 +1282,7 @@ public abstract class BaseResultIterators extends ExplainTable implements Result
.getInt(QueryConstants.HASH_JOIN_CACHE_RETRIES, QueryConstants.DEFAULT_HASH_JOIN_CACHE_RETRIES));
}
- class ScanWrapper {
+ private static class ScanWrapper {
Scan scan;
public Scan getScan() {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/RoundRobinResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/RoundRobinResultIterator.java
index 232cdd6..5d33292 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/RoundRobinResultIterator.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/RoundRobinResultIterator.java
@@ -291,7 +291,7 @@ public class RoundRobinResultIterator implements ResultIterator {
* keeps track of the tuple the {@link PeekingResultIterator} read in the previous next() call before it ran out of
* underlying scanner cache.
*/
- private class RoundRobinIterator implements PeekingResultIterator {
+ private static class RoundRobinIterator implements PeekingResultIterator {
private PeekingResultIterator delegate;
private Tuple tuple;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/join/HashCacheFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/join/HashCacheFactory.java
index ecf9d57..8eabd35 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/join/HashCacheFactory.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/join/HashCacheFactory.java
@@ -82,7 +82,7 @@ public class HashCacheFactory implements ServerCacheFactory {
}
@Immutable
- private class HashCacheImpl implements HashCache {
+ private static class HashCacheImpl implements HashCache {
private final Map<ImmutableBytesPtr,List<Tuple>> hashCache;
private final MemoryChunk memoryChunk;
private final boolean singleValueOnly;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyTool.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyTool.java
index b0d4d2c..f404244 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyTool.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyTool.java
@@ -205,7 +205,7 @@ public class IndexScrutinyTool extends Configured implements Tool {
System.exit(exitCode);
}
- class JobFactory {
+ private static class JobFactory {
Connection connection;
Configuration configuration;
private boolean useSnapshot;
@@ -456,8 +456,8 @@ public class IndexScrutinyTool extends Configured implements Tool {
schemaName, dataTable, indexTable, useSnapshot, ts, batchSize, basePath,
outputFormat, outputMaxRows));
JobFactory jobFactory =
- new JobFactory(connection, configuration, batchSize, useSnapshot, ts,
- outputInvalidRows, outputFormat, basePath, outputMaxRows, tenantId, mapperClass);
+ new JobFactory(connection, configuration, batchSize, useSnapshot, ts,
+ outputInvalidRows, outputFormat, basePath, outputMaxRows, tenantId, mapperClass);
// If we are running the scrutiny with both tables as the source, run two separate jobs,
// one for each direction
if (SourceTable.BOTH.equals(sourceTable)) {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java
index 1621e12..0034f2c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java
@@ -841,7 +841,7 @@ public class IndexUpgradeTool extends Configured implements Tool {
tenantId);
for (String viewIndex : viewIndexes) {
IndexInfo indexInfo = new IndexInfo(schemaName, viewName,
- tenantId == null ? GLOBAL_INDEX_ID : tenantId, viewIndex);
+ tenantId == null ? GLOBAL_INDEX_ID : tenantId, viewIndex);
indexInfos.put(viewIndex, indexInfo);
}
}
@@ -890,7 +890,7 @@ public class IndexUpgradeTool extends Configured implements Tool {
" AND TENANT_ID = \'" + tenantId + "\'" : " AND TENANT_ID IS NULL");
}
- private class IndexInfo {
+ private static class IndexInfo {
final private String schemaName;
final private String baseTable;
final private String tenantId;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 9226b35..919e072 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -5358,7 +5358,7 @@ public class MetaDataClient {
return changingPhoenixTableProperty;
}
- class MetaProperties{
+ private static class MetaProperties {
private Boolean isImmutableRowsProp = null;
private Boolean multiTenantProp = null;
private Boolean disableWALProp = null;
@@ -5484,7 +5484,7 @@ public class MetaDataClient {
}
}
- class MetaPropertiesEvaluated{
+ private static class MetaPropertiesEvaluated {
private Boolean isImmutableRows;
private Boolean multiTenant = null;
private Boolean disableWAL = null;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollectionRunTracker.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollectionRunTracker.java
index c312b9e..960ffdf 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollectionRunTracker.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollectionRunTracker.java
@@ -105,7 +105,7 @@ public class StatisticsCollectionRunTracker {
* @return true if UPDATE STATISTICS wasn't already running on the region, false otherwise.
*/
public boolean addUpdateStatsCommandRegion(HRegionInfo regionInfo, Set<byte[]> familySet) {
- return updateStatsRegions.add(new ColumnFamilyRegionInfo(regionInfo,familySet));
+ return updateStatsRegions.add(new ColumnFamilyRegionInfo(regionInfo, familySet));
}
/**
@@ -113,7 +113,7 @@ public class StatisticsCollectionRunTracker {
* @return true if UPDATE STATISTICS was running on the region, false otherwise.
*/
public boolean removeUpdateStatsCommandRegion(HRegionInfo regionInfo, Set<byte[]> familySet) {
- return updateStatsRegions.remove(new ColumnFamilyRegionInfo(regionInfo,familySet));
+ return updateStatsRegions.remove(new ColumnFamilyRegionInfo(regionInfo, familySet));
}
/**
@@ -125,9 +125,9 @@ public class StatisticsCollectionRunTracker {
return executor.submit(c);
}
- class ColumnFamilyRegionInfo {
- private HRegionInfo regionInfo;
- private Set<byte[]> familySet;
+ private static class ColumnFamilyRegionInfo {
+ private final HRegionInfo regionInfo;
+ private final Set<byte[]> familySet;
public ColumnFamilyRegionInfo(HRegionInfo regionInfo, Set<byte[]> familySet) {
this.regionInfo = regionInfo;