phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JamesRTaylor <...@git.apache.org>
Subject [GitHub] phoenix pull request: Phoenix 180
Date Tue, 26 Aug 2014 04:13:27 GMT
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/8#discussion_r16695090
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
---
    @@ -664,14 +698,161 @@ private PTable getTable(RegionScanner scanner, long clientTimeStamp,
long tableT
               } else {
                   addColumnToTable(results, colName, famName, colKeyValues, columns, saltBucketNum
!= null);
               }
    +        }        
    +        byte[] tenIdBytes = QueryConstants.EMPTY_BYTE_ARRAY;
    +        if (tenantId != null) {
    +            tenIdBytes = tenantId.getBytes();
             }
    -
    +        byte[] schNameInBytes = QueryConstants.EMPTY_BYTE_ARRAY;
    +        if (schemaName != null) {
    +            schNameInBytes = Bytes.toBytes(schemaName.getString());
    +        }
    +        PTableStats stats = updateStats(SchemaUtil.getTableKey(tenIdBytes, schNameInBytes,
tableNameBytes));
             return PTableImpl.makePTable(tenantId, schemaName, tableName, tableType, indexState,
timeStamp, 
                 tableSeqNum, pkName, saltBucketNum, columns, tableType == INDEX ? dataTableName
: null, 
                 indexes, isImmutableRows, physicalTables, defaultFamilyName, viewStatement,
disableWAL, 
    -            multiTenant, viewType, viewIndexId, indexType);
    +            multiTenant, viewType, viewIndexId, indexType, stats);
         }
     
    +    private PTableStats updateStats(final byte[] tableNameBytes) {
    +        lock.readLock().lock();
    +        try {
    +            PTableStats stats = tableStatsMap.get(Bytes.toString(tableNameBytes));
    +            return stats;
    +        } finally {
    +            lock.readLock().unlock();
    +        }
    +    }
    +    
    +    private void updateStatsInternal(byte[] tableNameBytes, RegionCoprocessorEnvironment
env)
    --- End diff --
    
    Rather than have a separate cache for this, I'd rather piggyback on the existing cache.
How about if we just read the stats anytime we re-load the PTable? Then an updateStats would
just need to invalidate the cache entry for the table. Next time the table is accessed, the
stats table would be re-read.
    
    One side note: we'll want to make sure that the PStats info has a getEstimatedByteSize()
and that PTable takes this into account for it's getEstimatedByteSize() so that this is accounted
for in the size of each cached PTable.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message