Examples of DateWritable


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

    @Override
    void write(Object obj) throws IOException {
      super.write(obj);
      if (obj != null) {
        // Using the Writable here as it's used directly for writing as well as for stats.
        DateWritable val = ((DateObjectInspector) inspector).getPrimitiveWritableObject(obj);
        indexStatistics.updateDate(val);
        writer.write(val.getDays());
      }
    }
View Full Code Here

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

          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 " +
            category);
      }
    }
    else if (destCol instanceof DoubleColumnVector) {
      switch(category) {
      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 " +
            category);
      }
    }
    else if (destCol instanceof BytesColumnVector) {
      switch(category) {
      case BINARY:
        outVCA = new VectorBytesColumnAssign() {
          @Override
          public void assignObjectValue(Object val, int destIndex) throws HiveException {
            if (val == null) {
              assignNull(destIndex);
            }
            else {
              BytesWritable bw = (BytesWritable) val;
              byte[] bytes = bw.getBytes();
              assignBytes(bytes, 0, bw.getLength(), destIndex);
            }
          }
        }.init(outputBatch, (BytesColumnVector) destCol);
        break;
      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, bw.getLength(), destIndex);
            }
          }
        }.init(outputBatch, (BytesColumnVector) destCol);
        break;
      case VARCHAR:
View Full Code Here

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

                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

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

      Timestamp ts = ((TimestampWritable) converter.convert(argument.get()))
        .getTimestamp();
      date.setTime(ts.getTime());
      break;
    case DATE:
      DateWritable dw = (DateWritable) converter.convert(argument.get());
      date = dw.get();
      break;
    default:
      throw new UDFArgumentException(
        "TO_DATE() only takes STRING/TIMESTAMP/DATEWRITABLE types, got " + inputType);
    }
View Full Code Here

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

    }

    @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

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

  @Test
  public void testBuilderComplexTypes() throws Exception {
    SearchArgument sarg =
        SearchArgumentFactory.newBuilder()
            .startAnd()
              .lessThan("x", new DateWritable(10))
              .lessThanEquals("y", new HiveChar("hi", 10))
              .equals("z", HiveDecimal.create("1.0"))
            .end()
            .build();
    assertEquals("leaf-0 = (LESS_THAN x 1970-01-11)\n" +
View Full Code Here

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

  @Test
  public void testBuilderComplexTypes2() throws Exception {
    SearchArgument sarg =
        SearchArgumentFactory.newBuilder()
            .startAnd()
            .lessThan("x", new DateWritable(10))
            .lessThanEquals("y", new HiveChar("hi", 10))
            .equals("z", new BigDecimal("1.0"))
            .end()
            .build();
    assertEquals("leaf-0 = (LESS_THAN x 1970-01-11)\n" +
View Full Code Here

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

        PredicateLeaf.Type.STRING, "x", "15", null);
    assertEquals(TruthValue.YES_NO,
        RecordReaderImpl.evaluatePredicate(createIntStats(10, 100), pred));

    pred = TestSearchArgumentImpl.createPredicateLeaf(PredicateLeaf.Operator.NULL_SAFE_EQUALS,
        PredicateLeaf.Type.DATE, "x", new DateWritable(15), null);
    assertEquals(TruthValue.NO,
        RecordReaderImpl.evaluatePredicate(createIntStats(10, 100), pred));

    pred = TestSearchArgumentImpl.createPredicateLeaf(PredicateLeaf.Operator.NULL_SAFE_EQUALS,
        PredicateLeaf.Type.DECIMAL, "x", HiveDecimal.create(15), null);
View Full Code Here

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

        PredicateLeaf.Type.STRING, "x", "15", null);
    assertEquals(TruthValue.YES_NO,
        RecordReaderImpl.evaluatePredicate(createDoubleStats(10.0, 100.0), pred));

    pred = TestSearchArgumentImpl.createPredicateLeaf(PredicateLeaf.Operator.NULL_SAFE_EQUALS,
        PredicateLeaf.Type.DATE, "x", new DateWritable(15), null);
    assertEquals(TruthValue.NO,
        RecordReaderImpl.evaluatePredicate(createDoubleStats(10.0, 100.0), pred));

    pred = TestSearchArgumentImpl.createPredicateLeaf(PredicateLeaf.Operator.NULL_SAFE_EQUALS,
        PredicateLeaf.Type.DECIMAL, "x", HiveDecimal.create(15), null);
View Full Code Here

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

        PredicateLeaf.Type.STRING, "x", "100", null);
    assertEquals(TruthValue.YES_NO,
        RecordReaderImpl.evaluatePredicate(createStringStats("10", "1000"), pred));

    pred = TestSearchArgumentImpl.createPredicateLeaf(PredicateLeaf.Operator.NULL_SAFE_EQUALS,
        PredicateLeaf.Type.DATE, "x", new DateWritable(100), null);
    assertEquals(TruthValue.NO,
        RecordReaderImpl.evaluatePredicate(createStringStats("10", "1000"), pred));

    pred = TestSearchArgumentImpl.createPredicateLeaf(PredicateLeaf.Operator.NULL_SAFE_EQUALS,
        PredicateLeaf.Type.DECIMAL, "x", HiveDecimal.create(100), null);
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.