@Override public AFloat deserialize(DataInput in) throws HyracksDataException { return new AFloat(FloatSerializerDeserializer.read(in)); }
/** * Applies certain math function (e.g., ceil or floor) to a float value and returns that value. */ public static float applyMathFunctionToFloatValue(IAObject sourceObject, TypeCastingMathFunctionType mathFunction) { switch (mathFunction) { case CEIL: return (float) Math.ceil(((AFloat) sourceObject).getFloatValue()); case FLOOR: return (float) Math.floor(((AFloat) sourceObject).getFloatValue()); default: return ((AFloat) sourceObject).getFloatValue(); } }
@Override public boolean deepEqual(IAObject obj) { return equals(obj); }
jaccThresh = constVal.getObject(); } else { jaccThresh = new AFloat((float) ((ADouble) constVal.getObject()).getDoubleValue()); threshVal = ((AFloat) constVal.getObject()).getFloatValue(); } else { threshVal = (float) ((ADouble) constVal.getObject()).getDoubleValue(); if (f > 1.0f) f = 1.0f; jaccThresh = new AFloat(f); } else { return null;
@Override public int hash() { return hashCode(); }
public static IAObject getSimThreshold(MetadataProvider metadata, String simFuncName) { String simThresholValue = metadata.getProperty(SIM_THRESHOLD_PROP_NAME); IAObject ret = null; if (simFuncName.equals(JACCARD_FUNCTION_NAME)) { if (simThresholValue != null) { float jaccThresh = Float.parseFloat(simThresholValue); ret = new AFloat(jaccThresh); } else { ret = new AFloat(JACCARD_DEFAULT_SIM_THRESHOLD); } } else if (simFuncName.equals(EDIT_DISTANCE_FUNCTION_NAME)) { if (simThresholValue != null) { int edThresh = Integer.parseInt(simThresholValue); ret = new AInt32(edThresh); } else { ret = new AFloat(EDIT_DISTANCE_DEFAULT_SIM_THRESHOLD); } } return ret; }
@Override public boolean equals(Object o) { if (!(o instanceof AFloat)) { return false; } else { return Float.floatToIntBits(value) == Float.floatToIntBits(((AFloat) o).getFloatValue()); } }
@Override public IAObject convertType(IAObject sourceObject, TypeCastingMathFunctionType mathFunction) throws HyracksDataException { if (mathFunction != TypeCastingMathFunctionType.NONE) { throw new RuntimeDataException(ErrorCode.INVALID_TYPE_CASTING_MATH_FUNCTION, mathFunction, ATypeTag.DOUBLE, ATypeTag.FLOAT); } double sourceValue = ((ADouble) sourceObject).getDoubleValue(); float targetValue = convert(sourceValue); return new AFloat(targetValue); }
@Override public void serialize(AFloat instance, DataOutput out) throws HyracksDataException { FloatSerializerDeserializer.write(instance.getFloatValue(), out); }
private static IAObject createValue(IAType type, Number value) { switch (type.getTypeTag()) { case TINYINT: return new AInt8(value.byteValue()); case SMALLINT: return new AInt16(value.shortValue()); case INTEGER: return new AInt32(value.intValue()); case BIGINT: return new AInt64(value.longValue()); case FLOAT: return new AFloat(value.floatValue()); case DOUBLE: return new ADouble(value.doubleValue()); default: throw new IllegalStateException(type.toString()); } }
@Override public IAObject convertType(IAObject sourceObject, TypeCastingMathFunctionType mathFunction) throws HyracksDataException { if (mathFunction != TypeCastingMathFunctionType.NONE) { throw new RuntimeDataException(ErrorCode.INVALID_TYPE_CASTING_MATH_FUNCTION, mathFunction, ATypeTag.FLOAT, ATypeTag.DOUBLE); } double targetValue = ((AFloat) sourceObject).getFloatValue(); return new ADouble(targetValue); }
@Override public IAObject convertType(IAObject sourceObject, TypeCastingMathFunctionType mathFunction) throws HyracksDataException { float val; switch (sourceObject.getType().getTypeTag()) { case TINYINT: val = ((AInt8) sourceObject).getByteValue(); break; case SMALLINT: val = ((AInt16) sourceObject).getShortValue(); break; case INTEGER: val = ((AInt32) sourceObject).getIntegerValue(); break; case BIGINT: val = ((AInt64) sourceObject).getLongValue(); break; default: throw new RuntimeDataException(ErrorCode.TYPE_CONVERT_INTEGER_SOURCE, Arrays.toString( new ATypeTag[] { ATypeTag.TINYINT, ATypeTag.SMALLINT, ATypeTag.INTEGER, ATypeTag.BIGINT })); } return new AFloat(val); } }
AsterixConstantValue constVal = (AsterixConstantValue) constExpr.getValue(); if (constVal.getObject().getType().equals(BuiltinType.AFLOAT)) { simThreshold = ((AFloat) constVal.getObject()).getFloatValue(); } else { simThreshold = FuzzyUtils.getSimThreshold(metadataProvider);
public static IAObject objectFromLiteral(Literal valLiteral) { switch (valLiteral.getLiteralType()) { case DOUBLE: DoubleLiteral d = (DoubleLiteral) valLiteral; return new ADouble(d.getValue()); case FALSE: return ABoolean.FALSE; case FLOAT: FloatLiteral fl = (FloatLiteral) valLiteral; return new AFloat(fl.getValue()); case INTEGER: IntegerLiteral il = (IntegerLiteral) valLiteral; return new AInt32(il.getValue()); case LONG: LongIntegerLiteral ll = (LongIntegerLiteral) valLiteral; return new AInt64(ll.getValue()); case MISSING: return AMissing.MISSING; case NULL: return ANull.NULL; case STRING: StringLiteral sl = (StringLiteral) valLiteral; return new AString(sl.getValue()); case TRUE: return ABoolean.TRUE; default: throw new IllegalStateException(); } }
return new DisjunctiveSearchModifierFactory(); case JACCARD: float jaccThresh = ((AFloat) simThresh).getFloatValue(); return new JaccardSearchModifierFactory(jaccThresh); case EDIT_DISTANCE: