public void writeColumn(TblColRef column, byte[] value, int valueLen, int roundingFlag, byte dft, byte[] output, int outputOffset) { Dictionary<String> dict = getDictionary(column); int columnLen = getColumnLength(column); // non-dict value if (dict == null) { byte[] valueBytes = padFixLen(columnLen, value); System.arraycopy(valueBytes, 0, output, outputOffset, columnLen); return; } // dict value try { int id = dict.getIdFromValueBytes(value, 0, valueLen, roundingFlag); BytesUtil.writeUnsigned(id, output, outputOffset, dict.getSizeOfId()); } catch (IllegalArgumentException ex) { for (int i = outputOffset; i < outputOffset + columnLen; i++) output[i] = dft; logger.error("Can't translate value " + Bytes.toString(value, 0, valueLen) + " to dictionary ID, roundingFlag " + roundingFlag + ". Using default value " + String.format("\\x%02X", dft)); } }
public String readColumnString(TblColRef col, byte[] bytes, int bytesLen) { Dictionary<String> dict = getDictionary(col); if (dict == null) { bytes = Bytes.head(bytes, bytesLen); if (isNull(bytes)) { return null; } bytes = removeFixLenPad(bytes, 0); return Bytes.toString(bytes); } else { int id = BytesUtil.readUnsigned(bytes, 0, bytesLen); try { String value = dict.getValueFromId(id); return value; } catch (IllegalArgumentException e) { logger.error("Can't get dictionary value for column " + col.getName() + " (id = " + id + ")"); return ""; } } }
public void writeColumn(TblColRef column, byte[] value, int valueLen, int roundingFlag, byte dft, byte[] output, int outputOffset) { Dictionary<String> dict = getDictionary(column); int columnLen = getColumnLength(column); // non-dict value if (dict == null) { byte[] valueBytes = padFixLen(columnLen, value); System.arraycopy(valueBytes, 0, output, outputOffset, columnLen); return; } // dict value try { int id = dict.getIdFromValueBytes(value, 0, valueLen, roundingFlag); BytesUtil.writeUnsigned(id, output, outputOffset, dict.getSizeOfId()); } catch (IllegalArgumentException ex) { for (int i = outputOffset; i < outputOffset + columnLen; i++) output[i] = dft; logger.error("Can't translate value " + Bytes.toString(value, 0, valueLen) + " to dictionary ID, roundingFlag " + roundingFlag + ". Using default value " + String.format("\\x%02X", dft)); } }
public String readColumnString(TblColRef col, byte[] bytes, int bytesLen) { Dictionary<String> dict = getDictionary(col); if (dict == null) { bytes = Bytes.head(bytes, bytesLen); if (isNull(bytes)) { return null; } bytes = removeFixLenPad(bytes, 0); return Bytes.toString(bytes); } else { int id = BytesUtil.readUnsigned(bytes, 0, bytesLen); try { String value = dict.getValueFromId(id); return value; } catch (IllegalArgumentException e) { logger.error("Can't get dictionary value for column " + col.getName() + " (id = " + id + ")"); return ""; } } }