public static double toXorDouble(byte[] value, int offset, int length) { return Double.longBitsToDouble(toXorLong(value, offset, length)); }
/** * Method to type case the data based on modified data type. This method will used for * retrieving the data after change in data type restructure operation * * @param data * @param restructuredDataType * @param currentDataOffset * @param length * @return */ public static long getDataBasedOnRestructuredDataType(byte[] data, DataType restructuredDataType, int currentDataOffset, int length) { long value = 0L; if (restructuredDataType == DataTypes.INT) { value = ByteUtil.toXorInt(data, currentDataOffset, length); } else if (restructuredDataType == DataTypes.LONG) { value = ByteUtil.toXorLong(data, currentDataOffset, length); } return value; }
/** * Method for computing default value for no dictionary * * @param defaultValue * @return */ private static Object getNoDictionaryDefaultValue(DataType datatype, byte[] defaultValue) { Object noDictionaryDefaultValue = null; String value = null; if (!isDefaultValueNull(defaultValue)) { if (datatype == DataTypes.INT) { value = new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET)); noDictionaryDefaultValue = Integer.parseInt(value); } else if (datatype == DataTypes.LONG) { value = new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET)); noDictionaryDefaultValue = Long.parseLong(value); } else if (datatype == DataTypes.TIMESTAMP) { long timestampValue = ByteUtil.toXorLong(defaultValue, 0, defaultValue.length); noDictionaryDefaultValue = timestampValue * 1000L; } else { noDictionaryDefaultValue = DataTypeUtil.getDataTypeConverter().convertFromByteToUTF8Bytes(defaultValue); } } return noDictionaryDefaultValue; }
@Override public void fillVector(byte[] data, CarbonColumnVector vector) { // start position will be used to store the current data position int localOffset = 0; for (int i = 0; i < numberOfRows; i++) { int length = (((data[localOffset] & 0xFF) << 8) | (data[localOffset + 1] & 0xFF)); localOffset += 2; if (length == 0) { vector.putNull(i); } else { vector.putLong(i, ByteUtil.toXorLong(data, localOffset, length) * 1000L); } localOffset += length; } } }
return null; return ByteUtil.toXorLong(dataInBytes, 0, dataInBytes.length); } else if (actualDataType == DataTypes.TIMESTAMP) { if (isEmptyByteArray(dataInBytes)) { return ByteUtil.toXorLong(dataInBytes, 0, dataInBytes.length) * 1000L; } else { return ByteUtil.toXorLong(dataInBytes, 0, dataInBytes.length);
.getDataBasedOnRestructuredDataType(value, vector.getBlockDataType(), 0, length)); } else if (dt == DataTypes.TIMESTAMP) { vector.putLong(vectorRow, ByteUtil.toXorLong(value, 0, length) * 1000L);
currentDataOffset, length)); } else if (dt == DataTypes.TIMESTAMP) { vector.putLong(vectorRow, ByteUtil.toXorLong(data, currentDataOffset, length) * 1000L);