You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Bill Oliver (JIRA)" <ji...@apache.org> on 2014/05/28 16:58:01 UTC
[jira] [Created] (HIVE-7134) Implement ResultSet.getBytes()
Bill Oliver created HIVE-7134:
---------------------------------
Summary: Implement ResultSet.getBytes()
Key: HIVE-7134
URL: https://issues.apache.org/jira/browse/HIVE-7134
Project: Hive
Issue Type: Improvement
Reporter: Bill Oliver
I'd like to see an implementation of ResultSet.getBytes().
Here is my (untested) implementation. This could certainly be improved upon.
public byte[] getBytes(int columnIndex) throws SQLException {
Object value = getColumnValue(columnIndex);
if (wasNull) {
return null;
}
if (value instanceof byte[]) {
return (byte[]) value;
}
try {
// this implementation will work on any Object that implements java.io.Serializable
// includes Number, Date, Timestamp, or String
ByteArrayOutputStream b = new ByteArrayOutputStream();
ObjectOutputStream o = new ObjectOutputStream(b);
o.writeObject(value);
return b.toByteArray();
} catch (IOException e) {
throw new SQLException(e);
}
}
public byte[] getBytes(String columnName) throws SQLException {
return getBytes(findColumn(columnName));
}
--
This message was sent by Atlassian JIRA
(v6.2#6252)