Github user twdsilva commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/324#discussion_r210784966
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
 ---
    @@ -1431,10 +1439,33 @@ private PTable getTable(RegionScanner scanner, long 
clientTimeStamp, long tableT
             // server while holding this lock is a bad idea and likely to 
cause contention.
             return PTableImpl.makePTable(tenantId, schemaName, tableName, 
tableType, indexState, timeStamp, tableSeqNum,
                     pkName, saltBucketNum, columns, parentSchemaName, 
parentTableName, indexes, isImmutableRows, physicalTables, defaultFamilyName,
    -                viewStatement, disableWAL, multiTenant, storeNulls, 
viewType, viewIndexId, indexType,
    +                viewStatement, disableWAL, multiTenant, storeNulls, 
viewType, viewIndexType, viewIndexId, indexType,
                     rowKeyOrderOptimizable, transactionProvider, 
updateCacheFrequency, baseColumnCount,
                     indexDisableTimestamp, isNamespaceMapped, 
autoPartitionSeq, isAppendOnlySchema, storageScheme, encodingScheme, cqCounter, 
useStatsForParallelization);
         }
    +    private Long getViewIndexId(Cell[] tableKeyValues, PDataType 
viewIndexType) {
    +        Cell viewIndexIdKv = tableKeyValues[VIEW_INDEX_ID_INDEX];
    +        return viewIndexIdKv == null ? null :
    +                decodeViewIndexId(viewIndexIdKv, viewIndexType);
    +    }
    +
    +    /**
    +     * Returns viewIndexId based on its underlying data type
    +     *
    +     * @param tableKeyValues
    +     * @param viewIndexType
    +     * @return
    +     */
    +    private Long decodeViewIndexId(Cell viewIndexIdKv, PDataType 
viewIndexType) {
    +        return 
viewIndexType.getCodec().decodeLong(viewIndexIdKv.getValueArray(),
    +                viewIndexIdKv.getValueOffset(), SortOrder.getDefault());
    +    }
    +
    +    private PDataType getViewIndexType(Cell[] tableKeyValues) {
    +        Cell dataTypeKv = tableKeyValues[VIEW_INDEX_ID_DATA_TYPE];
    --- End diff --
    
    I think you need a null check here similar to the getViewIndexId. If the 
view index was created by an old client it won't have the 
VIEW_INDEX_ID_DATA_TYPE and you can assume its a short.


---

Reply via email to