use of java.io.UnsupportedEncodingException in project hive by apache.
the class SQLOperation method setupSessionIO.
private void setupSessionIO(SessionState sessionState) {
try {
// hive server's session input stream is not used
sessionState.in = null;
sessionState.out = new PrintStream(System.out, true, CharEncoding.UTF_8);
sessionState.info = new PrintStream(System.err, true, CharEncoding.UTF_8);
sessionState.err = new PrintStream(System.err, true, CharEncoding.UTF_8);
} catch (UnsupportedEncodingException e) {
LOG.error("Error creating PrintStream", e);
e.printStackTrace();
sessionState.out = null;
sessionState.info = null;
sessionState.err = null;
}
}
use of java.io.UnsupportedEncodingException in project hive by apache.
the class SQLOperation method decodeFromString.
private RowSet decodeFromString(List<Object> rows, RowSet rowSet) throws SQLException, SerDeException {
getSerDe();
StructObjectInspector soi = (StructObjectInspector) serde.getObjectInspector();
List<? extends StructField> fieldRefs = soi.getAllStructFieldRefs();
Object[] deserializedFields = new Object[fieldRefs.size()];
Object rowObj;
ObjectInspector fieldOI;
int protocol = getProtocolVersion().getValue();
for (Object rowString : rows) {
try {
rowObj = serde.deserialize(new BytesWritable(((String) rowString).getBytes("UTF-8")));
} catch (UnsupportedEncodingException e) {
throw new SerDeException(e);
}
for (int i = 0; i < fieldRefs.size(); i++) {
StructField fieldRef = fieldRefs.get(i);
fieldOI = fieldRef.getFieldObjectInspector();
Object fieldData = soi.getStructFieldData(rowObj, fieldRef);
deserializedFields[i] = SerDeUtils.toThriftPayload(fieldData, fieldOI, protocol);
}
rowSet.addRow(deserializedFields);
}
return rowSet;
}
use of java.io.UnsupportedEncodingException in project storm by apache.
the class JsonSerializer method initialize.
public void initialize(OutputStream processIn, InputStream processOut) {
try {
this.processIn = new BufferedWriter(new OutputStreamWriter(processIn, DEFAULT_CHARSET));
this.processOut = new BufferedReader(new InputStreamReader(processOut, DEFAULT_CHARSET));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
use of java.io.UnsupportedEncodingException in project hive by apache.
the class HiveBaseResultSet method getBinaryStream.
public InputStream getBinaryStream(int columnIndex) throws SQLException {
Object obj = getObject(columnIndex);
if (obj == null) {
return null;
} else if (obj instanceof InputStream) {
return (InputStream) obj;
} else if (obj instanceof byte[]) {
byte[] byteArray = (byte[]) obj;
InputStream is = new ByteArrayInputStream(byteArray);
return is;
} else if (obj instanceof String) {
String str = (String) obj;
InputStream is = null;
try {
is = new ByteArrayInputStream(str.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new SQLException("Illegal conversion to binary stream from column " + columnIndex + " - Unsupported encoding exception");
}
return is;
}
throw new SQLException("Illegal conversion to binary stream from column " + columnIndex);
}
use of java.io.UnsupportedEncodingException in project storm by apache.
the class JSONOpaqueSerializer method serialize.
@Override
public byte[] serialize(OpaqueValue obj) {
List toSer = new ArrayList(3);
toSer.add(obj.currTxid);
toSer.add(obj.curr);
toSer.add(obj.prev);
try {
return JSONValue.toJSONString(toSer).getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
Aggregations