Package org.apache.hadoop.hive.serde2.io

Examples of org.apache.hadoop.hive.serde2.io.DateWritable


  public Date getPrimitiveJavaObject(Object o) {
    return o == null ? null : ((DateWritable) o).get();
  }

  public Object copyObject(Object o) {
    return o == null ? null : new DateWritable((DateWritable) o);
  }
View Full Code Here


    ((DateWritable) o).set(d);
    return o;
  }

  public Object create(Date d) {
    return new DateWritable(d);
  }
View Full Code Here

  protected JavaDateObjectInspector() {
    super(TypeInfoFactory.dateTypeInfo);
  }

  public DateWritable getPrimitiveWritableObject(Object o) {
    return o == null ? null : new DateWritable((Date) o);
  }
View Full Code Here

        BytesWritable bw2 = ((BinaryObjectInspector) poi2).getPrimitiveWritableObject(o2);
        return bw1.compareTo(bw2);
      }

      case DATE: {
        DateWritable d1 = ((DateObjectInspector) poi1)
            .getPrimitiveWritableObject(o1);
        DateWritable d2 = ((DateObjectInspector) poi2)
            .getPrimitiveWritableObject(o2);
        return d1.compareTo(d2);
      }
      case TIMESTAMP: {
        TimestampWritable t1 = ((TimestampObjectInspector) poi1)
View Full Code Here

        }
        return bw;
      }

      case DATE: {
        DateWritable d = reuse == null ? new DateWritable()
            : (DateWritable) reuse;
        d.set(deserializeInt(buffer, invert));
        return d;
      }

      case TIMESTAMP:
        TimestampWritable t = (reuse == null ? new TimestampWritable() :
View Full Code Here

                tw.set(t);
                LazyTimestamp.writeUTF8(serializeVectorStream, tw);
                break;
              case DATE:
                LongColumnVector dacv = (LongColumnVector) batch.cols[k];
                DateWritable daw = new DateWritable((int) dacv.vector[rowIndex]);
                LazyDate.writeUTF8(serializeVectorStream, daw);
                break;
              default:
                throw new UnsupportedOperationException(
                    "Vectorizaton is not supported for datatype:"
View Full Code Here

          public void assignObjectValue(Object val, int destIndex) throws HiveException {
            if (val == null) {
              assignNull(destIndex);
            }
            else {
              DateWritable bw = (DateWritable) val;
              assignLong(bw.getDays(), destIndex);
            }
          }
        }.init(outputBatch, (LongColumnVector) destCol);
        break;
      default:
        throw new HiveException("Incompatible Long vector column and primitive category " +
            poi.getPrimitiveCategory());
      }
    }
    else if (destCol instanceof DoubleColumnVector) {
      switch(poi.getPrimitiveCategory()) {
      case DOUBLE:
        outVCA = new VectorDoubleColumnAssign() {
          @Override
          public void assignObjectValue(Object val, int destIndex) throws HiveException {
            if (val == null) {
              assignNull(destIndex);
            }
            else {
              DoubleWritable bw = (DoubleWritable) val;
              assignDouble(bw.get(), destIndex);
            }
          }
        }.init(outputBatch, (DoubleColumnVector) destCol);
        break;
      case FLOAT:
        outVCA = new VectorDoubleColumnAssign() {
          @Override
          public void assignObjectValue(Object val, int destIndex) throws HiveException {
            if (val == null) {
              assignNull(destIndex);
            }
            else {
              FloatWritable bw = (FloatWritable) val;
              assignDouble(bw.get(), destIndex);
            }
          }
        }.init(outputBatch, (DoubleColumnVector) destCol);
        break;
      default:
        throw new HiveException("Incompatible Double vector column and primitive category " +
            poi.getPrimitiveCategory());
      }
    }
    else if (destCol instanceof BytesColumnVector) {
      switch(poi.getPrimitiveCategory()) {
      case STRING:
        outVCA = new VectorBytesColumnAssign() {
          @Override
          public void assignObjectValue(Object val, int destIndex) throws HiveException {
            if (val == null) {
              assignNull(destIndex);
            }
            else {
              Text bw = (Text) val;
              byte[] bytes = bw.getBytes();
              assignBytes(bytes, 0, bytes.length, destIndex);
            }
          }
        }.init(outputBatch, (BytesColumnVector) destCol);
        break;
View Full Code Here

    ObjectInspector[] arguments = {valueOI};
    udf.initialize(arguments);

    Date date = Date.valueOf("1970-01-01");
    runAndVerify(udf,
        new DateWritable(date),
        new LongWritable(date.getTime() / 1000));

    // test null values
    runAndVerify(udf, null, null);
  }
View Full Code Here

        .getTimestamp();
      calendar.setTime(ts);
      calendar.add(Calendar.DAY_OF_MONTH, toBeAdded.get());
      break;
    case DATE:
      DateWritable dw = (DateWritable) dateWritableConverter.convert(arguments[0].get());
      calendar.setTime(dw.get());
      calendar.add(Calendar.DAY_OF_MONTH, toBeAdded.get());
      break;
    default:
      throw new UDFArgumentException(
        "DATE_ADD() only takes STRING/TIMESTAMP/DATEWRITABLE types, got " + inputType1);
View Full Code Here

    }

    @Override
    Object next(Object previous) throws IOException {
      super.next(previous);
      DateWritable result = null;
      if (valuePresent) {
        if (previous == null) {
          result = new DateWritable();
        } else {
          result = (DateWritable) previous;
        }
        result.set((int) reader.next());
      }
      return result;
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.serde2.io.DateWritable

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.