Java Code Examples for org.apache.arrow.vector.ValueVector#isNull()

The following examples show how to use org.apache.arrow.vector.ValueVector#isNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimeFieldReader.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public Time read(int index) {
	ValueVector valueVector = getValueVector();
	if (valueVector.isNull(index)) {
		return null;
	} else {
		long timeMilli;
		if (valueVector instanceof TimeSecVector) {
			timeMilli = ((TimeSecVector) getValueVector()).get(index) * 1000;
		} else if (valueVector instanceof TimeMilliVector) {
			timeMilli = ((TimeMilliVector) getValueVector()).get(index);
		} else if (valueVector instanceof TimeMicroVector) {
			timeMilli = ((TimeMicroVector) getValueVector()).get(index) / 1000;
		} else {
			timeMilli = ((TimeNanoVector) getValueVector()).get(index) / 1000000;
		}
		return new Time(timeMilli - LOCAL_TZ.getOffset(timeMilli));
	}
}
 
Example 2
Source File: IcebergPartitionData.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public void set(int position, CompleteType type, ValueVector vector, int offset) {
  if (vector.isNull(offset)) {
    set(position, null);
    return;
  }

  switch (type.toMinorType()) {
    case TINYINT:
    case UINT1:
      setInteger(position, Integer.valueOf((Byte)(vector.getObject(offset))));
      break;
    case SMALLINT:
    case UINT2:
      setInteger(position, Integer.valueOf((Short)(vector.getObject(offset))));
      break;
    case INT:
    case UINT4:
      setInteger(position, (Integer)vector.getObject(offset));
      break;
    case UINT8:
    case BIGINT:
      setLong(position, (Long)(vector.getObject(offset)));
      break;
    case FLOAT4:
      setFloat(position, ((Float)(vector.getObject(offset))));
      break;
    case FLOAT8:
      setDouble(position, ((Double)(vector.getObject(offset))));
      break;
    case BIT:
      setBoolean(position, ((Boolean)(vector.getObject(offset))));
      break;
    case VARBINARY:
      setBytes(position, ((byte[])(vector.getObject(offset))));
      break;
    case DECIMAL9:
    case DECIMAL18:
    case DECIMAL28SPARSE:
    case DECIMAL38SPARSE:
    case DECIMAL28DENSE:
    case DECIMAL38DENSE:
    case DECIMAL:
      setBigDecimal(position, ((BigDecimal)(vector.getObject(offset))));
      break;

    case DATE:
      if (vector instanceof DateMilliVector) {
        setInteger(position, Math.toIntExact(TimeUnit.MILLISECONDS.toDays(((DateMilliVector) vector).get(offset))));
      } else {
        //TODO: needs further tuning
        set(position, null);
      }
      break;
    case TIME:
    case TIMETZ:
    case TIMESTAMPTZ:
    case TIMESTAMP:
    case INTERVAL:
    case INTERVALYEAR:
    case INTERVALDAY:
      if (vector instanceof  TimeStampMilliVector) {
        setLong(position, (((TimeStampMilliVector) vector).get(offset)) * 1000);
      } else {
        //TODO: needs further tuning
        set(position, null);
      }
      break;

    case VARCHAR:
    case FIXEDCHAR:
    case FIXED16CHAR:
    case FIXEDSIZEBINARY:
    case VAR16CHAR:
      setString(position, vector.getObject(offset).toString());
      break;


    case NULL:
    case MONEY:
    case LATE:
    case STRUCT:
    case LIST:
    case GENERIC_OBJECT:
    case UNION:
      throw new IllegalArgumentException("Unsupported type in partition data: " + type.toString());

  }
}