return BigDecimal.valueOf(actualType.getCodec().decodeLong(b, o, sortOrder)); } else if (equalsAny(actualType, PFloat.INSTANCE, PUnsignedFloat.INSTANCE)) { return BigDecimal.valueOf(actualType.getCodec().decodeFloat(b, o, sortOrder)); } else if (equalsAny(actualType, PDouble.INSTANCE, PUnsignedDouble.INSTANCE)) { return BigDecimal.valueOf(actualType.getCodec().decodeDouble(b, o, sortOrder));
@Override public Float toObject(byte[] b, int o, int l, PDataType actualType, SortOrder sortOrder, Integer maxLength, Integer scale) { if (l <= 0) { return null; } if (equalsAny(actualType, PFloat.INSTANCE, PUnsignedFloat.INSTANCE, PDouble.INSTANCE, PUnsignedDouble.INSTANCE, PLong.INSTANCE, PUnsignedLong.INSTANCE, PInteger.INSTANCE, PUnsignedInt.INSTANCE, PSmallint.INSTANCE, PUnsignedSmallint.INSTANCE, PTinyint.INSTANCE, PUnsignedTinyint.INSTANCE)) { return actualType.getCodec().decodeFloat(b, o, sortOrder); } else if (actualType == PDecimal.INSTANCE) { BigDecimal bd = (BigDecimal) actualType.toObject(b, o, l, actualType, sortOrder); return bd.floatValue(); } throwConstraintViolationException(actualType, this); return null; }
} else if (this.getClass() == PFloat.class) { isFloat = true; fvalue = this.getCodec().decodeFloat(lhs, lhsOffset, lhsSortOrder); } else if (this.isCoercibleTo(PDouble.INSTANCE)) { dvalue = this.getCodec().decodeDouble(lhs, lhsOffset, lhsSortOrder); invert = -1; isFloat = true; fvalue = rhsType.getCodec().decodeFloat(rhs, rhsOffset, rhsSortOrder); } else if (rhsType.isCoercibleTo(PDouble.INSTANCE)) { invert = -1;
} else if (this.getClass() == PFloat.class) { isFloat = true; fvalue = this.getCodec().decodeFloat(lhs, lhsOffset, lhsSortOrder); } else if (this.isCoercibleTo(PDouble.INSTANCE)) { dvalue = this.getCodec().decodeDouble(lhs, lhsOffset, lhsSortOrder); invert = -1; isFloat = true; fvalue = rhsType.getCodec().decodeFloat(rhs, rhsOffset, rhsSortOrder); } else if (rhsType.isCoercibleTo(PDouble.INSTANCE)) { invert = -1;
} else if (this.getClass() == PFloat.class) { isFloat = true; fvalue = this.getCodec().decodeFloat(lhs, lhsOffset, lhsSortOrder); } else if (this.isCoercibleTo(PDouble.INSTANCE)) { dvalue = this.getCodec().decodeDouble(lhs, lhsOffset, lhsSortOrder); invert = -1; isFloat = true; fvalue = rhsType.getCodec().decodeFloat(rhs, rhsOffset, rhsSortOrder); } else if (rhsType.isCoercibleTo(PDouble.INSTANCE)) { invert = -1;
return BigDecimal.valueOf(actualType.getCodec().decodeLong(b, o, sortOrder)); } else if (equalsAny(actualType, PFloat.INSTANCE, PUnsignedFloat.INSTANCE)) { return BigDecimal.valueOf(actualType.getCodec().decodeFloat(b, o, sortOrder)); } else if (equalsAny(actualType, PDouble.INSTANCE, PUnsignedDouble.INSTANCE)) { return BigDecimal.valueOf(actualType.getCodec().decodeDouble(b, o, sortOrder));
return BigDecimal.valueOf(actualType.getCodec().decodeLong(b, o, sortOrder)); } else if (equalsAny(actualType, PFloat.INSTANCE, PUnsignedFloat.INSTANCE)) { return BigDecimal.valueOf(actualType.getCodec().decodeFloat(b, o, sortOrder)); } else if (equalsAny(actualType, PDouble.INSTANCE, PUnsignedDouble.INSTANCE)) { return BigDecimal.valueOf(actualType.getCodec().decodeDouble(b, o, sortOrder));
@Override public Float toObject(byte[] b, int o, int l, PDataType actualType, SortOrder sortOrder, Integer maxLength, Integer scale) { if (l <= 0) { return null; } if (equalsAny(actualType, PFloat.INSTANCE, PUnsignedFloat.INSTANCE, PDouble.INSTANCE, PUnsignedDouble.INSTANCE, PLong.INSTANCE, PUnsignedLong.INSTANCE, PInteger.INSTANCE, PUnsignedInt.INSTANCE, PSmallint.INSTANCE, PUnsignedSmallint.INSTANCE, PTinyint.INSTANCE, PUnsignedTinyint.INSTANCE)) { return actualType.getCodec().decodeFloat(b, o, sortOrder); } else if (actualType == PDecimal.INSTANCE) { BigDecimal bd = (BigDecimal) actualType.toObject(b, o, l, actualType, sortOrder); return bd.floatValue(); } throwConstraintViolationException(actualType, this); return null; }
@Override public Float toObject(byte[] b, int o, int l, PDataType actualType, SortOrder sortOrder, Integer maxLength, Integer scale) { if (l <= 0) { return null; } if (equalsAny(actualType, PFloat.INSTANCE, PUnsignedFloat.INSTANCE, PDouble.INSTANCE, PUnsignedDouble.INSTANCE, PLong.INSTANCE, PUnsignedLong.INSTANCE, PInteger.INSTANCE, PUnsignedInt.INSTANCE, PSmallint.INSTANCE, PUnsignedSmallint.INSTANCE, PTinyint.INSTANCE, PUnsignedTinyint.INSTANCE)) { return actualType.getCodec().decodeFloat(b, o, sortOrder); } else if (actualType == PDecimal.INSTANCE) { BigDecimal bd = (BigDecimal) actualType.toObject(b, o, l, actualType, sortOrder); return bd.floatValue(); } throwConstraintViolationException(actualType, this); return null; }
ImmutableBytesWritable ptr = new ImmutableBytesWritable(); ptr.set(b); nb = PFloat.INSTANCE.getCodec().decodeFloat(ptr, SortOrder.DESC); assertEquals(na,nb); ba = PFloat.INSTANCE.toBytes(na); bb = PFloat.INSTANCE.toBytes(nb); float nna = PFloat.INSTANCE.getCodec().decodeFloat(ba, 0, SortOrder.DESC); float nnb = PFloat.INSTANCE.getCodec().decodeFloat(bb, 0, SortOrder.DESC); assertTrue(Float.compare(nna, nnb) < 0);
ImmutableBytesWritable ptr = new ImmutableBytesWritable(); ptr.set(b); nb = PUnsignedFloat.INSTANCE.getCodec().decodeFloat(ptr, SortOrder.DESC); assertEquals(na,nb);