use of org.apache.carbondata.core.devapi.DictionaryGenerationException in project carbondata by apache.
the class DictionaryFieldConverterImpl method convert.
@Override
public void convert(CarbonRow row, BadRecordLogHolder logHolder) throws CarbonDataLoadingException {
try {
String parsedValue = null;
String dimensionValue = row.getString(index);
if (dimensionValue == null || dimensionValue.equals(nullFormat)) {
parsedValue = CarbonCommonConstants.MEMBER_DEFAULT_VAL;
} else {
parsedValue = DataTypeUtil.parseValue(dimensionValue, carbonDimension);
}
if (null == parsedValue) {
if ((dimensionValue.length() > 0) || (dimensionValue.length() == 0 && isEmptyBadRecord)) {
String dataType = carbonDimension.getDataType().getName();
logHolder.setReason("The value " + " \"" + dimensionValue + "\"" + " with column name " + carbonDimension.getColName() + " and column data type " + dataType + " is not a valid " + dataType + " type.");
}
row.update(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY, index);
} else {
row.update(dictionaryGenerator.getOrGenerateKey(parsedValue), index);
}
} catch (DictionaryGenerationException e) {
throw new CarbonDataLoadingException(e);
}
}
use of org.apache.carbondata.core.devapi.DictionaryGenerationException in project carbondata by apache.
the class DictionaryFieldConverterImpl method convert.
@Override
public void convert(CarbonRow row, BadRecordLogHolder logHolder) throws CarbonDataLoadingException {
try {
String parsedValue = null;
String dimensionValue = row.getString(index);
if (dimensionValue == null || dimensionValue.equals(nullFormat)) {
parsedValue = CarbonCommonConstants.MEMBER_DEFAULT_VAL;
} else {
parsedValue = DataTypeUtil.parseValue(dimensionValue, carbonDimension);
}
if (null == parsedValue) {
if ((dimensionValue.length() > 0) || (dimensionValue.length() == 0 && isEmptyBadRecord)) {
String message = logHolder.getColumnMessageMap().get(carbonDimension.getColName());
if (null == message) {
message = CarbonDataProcessorUtil.prepareFailureReason(carbonDimension.getColName(), carbonDimension.getDataType());
logHolder.getColumnMessageMap().put(carbonDimension.getColName(), message);
}
logHolder.setReason(message);
}
row.update(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY, index);
} else {
row.update(dictionaryGenerator.getOrGenerateKey(parsedValue), index);
}
} catch (DictionaryGenerationException e) {
throw new CarbonDataLoadingException(e);
}
}
Aggregations