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

    https://github.com/apache/phoenix/pull/329#discussion_r211447285
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java ---
    @@ -303,6 +303,54 @@ public static long getSequenceNumber(List<Mutation> 
tableMetaData) {
             return getSequenceNumber(getPutOnlyTableHeaderRow(tableMetaData));
         }
         
    +    /**
    +     * Returns the sequence number of the parent table if we have a 
mutation that is updating the
    +     * parent table's encoded column qualifier
    +     */
    +    public static long 
getParentSequenceNumberForAddColumnMutations(List<Mutation> tableMetaData) {
    +        byte[] parentTableRowKey = null;
    +        for (Mutation tableMutation : tableMetaData) {
    +            List<Cell> kvs =
    +                    tableMutation.getFamilyCellMap()
    +                            
.get(PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES);
    +            if (kvs != null) {
    +                for (Cell kv : kvs) {
    +                    if (Bytes.compareTo(kv.getQualifierArray(), 
kv.getQualifierOffset(),
    +                        kv.getQualifierLength(), 
PhoenixDatabaseMetaData.TABLE_SEQ_NUM_BYTES, 0,
    +                        
PhoenixDatabaseMetaData.TABLE_SEQ_NUM_BYTES.length) == 0) {
    +                        parentTableRowKey = kv.getRow();
    +                    }
    +                }
    +            }
    +        }
    +        if (parentTableRowKey == null) {
    +            throw new IllegalStateException(
    +                    "Could not find mutation to update the encoded column 
qualifier of the parent table ");
    +        }
    +        
    +        byte[] rowKeyPrefix = ByteUtil.concat(parentTableRowKey, 
ByteUtil.EMPTY_BYTE_ARRAY);
    --- End diff --
    
    Sorry I had a bug here in the first loop we should look for 
COLUMN_QUALIFIER_COUNTER_BYTES. 
    tableMetadata will contain two Puts that have TABLE_SEQ_NUM, one is for the 
view where we update the COLUMN_COUNT and another is for the physical table 
where we update the COLUMN_QUALIFIER_COUNTER. I think I could assume the second 
put will always be the one for the physical table, but I added this check to 
search for the keyvalue of the COLUMN_QUALIFIER_COUNTER put just to be more 
resilient.


---

Reply via email to