Exemple #1
0
 @Override
 public boolean equals(Object obj) {
   boolean retval = true;
   if (obj instanceof Field) {
     Field field = (Field) obj;
     if (type.equals(field.getType())) {
       if (this.isNull() && field.isNull()) {
         retval = true;
       } else if (this.isNull() ^ field.isNull()) {
         retval = false;
       } else if (type.equals(VARBINARY)) {
         // special case for byte arrays
         // aren't they so fancy
         retval = Arrays.equals((byte[]) value, (byte[]) field.getObject());
       } else if (type.equals(DATE) || type.equals(TIME) || type.equals(TIMESTAMP)) {
         retval = value.toString().equals(field.getObject().toString());
       } else {
         if (value instanceof Block) {
           retval = equals((Block) value, (Block) field.getObject());
         } else {
           retval = value.equals(field.getObject());
         }
       }
     }
   }
   return retval;
 }
Exemple #2
0
  public Field(Field field) {
    this.type = field.type;
    this.indexed = false;

    if (Types.isArrayType(this.type) || Types.isMapType(this.type)) {
      this.value = field.value;
      return;
    }

    if (type.equals(BIGINT)) {
      this.value = field.getLong();
    } else if (type.equals(BOOLEAN)) {
      this.value = field.getBoolean();
    } else if (type.equals(DATE)) {
      this.value = new Date(field.getDate().getTime());
    } else if (type.equals(DOUBLE)) {
      this.value = field.getDouble();
    } else if (type.equals(INTEGER)) {
      this.value = field.getInt();
    } else if (type.equals(REAL)) {
      this.value = field.getFloat();
    } else if (type.equals(SMALLINT)) {
      this.value = field.getShort();
    } else if (type.equals(TIME)) {
      this.value = new Time(field.getTime().getTime());
    } else if (type.equals(TIMESTAMP)) {
      this.value = new Timestamp(field.getTimestamp().getTime());
    } else if (type.equals(TINYINT)) {
      this.value = field.getByte();
    } else if (type.equals(VARBINARY)) {
      this.value = Arrays.copyOf(field.getVarbinary(), field.getVarbinary().length);
    } else if (type.equals(VARCHAR)) {
      this.value = field.getVarchar();
    } else {
      throw new PrestoException(NOT_SUPPORTED, "Unsupported type " + type);
    }
  }