Examples of BigDecimalWrapper


Examples of com.foundationdb.server.types.common.BigDecimalWrapper

        builder.covers(MNumeric.DECIMAL, 0);
    }

    @Override
    protected void doEvaluate(TExecutionContext context, LazyList<? extends ValueSource> inputs, ValueTarget output) {
        BigDecimalWrapper num = TBigDecimal.getWrapper(inputs.get(0), context.inputTypeAt(0));
       
        output.putInt64(num.getSign());     
    }
View Full Code Here

Examples of com.foundationdb.server.types.common.BigDecimalWrapper

        protected abstract void apply(BigDecimalWrapper io, int scale);
    }

    @Override
    protected void doEvaluate(TExecutionContext context, LazyList<? extends ValueSource> inputs, ValueTarget output) {
        BigDecimalWrapper result = TBigDecimal.getWrapper(context, DEC_INDEX);
        result.set(TBigDecimal.getWrapper(inputs.get(0), context.inputTypeAt(0)));
        int scale = signatureStrategy.roundToScale(inputs);
        roundingStrategy.apply(result, scale);
        output.putObject(result);
    }
View Full Code Here

Examples of com.foundationdb.server.types.common.BigDecimalWrapper

            return new BigDecimalWrapperImpl(decimal);
        }

        @Override
        protected Object rawFromValue(ValueSource value) {
            BigDecimalWrapper wrapper = TBigDecimal.getWrapper(value, type);
            return wrapper.asBigDecimal().unscaledValue().longValue();
        }
View Full Code Here

Examples of com.foundationdb.server.types.common.BigDecimalWrapper

            return new BigDecimalWrapperImpl(sb.toString());
        }

        @Override
        protected Object rawFromValue(ValueSource value) {
            BigDecimalWrapper wrapper = TBigDecimal.getWrapper(value, type);
            int precision = type.attribute(DecimalAttribute.PRECISION);
            int scale = type.attribute(DecimalAttribute.SCALE);
            return ByteString.copyFrom(ConversionHelperBigDecimal.bytesFromObject(wrapper.asBigDecimal(), precision, scale));
        }
View Full Code Here

Examples of com.foundationdb.server.types.common.BigDecimalWrapper

            rowDataSource.bind(fieldDefs[d], rowData);

            RowDataValueSource rowDataValueSource = (RowDataValueSource)rowDataSource;
            TClass tclass = tinstances[d].typeClass();
            if (tclass == MNumeric.DECIMAL) {
                BigDecimalWrapper wrapper = TBigDecimal.getWrapper(rowDataValueSource, tinstances[d]);
                coords[d] = wrapper.asBigDecimal().doubleValue();
            }
            else if (tclass == MNumeric.BIGINT) {
                coords[d] = rowDataValueSource.getInt64();
            }
            else if (tclass == MNumeric.INT) {
View Full Code Here

Examples of com.foundationdb.server.types.common.BigDecimalWrapper

            private static final int DEC_INDEX = 1;

            @Override
            protected void doEvaluate(TExecutionContext context, LazyList<? extends ValueSource> inputs, ValueTarget output) {
                TClass cached = (TClass) context.objectAt(RET_TYPE_INDEX);
                BigDecimalWrapper result = TBigDecimal.getWrapper(context, DEC_INDEX);
                result.set(TBigDecimal.getWrapper(inputs.get(0), context.inputTypeAt(0)));
                result = roundType.evaluate(result);
               
                TClass outT = context.outputType().typeClass();
                if (cached != null && cached != outT)
                    throw new AssertionError(String.format("Mismatched type! cached: [%s] != output: [%s]",
                                                           cached,
                                                           outT));
                else if (outT == MNumeric.DECIMAL)
                    output.putObject(result);
                else if (outT == MNumeric.BIGINT)
                   output.putInt64(result.asBigDecimal().longValue());
                else if (outT == MNumeric.INT) // INT
                    output.putInt32(result.asBigDecimal().intValue());
                else
                    throw new AssertionError("Unexpected output type: " + outT);
            }

            @Override
View Full Code Here

Examples of com.foundationdb.server.types.common.BigDecimalWrapper

        ConversionHelperBigDecimal.decodeToString(bytes, 0, precision, scale, AkibanAppender.of(sb));
        return new BigDecimalWrapperImpl(sb.toString());
    }

    public static BigDecimalWrapper getWrapper(TExecutionContext context, int index) {
        BigDecimalWrapper wrapper = (BigDecimalWrapper)context.exectimeObjectAt(index);
        if (wrapper == null) {
            wrapper = new BigDecimalWrapperImpl();
            context.putExectimeObject(index, wrapper);
        }
        wrapper.reset();
        return wrapper;
    }
View Full Code Here

Examples of com.foundationdb.server.types.common.BigDecimalWrapper

        int inputPrecision = inputInstance.attribute(DecimalAttribute.PRECISION);
        int targetPrecision = targetInstance.attribute(DecimalAttribute.PRECISION);
        int inputScale = inputInstance.attribute(DecimalAttribute.SCALE);
        int targetScale = targetInstance.attribute(DecimalAttribute.SCALE);
        if ( (inputPrecision != targetPrecision) || (inputScale != targetScale) ) {
            BigDecimalWrapper bdw = new BigDecimalWrapperImpl().set(getWrapper(source, inputInstance));
            bdw.round(targetScale);
            target.putObject(bdw);
        }
        else if (source.hasCacheValue()) {
            target.putObject(source.getObject());
        }
View Full Code Here

Examples of com.foundationdb.server.types.common.BigDecimalWrapper

    protected boolean tryFromObject(TExecutionContext context, ValueSource in, ValueTarget out) {
        // If the incoming ValueSource is a DECIMAL, *and* it has a cache value (ie an BigDecimalWrapper), then
        // we can just copy the wrapper into the output. If the incoming is a DECIMAL with bytes (its raw form), we
        // can only copy those bytes if the TInstance match -- and super.tryFromObject already makes that check.
        if (in.getType().typeClass() instanceof TBigDecimal && in.hasCacheValue()) {
            BigDecimalWrapper cached = (BigDecimalWrapper) in.getObject();
            out.putObject(new BigDecimalWrapperImpl(cached.asBigDecimal()));
            return true;
        }
        return super.tryFromObject(context, in, out);
    }
View Full Code Here

Examples of com.foundationdb.server.types.common.BigDecimalWrapper

        int scale = num.getScale();

        int expectedPre = context.outputType().attribute(DecimalAttribute.PRECISION);
        int expectedScale = context.outputType().attribute(DecimalAttribute.SCALE);

        BigDecimalWrapper meta[] = (BigDecimalWrapper[]) context.outputType().getMetaData();

        if (meta == null)
        {
            // compute the max value:
            meta = new BigDecimalWrapper[2];
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.