use of java.nio.charset.CharacterCodingException in project hive by apache.
the class LazyHiveChar method init.
@Override
public void init(ByteArrayRef bytes, int start, int length) {
if (oi.isEscaped()) {
Text textData = data.getTextValue();
// This is doing a lot of copying here, this could be improved by enforcing length
// at the same time as escaping rather than as separate steps.
LazyUtils.copyAndEscapeStringDataToText(bytes.getData(), start, length, oi.getEscapeChar(), textData);
data.set(textData.toString(), maxLength);
isNull = false;
} else {
String byteData = null;
try {
byteData = Text.decode(bytes.getData(), start, length);
data.set(byteData, maxLength);
isNull = false;
} catch (CharacterCodingException e) {
isNull = true;
LOG.debug("Data not in the HiveChar data type range so converted to null.", e);
}
}
}
use of java.nio.charset.CharacterCodingException in project robovm by robovm.
the class CharacterCodingExceptionTest method testConstructor.
public void testConstructor() {
CharacterCodingException ex = new CharacterCodingException();
assertTrue(ex instanceof IOException);
assertNull(ex.getCause());
assertNull(ex.getMessage());
}
use of java.nio.charset.CharacterCodingException in project robovm by robovm.
the class MalformedInputExceptionTest method testConstructor.
public void testConstructor() {
MalformedInputException ex = new MalformedInputException(3);
assertTrue(ex instanceof CharacterCodingException);
assertNull(ex.getCause());
assertEquals(ex.getInputLength(), 3);
assertTrue(ex.getMessage().indexOf("3") != -1);
ex = new MalformedInputException(-3);
assertNull(ex.getCause());
assertEquals(ex.getInputLength(), -3);
assertTrue(ex.getMessage().indexOf("-3") != -1);
ex = new MalformedInputException(0);
assertNull(ex.getCause());
assertEquals(ex.getInputLength(), 0);
assertTrue(ex.getMessage().indexOf("0") != -1);
}
use of java.nio.charset.CharacterCodingException in project robovm by robovm.
the class UnmappableCharacterExceptionTest method testConstructor.
public void testConstructor() {
UnmappableCharacterException ex = new UnmappableCharacterException(3);
assertTrue(ex instanceof CharacterCodingException);
assertNull(ex.getCause());
assertEquals(ex.getInputLength(), 3);
assertTrue(ex.getMessage().indexOf("3") != -1);
ex = new UnmappableCharacterException(-3);
assertNull(ex.getCause());
assertEquals(ex.getInputLength(), -3);
assertTrue(ex.getMessage().indexOf("-3") != -1);
ex = new UnmappableCharacterException(0);
assertNull(ex.getCause());
assertEquals(ex.getInputLength(), 0);
assertTrue(ex.getMessage().indexOf("0") != -1);
}
use of java.nio.charset.CharacterCodingException in project brisk by riptano.
the class SchemaManagerService method buildTable.
private Table buildTable(CfDef cfDef) {
Table table = new Table();
table.setDbName(cfDef.keyspace);
table.setTableName(cfDef.name);
table.setTableType(TableType.EXTERNAL_TABLE.toString());
table.putToParameters("EXTERNAL", "TRUE");
table.putToParameters("cassandra.ks.name", cfDef.keyspace);
table.putToParameters("cassandra.cf.name", cfDef.name);
table.putToParameters("cassandra.slice.predicate.size", "100");
table.putToParameters("storage_handler", "org.apache.hadoop.hive.cassandra.CassandraStorageHandler");
table.setPartitionKeys(new ArrayList<FieldSchema>());
// cassandra.column.mapping
StorageDescriptor sd = new StorageDescriptor();
sd.setInputFormat("org.apache.hadoop.hive.cassandra.input.HiveCassandraStandardColumnInputFormat");
sd.setOutputFormat("org.apache.hadoop.hive.cassandra.output.HiveCassandraOutputFormat");
sd.setParameters(new HashMap<String, String>());
try {
sd.setLocation(warehouse.getDefaultTablePath(cfDef.keyspace, cfDef.name).toString());
} catch (MetaException me) {
log.error("could not build path information correctly", me);
}
SerDeInfo serde = new SerDeInfo();
serde.setSerializationLib("org.apache.hadoop.hive.cassandra.serde.CassandraColumnSerDe");
serde.putToParameters("serialization.format", "1");
StringBuilder mapping = new StringBuilder();
StringBuilder validator = new StringBuilder();
try {
CFMetaData cfm = CFMetaData.fromThrift(cfDef);
AbstractType keyValidator = cfDef.key_validation_class != null ? TypeParser.parse(cfDef.key_validation_class) : BytesType.instance;
addTypeToStorageDescriptor(sd, ByteBufferUtil.bytes("row_key"), keyValidator, keyValidator);
mapping.append(":key");
validator.append(keyValidator.toString());
for (ColumnDef column : cfDef.getColumn_metadata()) {
addTypeToStorageDescriptor(sd, column.name, TypeParser.parse(cfDef.comparator_type), TypeParser.parse(column.getValidation_class()));
try {
mapping.append(",");
mapping.append(ByteBufferUtil.string(column.name));
validator.append(",");
validator.append(column.getValidation_class());
} catch (CharacterCodingException e) {
log.error("could not build column mapping correctly", e);
}
}
serde.putToParameters("cassandra.columns.mapping", mapping.toString());
serde.putToParameters("cassandra.cf.validatorType", validator.toString());
sd.setSerdeInfo(serde);
} catch (ConfigurationException ce) {
throw new CassandraHiveMetaStoreException("Problem converting comparator type: " + cfDef.comparator_type, ce);
} catch (InvalidRequestException ire) {
throw new CassandraHiveMetaStoreException("Problem parsing CfDef: " + cfDef.name, ire);
}
table.setSd(sd);
if (log.isDebugEnabled())
log.debug("constructed table for CF:{} {}", cfDef.name, table.toString());
return table;
}
Aggregations