Examples of HiveVarchar


Examples of org.apache.hadoop.hive.common.type.HiveVarchar

      } else {
        bdStr = bd.toString();
      }
      if (hfsType == HCatFieldSchema.Type.VARCHAR) {
        VarcharTypeInfo vti = (VarcharTypeInfo) hfs.getTypeInfo();
        HiveVarchar hvc = new HiveVarchar(bdStr, vti.getLength());
        return hvc;
      } else if (hfsType == HCatFieldSchema.Type.VARCHAR) {
        CharTypeInfo cti = (CharTypeInfo) hfs.getTypeInfo();
        HiveChar hChar = new HiveChar(bdStr, cti.getLength());
        return hChar;
      } else {
        return bdStr;
      }
    }
    Number n = (Number) val;
    if (hfsType == HCatFieldSchema.Type.TINYINT) {
      return n.byteValue();
    } else if (hfsType == HCatFieldSchema.Type.SMALLINT) {
      return n.shortValue();
    } else if (hfsType == HCatFieldSchema.Type.INT) {
      return n.intValue();
    } else if (hfsType == HCatFieldSchema.Type.BIGINT) {
      return n.longValue();
    } else if (hfsType == HCatFieldSchema.Type.FLOAT) {
      return n.floatValue();
    } else if (hfsType == HCatFieldSchema.Type.DOUBLE) {
      return n.doubleValue();
    } else if (hfsType == HCatFieldSchema.Type.BOOLEAN) {
      return n.byteValue() == 0 ? Boolean.FALSE : Boolean.TRUE;
    } else if (hfsType == HCatFieldSchema.Type.STRING) {
      return n.toString();
    } else if (hfsType == HCatFieldSchema.Type.VARCHAR) {
      VarcharTypeInfo vti = (VarcharTypeInfo) hfs.getTypeInfo();
      HiveVarchar hvc = new HiveVarchar(val.toString(), vti.getLength());
      return hvc;
    } else if (hfsType == HCatFieldSchema.Type.CHAR) {
      CharTypeInfo cti = (CharTypeInfo) hfs.getTypeInfo();
      HiveChar hChar = new HiveChar(val.toString(), cti.getLength());
      return hChar;
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveVarchar

    case DECIMAL:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : HiveDecimal.create(p.getText());
      break;
    case VARCHAR:
      int vLen = ((BaseCharTypeInfo)hcatFieldSchema.getTypeInfo()).getLength();
      val = (valueToken == JsonToken.VALUE_NULL) ? null : new HiveVarchar(p.getText(), vLen);
      break;
    case CHAR:
      int cLen = ((BaseCharTypeInfo)hcatFieldSchema.getTypeInfo()).getLength();
      val = (valueToken == JsonToken.VALUE_NULL) ? null : new HiveChar(p.getText(), cLen);
      break;
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveVarchar

    case TIMESTAMP:
      return Timestamp.valueOf(s);
    case DECIMAL:
      return HiveDecimal.create(s);
    case VARCHAR:
      return new HiveVarchar(s, ((BaseCharTypeInfo)mapKeyType).getLength());
    case CHAR:
      return new HiveChar(s, ((BaseCharTypeInfo)mapKeyType).getLength());
    }
    throw new IOException("Could not convert from string to map type " + mapKeyType.getTypeName());
  }
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveVarchar

  }
  private static HCatRecord getHCat13TypesRecord() {
    List<Object> rec_hcat13types = new ArrayList<Object>(5);
    rec_hcat13types.add(HiveDecimal.create(new BigDecimal("123.45")));//prec 5, scale 2
    rec_hcat13types.add(new HiveChar("hive_char", 10));
    rec_hcat13types.add(new HiveVarchar("hive_varchar", 20));
    rec_hcat13types.add(Date.valueOf("2014-01-06"));
    rec_hcat13types.add(new Timestamp(System.currentTimeMillis()));
    return new DefaultHCatRecord(rec_hcat13types);
  }
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveVarchar

    c1_1.add(i2);
    c1.add(c1_1);
    rlist.add(c1);
    rlist.add(HiveDecimal.create(new BigDecimal("123.45")));//prec 5, scale 2
    rlist.add(new HiveChar("hive_char", 10));
    rlist.add(new HiveVarchar("hive_varchar", 20));
    rlist.add(Date.valueOf("2014-01-07"));
    rlist.add(new Timestamp(System.currentTimeMillis()));

    List<Object> nlist = new ArrayList<Object>(13);
    nlist.add(null); // tinyint
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveVarchar

        VarcharTypeInfo vti = (VarcharTypeInfo)hcatFS.getTypeInfo();
        if(varcharVal.length() > vti.getLength()) {
          handleOutOfRangeValue(pigObj, hcatFS);
          return null;
        }
        return new HiveVarchar(varcharVal, vti.getLength());
      case TIMESTAMP:
        DateTime dt = (DateTime)pigObj;
        return new Timestamp(dt.getMillis());//getMillis() returns UTC time regardless of TZ
      case DATE:
        /**
 
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveVarchar

    if (o == null) {
      return null;
    }

    HiveVarchar result = null;
    switch (oi.getPrimitiveCategory()) {
      case VARCHAR:
        result = ((HiveVarcharObjectInspector)oi).getPrimitiveJavaObject(o);
        break;
      default:
        // Is there a way to provide char length here?
        // It might actually be ok as long as there is an object inspector (with char length)
        // receiving this value.
        result = new HiveVarchar();
        result.setValue(getString(o, oi));
        break;
    }
    return result;
  }
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveVarchar

    return getWritableWithParams(writable);
  }

  private HiveVarchar getPrimitiveWithParams(HiveVarcharWritable val) {
    HiveVarchar hv = new HiveVarchar();
    hv.setValue(val.getHiveVarchar(), getMaxLength());
    return hv;
  }
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveVarchar

    public Object convert(Object input) {
      switch (inputOI.getPrimitiveCategory()) {
        case BOOLEAN:
          return outputOI.set(hc,
              ((BooleanObjectInspector) inputOI).get(input) ?
                  new HiveVarchar("TRUE", -1) : new HiveVarchar("FALSE", -1));
        default:
          return outputOI.set(hc, PrimitiveObjectInspectorUtils.getHiveVarchar(input, inputOI));
      }
    }
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveVarchar

  @Override
  public HiveVarchar getPrimitiveJavaObject(Object o) {
    if (o == null) {
      return null;
    }
    HiveVarchar value = (HiveVarchar)o;
    if (BaseCharUtils.doesPrimitiveMatchTypeParams(
        value, (VarcharTypeInfo)typeInfo)) {
      return value;
    }
    // value needs to be converted to match the type params (length, etc).
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.