org.datavec.api.transform.schema.conversion.TypeConversion Java Examples
The following examples show how to use
org.datavec.api.transform.schema.conversion.TypeConversion.
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: ArrowUtils.java From konduit-serving with Apache License 2.0 | 4 votes |
public static void setValue(ColumnType columnType, FieldVector fieldVector, Object value, int row) { if (!(value instanceof NullWritable)) { try { switch (columnType) { case Integer: int set; if (fieldVector instanceof IntVector) { IntVector intVector = (IntVector) fieldVector; set = TypeConversion.getInstance().convertInt(value); intVector.set(row, set); } else { if (!(fieldVector instanceof UInt4Vector)) { throw new UnsupportedOperationException("Illegal type " + fieldVector.getClass() + " for int type"); } UInt4Vector uInt4Vector = (UInt4Vector) fieldVector; set = TypeConversion.getInstance().convertInt(value); uInt4Vector.set(row, set); } break; case Float: Float4Vector float4Vector = (Float4Vector) fieldVector; float set2 = TypeConversion.getInstance().convertFloat(value); float4Vector.set(row, set2); break; case Double: double set3 = TypeConversion.getInstance().convertDouble(value); Float8Vector float8Vector = (Float8Vector) fieldVector; float8Vector.set(row, set3); break; case Long: if (fieldVector instanceof BigIntVector) { BigIntVector largeIntVector = (BigIntVector) fieldVector; largeIntVector.set(row, TypeConversion.getInstance().convertLong(value)); } else { if (!(fieldVector instanceof UInt8Vector)) { throw new UnsupportedOperationException("Illegal type " + fieldVector.getClass() + " for long type"); } UInt8Vector uInt8Vector = (UInt8Vector) fieldVector; uInt8Vector.set(row, TypeConversion.getInstance().convertLong(value)); } break; case NDArray: NDArrayWritable arr = (NDArrayWritable) value; VarBinaryVector nd4jArrayVector = (VarBinaryVector) fieldVector; ByteBuffer byteBuffer = BinarySerde.toByteBuffer(arr.get()); nd4jArrayVector.setSafe(row, byteBuffer, 0, byteBuffer.capacity()); case Boolean: case Bytes: default: break; case Categorical: case String: String stringSet = TypeConversion.getInstance().convertString(value); VarCharVector textVector = (VarCharVector) fieldVector; textVector.setSafe(row, stringSet.getBytes()); break; case Time: long timeSet = TypeConversion.getInstance().convertLong(value); setLongInTime(fieldVector, row, timeSet); } } catch (Exception var16) { log.warn("Unable to set value at row " + row); } } }