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

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


    testVectorUDFUnixTimeStamp(TestType.STRING_LONG);
  }

  private void compareToUDFWeekOfYearLong(long t, int y) {
    UDFWeekOfYear udf = new UDFWeekOfYear();
    TimestampWritable tsw = toTimestampWritable(t);
    IntWritable res = udf.evaluate(tsw);
    Assert.assertEquals(res.get(), y);
  }
View Full Code Here


    } else if (ti.equals(TypeInfoFactory.booleanTypeInfo)) {
      return new BooleanWritable( value == 0 ? false : true);
    } else if (ti.equals(TypeInfoFactory.timestampTypeInfo)) {
      Timestamp ts = new Timestamp(value);
      TimestampUtils.assignTimeInNanoSec(value, ts);
      TimestampWritable tw = new TimestampWritable(ts);
      return tw;
    }
    return null;
  }
View Full Code Here

    for (int i = 0; i < vectorSize; i++) {
      Writable w = (Writable) vew.writeValue(lcv, i);
      if (w != null) {
        Writable expected = getWritableValue(type, lcv.vector[i]);
        if (expected instanceof TimestampWritable) {
          TimestampWritable t1 = (TimestampWritable) expected;
          TimestampWritable t2 = (TimestampWritable) w;
          Assert.assertTrue(t1.getNanos() == t2.getNanos());
          Assert.assertTrue(t1.getSeconds() == t2.getSeconds());
          continue;
        }
        Assert.assertEquals(expected, w);
      } else {
        Assert.assertTrue(lcv.isNull[i]);
View Full Code Here

      values[i] = vew.initValue(null);
      values[i] = vew.setValue(values[i], lcv, i);
      if (values[i] != null) {
        Writable expected = getWritableValue(type, lcv.vector[i]);
        if (expected instanceof TimestampWritable) {
          TimestampWritable t1 = (TimestampWritable) expected;
          TimestampWritable t2 = (TimestampWritable) values[i];
          Assert.assertTrue(t1.getNanos() == t2.getNanos());
          Assert.assertTrue(t1.getSeconds() == t2.getSeconds());
          continue;
        }
        Assert.assertEquals(expected, values[i]);
      } else {
        Assert.assertTrue(lcv.isNull[i]);
View Full Code Here

            super(TypeInfoFactory.timestampTypeInfo);
        }

        @Override
        public TimestampWritable getPrimitiveWritableObject(Object o) {
            return o == null ? null : new TimestampWritable(new Timestamp(((DateTime)o).getMillis()));
        }
View Full Code Here

        return create(tw.getTimestamp());
    }

    @Override
    public Object create(byte[] bytes, int offset) {
       return new TimestampWritable(bytes, offset).toString();
    }
View Full Code Here

    @Override
    public TimestampWritable getPrimitiveWritableObject(Object o) {
        if(o == null) return null;
       
        if(o instanceof String) {
           return new TimestampWritable(ParsePrimitiveUtils.parseTimestamp((String)o));
        } else {
          return new TimestampWritable(((Timestamp) o));
        }
    }
View Full Code Here

        return ((BinaryObjectInspector) poi).getPrimitiveWritableObject(o).hashCode();

      case DATE:
        return ((DateObjectInspector) poi).getPrimitiveWritableObject(o).hashCode();
      case TIMESTAMP:
        TimestampWritable t = ((TimestampObjectInspector) poi)
            .getPrimitiveWritableObject(o);
        return t.hashCode();
      case DECIMAL:
        return ((HiveDecimalObjectInspector) poi).getPrimitiveWritableObject(o).hashCode();

      default: {
        throw new RuntimeException("Unknown type: "
View Full Code Here

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

  protected JavaTimestampObjectInspector() {
    super(TypeInfoFactory.timestampTypeInfo);
  }

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

TOP

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

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.