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-514 Support functional indexes
Date Thu, 15 Jan 2015 07:15:40 GMT
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/34#discussion_r22993837
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java ---
    @@ -953,20 +973,39 @@ public MutationState createIndex(CreateIndexStatement statement,
byte[][] splits
                         PDataType dataType = MetaDataUtil.getViewIndexIdDataType();
                         ColumnName colName = ColumnName.caseSensitiveColumnName(MetaDataUtil.getViewIndexIdColumnName());
                         allPkColumns.add(new Pair<ColumnName, SortOrder>(colName, SortOrder.getDefault()));
    -                    columnDefs.add(FACTORY.columnDef(colName, dataType.getSqlTypeName(),
false, null, null, false, SortOrder.getDefault()));
    +                    columnDefs.add(FACTORY.columnDef(colName, dataType.getSqlTypeName(),
false, null, null, false, SortOrder.getDefault(), null));
                     }
                     // First columns are the indexed ones
    -                for (Pair<ColumnName, SortOrder> pair : indexedPkColumns) {
    -                    ColumnName colName = pair.getFirst();
    -                    PColumn col = resolver.resolveColumn(null, colName.getFamilyName(),
colName.getColumnName()).getColumn();
    -                    unusedPkColumns.remove(col);
    -                    // Ignore view constants for updatable views as we don't need these
in the index
    -                    if (col.getViewConstant() == null) {
    -                        PDataType dataType = IndexUtil.getIndexColumnDataType(col);
    -                        colName = ColumnName.caseSensitiveColumnName(IndexUtil.getIndexColumnName(col));
    -                        allPkColumns.add(new Pair<ColumnName, SortOrder>(colName,
pair.getSecond()));
    -                        columnDefs.add(FACTORY.columnDef(colName, dataType.getSqlTypeName(),
col.isNullable(), col.getMaxLength(), col.getScale(), false, SortOrder.getDefault()));
    -                    }
    +                for (Pair<ParseNode, SortOrder> pair : indexParseNodeAndSortOrderList)
{
    +                	ParseNode parseNode = pair.getFirst();
    +                	ColumnName colName = null;
    +                	Integer maxLength = null;
    +                	Integer scale = null;
    +                	// if it is a column 
    +                	if (parseNode instanceof ColumnParseNode) {
    +                		ColumnParseNode colParseNode = (ColumnParseNode)parseNode;
    +	                    PColumn col = resolver.resolveColumn(null, colParseNode.getTableName(),
colParseNode.getName()).getColumn();
    +	                    unusedPkColumns.remove(col);
    +	                    // Ignore view constants for updatable views as we don't need these
in the index
    +	                    if (col.getViewConstant() != null) 
    +	                    	continue;
    +	                    colName = ColumnName.caseSensitiveColumnName(IndexUtil.getIndexColumnName(col));
    +	                    maxLength = col.getMaxLength();
    +	                    scale = col.getScale();
    +                	}
    +                	// compile the parseNode to get an expression
    +			        PhoenixStatement phoenixStatment = new PhoenixStatement(connection);
    +					final StatementContext context = new StatementContext(phoenixStatment, resolver);
    +			        ExpressionCompiler expressionCompiler = new ExpressionCompiler(context);
    +			        Expression expression = parseNode.accept(expressionCompiler);	
    +                	
    +                	PDataType dataType = IndexUtil.getIndexColumnDataType(expression.isNullable(),
expression.getDataType());
    +                	// use the expression's hashCode as the column name for uniqueness
    --- End diff --
    
    Tell me more about this. Perhaps use the expression.toString() as the name?


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