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

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

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

    https://github.com/apache/tajo/pull/232#discussion_r20281223
  
    --- Diff: 
tajo-storage/src/main/java/org/apache/tajo/storage/hbase/ColumnMapping.java ---
    @@ -0,0 +1,239 @@
    +/**
    + * 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.storage.hbase;
    +
    +import org.apache.hadoop.hbase.util.Bytes;
    +import org.apache.tajo.catalog.Schema;
    +import org.apache.tajo.catalog.TableMeta;
    +import org.apache.tajo.util.BytesUtils;
    +
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.List;
    +
    +public class ColumnMapping {
    +  public static final String KEY_COLUMN_MAPPING = "key";
    +  public static final String VALUE_COLUMN_MAPPING = "value";
    +
    +  private TableMeta tableMeta;
    +  private Schema schema;
    +  private char rowKeyDelimiter;
    +
    +  private String hbaseTableName;
    +
    +  private int[] rowKeyFieldIndexes;
    +  private boolean[] isRowKeyMappings;
    +  private boolean[] isBinaryColumns;
    +  private boolean[] isColumnKeys;
    +  private boolean[] isColumnValues;
    +
    +  // schema order -> 0: cf name, 1: column name -> name bytes
    +  private byte[][][] mappingColumns;
    +
    +  private int numRowKeys;
    +
    +  public ColumnMapping(Schema schema, TableMeta tableMeta) throws 
IOException {
    +    this.schema = schema;
    +    this.tableMeta = tableMeta;
    +
    +    init();
    +  }
    +
    +  public void init() throws IOException {
    +    hbaseTableName = 
tableMeta.getOption(HBaseStorageManager.META_TABLE_KEY);
    +    String delim = 
tableMeta.getOption(HBaseStorageManager.META_ROWKEY_DELIMITER, "").trim();
    +    if (delim.length() > 0) {
    +      rowKeyDelimiter = delim.charAt(0);
    +    }
    +    isRowKeyMappings = new boolean[schema.size()];
    +    rowKeyFieldIndexes = new int[schema.size()];
    +    isBinaryColumns = new boolean[schema.size()];
    +    isColumnKeys = new boolean[schema.size()];
    +    isColumnValues = new boolean[schema.size()];
    +
    +    mappingColumns = new byte[schema.size()][][];
    +
    +    for (int i = 0; i < schema.size(); i++) {
    +      rowKeyFieldIndexes[i] = -1;
    +    }
    +
    +    String columnMapping = 
tableMeta.getOption(HBaseStorageManager.META_COLUMNS_KEY, "");
    +    if (columnMapping == null || columnMapping.isEmpty()) {
    +      throw new IOException("'columns' property is required.");
    +    }
    +
    +    String[] columnMappingTokens = columnMapping.split(",");
    +
    +    if (columnMappingTokens.length != schema.getColumns().size()) {
    +      throw new IOException("The number of mapped HBase columns is great 
than the number of Tajo table columns");
    +    }
    +
    +    int index = 0;
    +    for (String eachToken: columnMappingTokens) {
    +      mappingColumns[index] = new byte[2][];
    +
    +      byte[][] mappingTokens = 
BytesUtils.splitPreserveAllTokens(eachToken.trim().getBytes(), ':');
    +
    +      if (mappingTokens.length == 3) {
    --- End diff --
    
    They seem to be checked in the phase of logical plan verification. 
Otherwise, it will cause runtime exception during query processing.
    
    BTW, I know that in this time there is no system to insert this test into 
the phase of logical plan verification. We need to consider it later. Now, I 
added the requirement to https://issues.apache.org/jira/browse/TAJO-337.


> Supports Inserting or Creating table into the HBase mapped table.
> -----------------------------------------------------------------
>
>                 Key: TAJO-1131
>                 URL: https://issues.apache.org/jira/browse/TAJO-1131
>             Project: Tajo
>          Issue Type: Sub-task
>            Reporter: Hyoungjun Kim
>            Assignee: Hyoungjun Kim
>            Priority: Minor
>
> Tajo should support inserting or creating table into the HBase mapped table.
> HBase supports bulk uploading. For using  this tool the query result should 
> be range partitioned and sorted by a region split range. 
> See the following HBase reference.
> http://hbase.apache.org/book/arch.bulk.load.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to