[ 
https://issues.apache.org/jira/browse/TAJO-836?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14051461#comment-14051461
 ] 

ASF GitHub Bot commented on TAJO-836:
-------------------------------------

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

    https://github.com/apache/tajo/pull/15#discussion_r14514922
  
    --- Diff: 
tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/StoreIndexExec.java
 ---
    @@ -0,0 +1,110 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.tajo.engine.planner.physical;
    +
    +import org.apache.commons.logging.Log;
    +import org.apache.commons.logging.LogFactory;
    +import org.apache.hadoop.fs.Path;
    +import org.apache.hadoop.io.IOUtils;
    +import org.apache.tajo.catalog.Column;
    +import org.apache.tajo.catalog.Schema;
    +import org.apache.tajo.catalog.SortSpec;
    +import org.apache.tajo.conf.TajoConf;
    +import org.apache.tajo.conf.TajoConf.ConfVars;
    +import org.apache.tajo.engine.planner.PlannerUtil;
    +import org.apache.tajo.engine.planner.logical.CreateIndexNode;
    +import org.apache.tajo.storage.RowStoreUtil;
    +import org.apache.tajo.storage.Tuple;
    +import org.apache.tajo.storage.TupleComparator;
    +import org.apache.tajo.storage.VTuple;
    +import org.apache.tajo.storage.index.bst.BSTIndex;
    +import org.apache.tajo.storage.index.bst.BSTIndex.BSTIndexWriter;
    +import org.apache.tajo.worker.TaskAttemptContext;
    +
    +import java.io.IOException;
    +
    +public class StoreIndexExec extends UnaryPhysicalExec {
    +  private static final Log LOG = LogFactory.getLog(StoreIndexExec.class);
    +  private BSTIndexWriter indexWriter;
    +  private final CreateIndexNode logicalPlan;
    +  private int[] indexKeys = null;
    +  private Schema keySchema;
    +  private TupleComparator comparator;
    +
    +  public StoreIndexExec(final TaskAttemptContext context, final 
CreateIndexNode logicalPlan,
    +                        final PhysicalExec child) {
    +    super(context, logicalPlan.getInSchema(), logicalPlan.getOutSchema(), 
child);
    +    this.logicalPlan = logicalPlan;
    +  }
    +
    +  @Override
    +  public void init() throws IOException {
    +    super.init();
    +
    +    SortSpec[] sortSpecs = logicalPlan.getSortSpecs();
    +    indexKeys = new int[sortSpecs.length];
    +    keySchema = PlannerUtil.sortSpecsToSchema(sortSpecs);
    +
    +    Column col;
    +    for (int i = 0 ; i < sortSpecs.length; i++) {
    +      col = sortSpecs[i].getSortKey();
    +      indexKeys[i] = inSchema.getColumnId(col.getQualifiedName());
    +    }
    +
    +    TajoConf conf = new TajoConf();
    +
    +    Path indexPath = new Path(conf.getVar(ConfVars.INDEX_DIR), 
logicalPlan.getIndexName() + "/" +
    --- End diff --
    
    It seems to write index on ```${INDEX_DIR}/${INDEX NAME}```. It would be 
better if index is located as the following directory hierarchy: 
```${DATABASE_NAME}/${TABLE_NAME}/${INDEX_NAME}```. 
    
    There are one or more indices against one table. The proposed directory 
hierarchy will enable Tajo to manage indices  more effectively.


> create index support
> --------------------
>
>                 Key: TAJO-836
>                 URL: https://issues.apache.org/jira/browse/TAJO-836
>             Project: Tajo
>          Issue Type: Sub-task
>          Components: operator/expression, physical operator, planner/optimizer
>            Reporter: Jihoon Son
>            Assignee: Jihoon Son
>            Priority: Minor
>             Fix For: 0.9.0
>
>         Attachments: TAJO-836.patch, TAJO-836_2.patch, TAJO-836_3.patch
>
>
> The synopsis is as follows.
> {noformat}
> CREATE [ UNIQUE ] INDEX [ name ] ON table [ USING method ]
>     ( { column | ( expression ) } [ ASC | DESC ] [ NULLS { FIRST | LAST } ] 
> [, ...] )
>     [ WHERE predicate ]
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to