Thomas D'Silva commented on PHOENIX-2565:

Thanks for the feedback. 

ReplaceArrayColumnWithKeyValueColumnExpressionVisitor is only used in one place 
in IndexUtil.generateIndexData because we use a ValueGetter to get the value of 
the data table column using the original data table column reference. This is 
also why ArrayColumnExpression needs to keep track of the original key value 
column expression. 
If we don't replace the array column expression with the original column 
expression when it looks up the column by the qualifier it won't find it. 
I will make the other changes you suggested.

ValueGetter valueGetter = new ValueGetter() {
                        public byte[] getRowKey() {
                                return dataMutation.getRow();
                        public ImmutableBytesWritable 
getLatestValue(ColumnReference ref) {
                            // Always return null for our empty key value, as 
this will cause the index
                            // maintainer to always treat this Put as a new row.
                            if (isEmptyKeyValue(table, ref)) {
                                return null;
                            byte[] family = ref.getFamily();
                            byte[] qualifier = ref.getQualifier();
                            RowMutationState rowMutationState = 
                            PColumn column = null;
                            try {
                                column = 
                            } catch (ColumnNotFoundException e) {
                            } catch (ColumnFamilyNotFoundException e) {
                            if (rowMutationState!=null && column!=null) {
                                byte[] value = 
                                ImmutableBytesPtr ptr = new ImmutableBytesPtr();
                                ptr.set(value==null ? ByteUtil.EMPTY_BYTE_ARRAY 
: value);
column, ptr);
                                return ptr;
                            return null;

> Store data for immutable tables in single KeyValue
> --------------------------------------------------
>                 Key: PHOENIX-2565
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2565
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: James Taylor
>            Assignee: Thomas D'Silva
>             Fix For: 4.9.0
>         Attachments: PHOENIX-2565-wip.patch, PHOENIX-2565.patch
> Since an immutable table (i.e. declared with IMMUTABLE_ROWS=true) will never 
> update a column value, it'd be more efficient to store all column values for 
> a row in a single KeyValue. We could use the existing format we have for 
> variable length arrays.
> For backward compatibility, we'd need to support the current mechanism. Also, 
> you'd no longer be allowed to transition an existing table to/from being 
> immutable. I think the best approach would be to introduce a new IMMUTABLE 
> keyword and use it like this:
> {code}
> {code}

This message was sent by Atlassian JIRA

Reply via email to