@Override public Object decode(byte[] value) { String stringResult = new String(value, keyField.CHARSET); Object result = DataConverter.INSTANCE.fromString(keyField.getDataType(), stringResult); return result; }
case other: case temporal: String stringValue = DataConverter.INSTANCE.toString(this.keyField.getDataType(), value); bytesValue = DataConverter.INSTANCE.toBytes(DataType.String, stringValue); break; default: bytesValue = DataConverter.INSTANCE.toBytes(this.keyField.getDataType(), value); break; int hashValue = Jenkins32.instance().hash(bytesValue); hashValue++; hashValueStr = DataConverter.INSTANCE.toString(DataType.Int, hashValue); break; case MURMUR_32: hashValue = Murmur32.instance().hash(bytesValue); hashValue++; hashValueStr = DataConverter.INSTANCE.toString(DataType.Int, hashValue); break; case MURMUR_128: long hashValueLong = Murmur128.instance().hash(bytesValue); hashValueLong++; hashValueStr = DataConverter.INSTANCE.toString(DataType.Long, hashValueLong); break; default:
switch (this.keyField.getDataType()) { case Short: Short shortValue = DataConverter.INSTANCE.toShort(DataType.Short, value); result = Short.valueOf((short) (shortValue.shortValue() + INCREMENT_INTEGRAL)); break; case Int: Integer intValue = DataConverter.INSTANCE.toInt(DataType.Int, value); result = Integer.valueOf(intValue.intValue() + INCREMENT_INTEGRAL); break; case UnsignedInt: UnsignedInteger uintValue = DataConverter.INSTANCE.toUnsignedInt(DataType.UnsignedInt, value); result = UnsignedInteger.valueOf(uintValue.longValue() + INCREMENT_INTEGRAL); break; case Long: Long longValue = DataConverter.INSTANCE.toLong(DataType.Long, value); result = Long.valueOf(longValue.longValue() + INCREMENT_INTEGRAL); break; case UnsignedLong: UnsignedLong ulongValue = DataConverter.INSTANCE.toUnsignedLong(DataType.UnsignedLong, value); BigInteger bigIntValue = ulongValue.bigIntegerValue(); bigIntValue = bigIntValue.add(BigInteger.valueOf(INCREMENT_INTEGRAL)); break; case Integer: BigInteger integerValue = DataConverter.INSTANCE.toInteger(DataType.Integer, value); result = integerValue.add(BigInteger.valueOf(INCREMENT_INTEGRAL)); break;
switch (sourceDataType) { case Float: Float floatValue = this.dataConverter.toFloat(property.getType(), value); int intBits = Float.floatToRawIntBits(floatValue.floatValue()); intBits++; Float floatResult = Float.valueOf(Float.intBitsToFloat(intBits)); result = this.dataConverter.toString(type, floatResult); break; case Double: Double doubleValue = this.dataConverter.toDouble(property.getType(), value); long longBits = Double.doubleToRawLongBits(doubleValue.doubleValue()); longBits++; Double doubleResult = Double.valueOf(Double.longBitsToDouble(longBits)); result = this.dataConverter.toString(type, doubleResult); break; case Decimal: BigDecimal decimalValue = this.dataConverter.toDecimal(property.getType(), value); longBits++; doubleResult = Double.valueOf(Double.longBitsToDouble(longBits)); result = this.dataConverter.toString(type, doubleResult); break; default:
case Date: case Duration: String resultStr = DataConverter.INSTANCE.toString(sourceProperty, value); result = Bytes.toBytes(resultStr); break; case DateTime: resultStr = DataConverter.INSTANCE.toString(sourceProperty, value); result = Bytes.toBytes(resultStr); break; if (!sourceProperty.isMany()) { BigDecimal resultDecimal = DataConverter.INSTANCE .toDecimal(sourceProperty.getType(), value); result = Bytes.toBytes(resultDecimal); } else { String strResult = DataConverter.INSTANCE.toString(sourceProperty, value); result = Bytes.toBytes(strResult); case Bytes: if (!sourceProperty.isMany()) { byte[] resultBytes = DataConverter.INSTANCE.toBytes(sourceProperty.getType(), value); result = resultBytes; } else { String strResult = DataConverter.INSTANCE.toString(sourceProperty, value); result = Bytes.toBytes(strResult); case Byte: if (!sourceProperty.isMany()) { byte resultByte = DataConverter.INSTANCE.toByte(sourceProperty.getType(), value);
/** * As per SDO 2.1 spec every temporal data type can be converted to a date, * not a long however. So get to a date then a long, then manipulate/increment * the value and convert back.. * * @param type * @param value * @return */ private String increment(Type type, Object value) { Date dateValue = this.dataConverter.toDate(property.getType(), value); Long longValue = dateValue.getTime(); DataType dataType = DataType.valueOf(property.getType().getName()); Long incrementLongValue = longValue + getIncrement(dataType); Date incrementDate = new Date(incrementLongValue); // back to whatever its native type is Object incrementValue = this.dataConverter.convert(property.getType(), incrementDate); // re format the string under its native type String result = this.dataConverter.toString(property.getType(), incrementValue); return result; }
@Override public byte[] encode(Object value) { String stringValue = DataConverter.INSTANCE.toString(keyField.getDataType(), value); byte[] result = stringValue.getBytes(keyField.CHARSET); return result; }
private byte[] nextLiteralToBytes() { Object value = this.dataConverter.convert(property.getType(), this.literal); return this.fieldConfig.getCodec().encodeNext(value); } }
@Override public byte[] encode(Object value) { byte[] bytesValue = DataConverter.INSTANCE.toBytes(this.keyField.getDataType(), value); return bytesValue; }
throw new GraphServiceException("property, " + property + ", must be datatype " + DataType.Long + " to support increment operations"); long longDataValue = DataConverter.INSTANCE.toLong(property.getType(), dataValue); rowWriter.incrementRowData(dataObject, sequence, property, longDataValue);
@Override public byte[] encodeNext(Object value) { String stringValue = DataConverter.INSTANCE.toString(keyField.getDataType(), value); byte[] bytesValue = stringValue.getBytes(keyField.CHARSET); byte[] result = new byte[bytesValue.length + 1]; System.arraycopy(bytesValue, 0, result, 0, bytesValue.length); result[bytesValue.length] = Byte.MIN_VALUE; return result; }
private byte[] literalToBytes() { Object value = this.dataConverter.convert(property.getType(), this.literal); return this.fieldConfig.getCodec().encode(value); }
@Override public byte[] encode(Object value) { byte[] bytesValue = DataConverter.INSTANCE.toBytes(this.keyField.getDataType(), value); byte[] result = null; switch (this.hashName) { case JENKINS_32: result = Bytes.toBytes(Jenkins32.instance().hash(bytesValue)); break; case MURMUR_32: result = Bytes.toBytes(Murmur32.instance().hash(bytesValue)); break; case MURMUR_128: result = Bytes.toBytes(Murmur128.instance().hash(bytesValue)); break; default: throw new IllegalArgumentException("unknown hash, " + this.hashName); } return result; }
switch (concurrent.getDataFlavor()) { case version: long longDataValue = DataConverter.INSTANCE.toLong(property.getType(), dataValue); byte[] valueBytes = HBaseDataConverter.INSTANCE.toBytes(property, longDataValue); byte[] concurrQual = null;
case other: case temporal: String stringValue = DataConverter.INSTANCE.toString(this.keyField.getDataType(), value); bytesValue = DataConverter.INSTANCE.toBytes(DataType.String, stringValue); break; default: bytesValue = DataConverter.INSTANCE.toBytes(this.keyField.getDataType(), value); break; case JENKINS_32: int hashValue = Jenkins32.instance().hash(bytesValue); hashValueStr = DataConverter.INSTANCE.toString(DataType.Int, hashValue); break; case MURMUR_32: hashValue = Murmur32.instance().hash(bytesValue); hashValueStr = DataConverter.INSTANCE.toString(DataType.Int, hashValue); break; case MURMUR_128: long hashValueLong = Murmur128.instance().hash(bytesValue); hashValueStr = DataConverter.INSTANCE.toString(DataType.Long, hashValueLong); break; default:
@Override public Object decode(byte[] value) { byte[] value2 = value; if (value[value.length - 1] == Byte.MIN_VALUE) { value2 = new byte[value.length - 1]; System.arraycopy(value, 0, value2, 0, value.length - 1); } byte[] bytesValue = this.padding.strip(value2, this.getMaxLength(), this.getDataFlavor()); String stringValue = new String(bytesValue, this.keyField.CHARSET); Object result = DataConverter.INSTANCE.fromString(this.keyField.getDataType(), stringValue); return result; }
@Override public byte[] encodeNext(Object value) { String stringValue = DataConverter.INSTANCE.toString(this.keyField.getDataType(), value); byte[] bytesValue = stringValue.getBytes(this.keyField.CHARSET); byte[] paddedValue = this.padding.pad(bytesValue, this.getMaxLength(), this.getDataFlavor()); byte[] result = new byte[paddedValue.length + 1]; System.arraycopy(paddedValue, 0, result, 0, paddedValue.length); result[result.length - 1] = Byte.MIN_VALUE; return result; }
private byte[] nextLiteralToBytes() { Object value = this.dataConverter.convert(property.getType(), this.literal); return this.fieldConfig.getCodec().encodeNext(value); }
case Duration: String resultStr = Bytes.toString(value); result = DataConverter.INSTANCE.fromString(targetProperty, resultStr); break; case Date: resultStr = Bytes.toString(value); result = DataConverter.INSTANCE.fromString(targetProperty, resultStr); break; case DateTime: result = DataConverter.INSTANCE.fromString(targetProperty, resultStr); break; result = Bytes.toBigDecimal(value); else result = DataConverter.INSTANCE.fromString(targetProperty, Bytes.toString(value)); break; case Bytes: result = Character.valueOf(Bytes.toString(value).charAt(0)); else result = DataConverter.INSTANCE.fromString(targetProperty, Bytes.toString(value)); break; case Double: result = new BigInteger(value); else result = DataConverter.INSTANCE.fromString(targetProperty, Bytes.toString(value)); break;
@Override public byte[] encode(Object value) { String stringValue = DataConverter.INSTANCE.toString(this.keyField.getDataType(), value); byte[] bytesValue = stringValue.getBytes(this.keyField.CHARSET); return this.padding.pad(bytesValue, this.getMaxLength(), this.getDataFlavor()); }