/** * Gets the (raw) Json representation of the object stored in the row * * @param columnName The column to fetch * @return The {@link JsonNode} object that represents the stored object * @throws NoSuchElementException if this column does not exist */ public JsonNode get(String columnName) { if (!_data.has(columnName)) { throw new NoSuchElementException(missingColumnErrorMessage(columnName, getColumnNames())); } return _data.get(columnName); }
/** * Puts {@code object} into column {@code column} of the row, after checking if the object is * compatible with the Schema of the column */ @Override public TypedRowBuilder put(String column, @Nullable Object object) { checkArgument( _columns.containsKey(column), Row.missingColumnErrorMessage(column, _columns.keySet())); Schema expectedSchema = _columns.get(column).getSchema(); checkArgument( SchemaUtils.isValidObject(object, expectedSchema), String.format( "Cannot convert '%s' to Schema '%s' of column '%s'", object, expectedSchema, column)); super.put(column, object); return this; }
/** * Gets the value of specified column * * @param columnName The column to fetch * @return The result * @throws NoSuchElementException if this column is not present * @throws ClassCastException if the recovered data cannot be cast to the expected object */ public Object get(String columnName, Schema columnSchema) { if (!_data.has(columnName)) { throw new NoSuchElementException(missingColumnErrorMessage(columnName, getColumnNames())); } if (_data.get(columnName).isNull()) { return null; } return SchemaUtils.convertType(_data.get(columnName), columnSchema); }