You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2022/11/08 23:25:00 UTC

[GitHub] [phoenix] tkhurana commented on a diff in pull request #1506: PHOENIX-6761 : Phoenix Client Side Metadata Caching Improvement

tkhurana commented on code in PR #1506:
URL: https://github.com/apache/phoenix/pull/1506#discussion_r1017217852


##########
phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaDataImpl.java:
##########
@@ -46,36 +48,52 @@ public class PMetaDataImpl implements PMetaData {
     private PMetaDataCache metaData;
     private final TimeKeeper timeKeeper;
     private final PTableRefFactory tableRefFactory;
+    private final long updateCacheFrequency;
     private HashMap<String, PTableKey> physicalNameToLogicalTableMap = new HashMap<>();
+    private final Object metricsLock = new Object();
     
-    public PMetaDataImpl(int initialCapacity, ReadOnlyProps props) {
-        this(initialCapacity, TimeKeeper.SYSTEM, props);
+    public PMetaDataImpl(int initialCapacity, long updateCacheFrequency, ReadOnlyProps props) {
+        this(initialCapacity, updateCacheFrequency, TimeKeeper.SYSTEM, props);
     }
 
-    public PMetaDataImpl(int initialCapacity, TimeKeeper timeKeeper, ReadOnlyProps props) {
+    public PMetaDataImpl(int initialCapacity, long updateCacheFrequency, TimeKeeper timeKeeper, ReadOnlyProps props) {
+
         this(new PMetaDataCache(initialCapacity, props.getLong(
             QueryServices.MAX_CLIENT_METADATA_CACHE_SIZE_ATTRIB,
-            QueryServicesOptions.DEFAULT_MAX_CLIENT_METADATA_CACHE_SIZE), timeKeeper,
-                PTableRefFactory.getFactory(props)), timeKeeper, PTableRefFactory.getFactory(props));
+            QueryServicesOptions.DEFAULT_MAX_CLIENT_METADATA_CACHE_SIZE), timeKeeper),
+                timeKeeper, PTableRefFactory.getFactory(props),
+                updateCacheFrequency);
     }
 
-    private PMetaDataImpl(PMetaDataCache metaData, TimeKeeper timeKeeper, PTableRefFactory tableRefFactory) {
+    private PMetaDataImpl(PMetaDataCache metaData, TimeKeeper timeKeeper,
+                          PTableRefFactory tableRefFactory, long updateCacheFrequency) {
         this.timeKeeper = timeKeeper;
         this.metaData = metaData;
         this.tableRefFactory = tableRefFactory;
+        this.updateCacheFrequency = updateCacheFrequency;
     }
 
-    @Override
-    public PMetaDataImpl clone() {
-        return new PMetaDataImpl(new PMetaDataCache(this.metaData), this.timeKeeper, this.tableRefFactory);
+    private void updateGlobalMetric(PTableRef pTableRef) {

Review Comment:
   I don't think you need a lock to just increment counters



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org