From issues-return-3825-archive-asf-public=cust-asf.ponee.io@phoenix.apache.org Tue Jan 8 01:49:25 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id B3CAE180647 for ; Tue, 8 Jan 2019 01:49:24 +0100 (CET) Received: (qmail 43817 invoked by uid 500); 8 Jan 2019 00:49:23 -0000 Mailing-List: contact issues-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list issues@phoenix.apache.org Received: (qmail 43808 invoked by uid 99); 8 Jan 2019 00:49:23 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jan 2019 00:49:23 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 85E26E11F9; Tue, 8 Jan 2019 00:49:23 +0000 (UTC) From: BinShi-SecularBird To: issues@phoenix.apache.org Reply-To: issues@phoenix.apache.org References: In-Reply-To: Subject: [GitHub] phoenix pull request #425: PHOENIX-5069 please go to JIRA to see the detaile... Content-Type: text/plain Message-Id: <20190108004923.85E26E11F9@git1-us-west.apache.org> Date: Tue, 8 Jan 2019 00:49:23 +0000 (UTC) Github user BinShi-SecularBird commented on a diff in the pull request: https://github.com/apache/phoenix/pull/425#discussion_r245847336 --- Diff: phoenix-core/src/main/java/org/apache/phoenix/query/GuidePostsCache.java --- @@ -85,39 +99,47 @@ public GuidePostsCache(ConnectionQueryServices queryServices, Configuration conf }) // Log removals at TRACE for debugging .removalListener(new PhoenixStatsCacheRemovalListener()) - // Automatically load the cache when entries are missing - .build(isStatsEnabled ? new StatsLoader() : new EmptyStatsLoader()); + // Automatically load the cache when entries need to be refreshed + .build(cacheLoader); } /** - * {@link CacheLoader} implementation for the Phoenix Table Stats cache. + * {@link PhoenixStatsLoader} implementation for the Stats Loader. */ - protected class StatsLoader extends CacheLoader { + protected class StatsLoaderImpl implements PhoenixStatsLoader { @Override - public GuidePostsInfo load(GuidePostsKey statsKey) throws Exception { + public boolean needsLoad() { + // Whenever it's called, we try to load stats from stats table + // no matter it has been updated or not. + return true; + } + + @Override + public GuidePostsInfo loadStats(GuidePostsKey statsKey, GuidePostsInfo prevGuidepostInfo) throws Exception { @SuppressWarnings("deprecation") - Table statsHTable = queryServices.getTable(SchemaUtil.getPhysicalName( + TableName tableName = SchemaUtil.getPhysicalName( PhoenixDatabaseMetaData.SYSTEM_STATS_NAME_BYTES, - queryServices.getProps()).getName()); + queryServices.getProps()); + Table statsHTable = queryServices.getTable(tableName.getName()); try { GuidePostsInfo guidePostsInfo = StatisticsUtil.readStatistics(statsHTable, statsKey, HConstants.LATEST_TIMESTAMP); traceStatsUpdate(statsKey, guidePostsInfo); return guidePostsInfo; } catch (TableNotFoundException e) { // On a fresh install, stats might not yet be created, don't warn about this. - logger.debug("Unable to locate Phoenix stats table", e); - return GuidePostsInfo.NO_GUIDEPOST; + logger.debug("Unable to locate Phoenix stats table: " + tableName.toString(), e); + return prevGuidepostInfo; } catch (IOException e) { - logger.warn("Unable to read from stats table", e); + logger.warn("Unable to read from stats table: " + tableName.toString(), e); --- End diff -- Comment from @karanmehta93 (copied from prev PR https://github.com/apache/phoenix/pull/416): nit: remove this comment ---