Package org.apache.hadoop.hive.hbase.HBaseSerDe

Examples of org.apache.hadoop.hive.hbase.HBaseSerDe.ColumnMapping


    } catch (SerDeException e) {
      fail(e.toString());
    }

    for (int i = 0; i < columnsMapping.size(); i++) {
      ColumnMapping colMap = columnsMapping.get(i);

      if (!colMap.hbaseRowKey && colMap.qualifierName == null) {
        colMap.binaryStorage.add(false);
        colMap.binaryStorage.add(false);
      } else {
View Full Code Here


    } catch (SerDeException e) {
      fail(e.toString());
    }

    for (int i = 0; i < columnsMapping.size(); i++) {
      ColumnMapping colMap = columnsMapping.get(i);

      if (!colMap.hbaseRowKey && colMap.qualifierName == null) {
        colMap.binaryStorage.add(false);
        colMap.binaryStorage.add(false);
      } else {
View Full Code Here

    } catch (SerDeException sde) {
      fail(sde.toString());
    }

    for (int i = 0; i < columnsMapping.size(); i++) {
      ColumnMapping colMap = columnsMapping.get(i);

      if (i == 0 || i == 7) {
        colMap.binaryStorage.add(false);
      } else {
        colMap.binaryStorage.add(true);
      }
    }

    ObjectInspector oi =
      LazyFactory.createLazyStructInspector(fieldNames, fieldTypeInfos,
          new byte [] {' ', ':', '='}, nullSequence, false, false, (byte) 0);

    LazyHBaseRow o = new LazyHBaseRow((LazySimpleStructObjectInspector) oi);

    byte [] rowKey = "row-key".getBytes();
    List<KeyValue> kvs = new ArrayList<KeyValue>();
    byte [] value;

    for (int i = 1; i < columnsMapping.size(); i++) {

      switch (i) {

      case 1:
        value = Bytes.toBytes(1);
        break;

      case 2:
        value = new byte[]{(byte)1};
        break;

      case 3:
        value = Bytes.toBytes((short) 1);
        break;

      case 4:
        value = Bytes.toBytes((long) 1);
        break;

      case 5:
        value = Bytes.toBytes((float) 1.0F);
        break;

      case 6:
        value = Bytes.toBytes((double) 1.0);
        break;

      case 7:
        value = "Hadoop, Hive, with HBase storage handler.".getBytes();
        break;

      case 8:
        value = Bytes.toBytes(true);
        break;

      default:
        throw new RuntimeException("Not expected: " + i);
      }

      ColumnMapping colMap = columnsMapping.get(i);
      kvs.add(new KeyValue(rowKey, colMap.familyNameBytes, colMap.qualifierNameBytes, value));
    }

    Collections.sort(kvs, KeyValue.COMPARATOR);
    Result result = new Result(kvs);
View Full Code Here

        }
        // make sure the schema mapping is right
        tableDesc = getHBaseAdmin().getTableDescriptor(Bytes.toBytes(tableName));

        for (int i = 0; i < columnsMapping.size(); i++) {
          ColumnMapping colMap = columnsMapping.get(i);

          if (colMap.hbaseRowKey) {
            continue;
          }
View Full Code Here

      List<? extends StructField> fieldRefs =
        ((StructObjectInspector)getInspector()).getAllStructFieldRefs();
      LazyObject<? extends ObjectInspector> [] fields = new LazyObject<?>[fieldRefs.size()];

      for (int i = 0; i < fields.length; i++) {
        ColumnMapping colMap = columnsMapping.get(i);

        if (colMap.qualifierName == null && !colMap.hbaseRowKey) {
          // a column family
          fields[i] = new LazyHBaseCellMap(
              (LazyMapObjectInspector) fieldRefs.get(i).getFieldObjectInspector());
View Full Code Here

    LazyObject<?> [] fields = getFields();
    boolean [] fieldsInited = getFieldInited();

    if (!fieldsInited[fieldID]) {
      ByteArrayRef ref = null;
      ColumnMapping colMap = columnsMapping.get(fieldID);

      if (colMap.hbaseRowKey) {
        ref = new ByteArrayRef();
        ref.setData(result.getRow());
      } else {
View Full Code Here

    // The list of families that have been added to the scan
    List<String> addedFamilies = new ArrayList<String>();

    if (!readAllColumns) {
      for (int i : readColIDs) {
        ColumnMapping colMap = columnsMapping.get(i);
        if (colMap.hbaseRowKey) {
          continue;
        }

        if (colMap.qualifierName == null) {
          scan.addFamily(colMap.familyNameBytes);
          addedFamilies.add(colMap.familyName);
        } else {
          if(!addedFamilies.contains(colMap.familyName)){
            // add only if the corresponding family has not already been added
            scan.addColumn(colMap.familyNameBytes, colMap.qualifierNameBytes);
          }
        }

        empty = false;
      }
    }

    // The HBase table's row key maps to a Hive table column. In the corner case when only the
    // row key column is selected in Hive, the HBase Scan will be empty i.e. no column family/
    // column qualifier will have been added to the scan. We arbitrarily add at least one column
    // to the HBase scan so that we can retrieve all of the row keys and return them as the Hive
    // tables column projection.
    if (empty) {
      for (int i = 0; i < columnsMapping.size(); i++) {
        ColumnMapping colMap = columnsMapping.get(i);
        if (colMap.hbaseRowKey) {
          continue;
        }

        if (colMap.qualifierName == null) {
View Full Code Here

    List<String> addedFamilies = new ArrayList<String>();

    // REVIEW:  are we supposed to be applying the getReadColumnIDs
    // same as in getRecordReader?
    for (int i = 0; i <columnsMapping.size(); i++) {
      ColumnMapping colMap = columnsMapping.get(i);
      if (colMap.hbaseRowKey) {
        continue;
      }

      if (colMap.qualifierName == null) {
View Full Code Here

    } catch (SerDeException e) {
      fail(e.toString());
    }

    for (int i = 0; i < columnsMapping.size(); i++) {
      ColumnMapping colMap = columnsMapping.get(i);

      if (!colMap.hbaseRowKey && colMap.qualifierName == null) {
        colMap.binaryStorage.add(false);
        colMap.binaryStorage.add(false);
      } else {
View Full Code Here

    } catch (SerDeException e) {
      fail(e.toString());
    }

    for (int i = 0; i < columnsMapping.size(); i++) {
      ColumnMapping colMap = columnsMapping.get(i);

      if (!colMap.hbaseRowKey && colMap.qualifierName == null) {
        colMap.binaryStorage.add(false);
        colMap.binaryStorage.add(false);
      } else {
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.hbase.HBaseSerDe.ColumnMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.