Github user jihoonson commented on a diff in the pull request:
https://github.com/apache/tajo/pull/15#discussion_r14544570
--- 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 --
Hi Hyunsik,
I also deeply thought about the directory structure.
In MHO, your suggestion might cause unnecessary operations while reading
table data. That is, the scanner should check that the file(or directory) is
index or table data.
Also, in PostgreSQL, catalog maintains indexes as well as tables as
relations. In other words, indexes are treated a kind of relations. This policy
prevents any indexes in a database from having the same name.
So, how about the directory structure of
```${DATABASE_NAME}/${INDEX_NAME}```? I think that this structure can help the
index management and also dose not disturb other operations.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---