phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramkrish86 <...@git.apache.org>
Subject [GitHub] phoenix pull request: Phoenix-180
Date Fri, 19 Sep 2014 07:44:26 GMT
Github user ramkrish86 commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/12#discussion_r17772474
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
---
    @@ -668,11 +677,89 @@ private PTable getTable(RegionScanner scanner, long clientTimeStamp,
long tableT
                   addColumnToTable(results, colName, famName, colKeyValues, columns, saltBucketNum
!= null);
               }
             }
    -
    +        PName physicalTableName = physicalTables.isEmpty() ? PNameFactory.newName(SchemaUtil.getTableName(
    +                schemaName.getString(), tableName.getString())) : physicalTables.get(0);
    +        PTableStats stats = updateStatsInternal(physicalTableName.getBytes(), columns);
             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 updateStatsInternal(byte[] tableNameBytes, List<PColumn>
columns)
    +            throws IOException {
    +        List<PName> family = Lists.newArrayListWithExpectedSize(columns.size());
    +        for (PColumn column : columns) {
    +            PName familyName = column.getFamilyName();
    +            if (familyName != null) {
    +                family.add(familyName);
    +            }
    +        }
    +        HTable statsHTable = null;
    +        try {
    +            // Can we do a new HTable instance here? Or get it from a pool or cache of
these instances?
    +            statsHTable = new HTable(this.env.getConfiguration(),
    +                    PhoenixDatabaseMetaData.SYSTEM_STATS_NAME_BYTES);
    +            Scan s = new Scan();
    +            if (tableNameBytes != null) {
    +                // Check for an efficient way here
    +                s.setStartRow(tableNameBytes);
    +                s.setStopRow(ByteUtil.nextKey(tableNameBytes));
    +            }
    +            ResultScanner scanner = statsHTable.getScanner(s);
    +            Result result = null;
    +            byte[] fam = null;
    +            List<byte[]> guidePosts = Lists.newArrayListWithExpectedSize(columns.size());
    +            TreeMap<byte[], List<byte[]>> guidePostsPerCf = new TreeMap<byte[],
List<byte[]>>(Bytes.BYTES_COMPARATOR);
    +            while ((result = scanner.next()) != null) {
    +                CellScanner cellScanner = result.cellScanner();
    +                while (cellScanner.advance()) {
    +                    Cell current = cellScanner.current();
    +                    // For now collect only guide posts
    +                    if (Bytes.equals(current.getQualifierArray(), current.getQualifierOffset(),
    +                            current.getQualifierLength(), PhoenixDatabaseMetaData.GUIDE_POSTS_BYTES,
0,
    +                            PhoenixDatabaseMetaData.GUIDE_POSTS_BYTES.length)) {
    +                        byte[] cfInCell = StatisticsUtils.getCFFromRowKey(tableNameBytes,
current.getRowArray(),
    +                                current.getRowOffset(), current.getRowLength());
    +                        if (fam == null) {
    +                            fam = cfInCell;
    +                        } else if (!Bytes.equals(fam, cfInCell)) {
    +                            // Sort all the guide posts
    +                            Collections.sort(guidePosts, Bytes.BYTES_COMPARATOR);
    --- End diff --
    
    Am sorting only here. Not at the end.  Anyway can change it to the end.


---
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