Package com.foundationdb.tuple.TupleUtil

Examples of com.foundationdb.tuple.TupleUtil.DecodeResult


    @Test
    public void doubleEncodingTest() {
        Double initDouble = 4.5;
        byte[] bytes = TupleFloatingUtil.encode(initDouble);
        DecodeResult result = TupleFloatingUtil.decodeDouble(bytes, 1);
        assertEquals(initDouble, (Double) result.o);
       
        initDouble = -4.5;
        bytes = TupleFloatingUtil.encode(initDouble);
        result = TupleFloatingUtil.decodeDouble(bytes, 1);
View Full Code Here


   
    @Test
    public void floatEncodingTest() {
        Float initFloat = (float) 4.5;
        byte[] bytes = TupleFloatingUtil.encode(initFloat);
        DecodeResult result = TupleFloatingUtil.decodeFloat(bytes, 1);
        assertEquals(initFloat, (Float) result.o);
       
        initFloat = (float) -4.5;
        bytes = TupleFloatingUtil.encode(initFloat);
        result = TupleFloatingUtil.decodeFloat(bytes, 1);
View Full Code Here

   
    @Test
    public void bigIntEncodingTest() {
        BigInteger bigInteger = new BigInteger("12345678912345");
        byte[] bytes = TupleFloatingUtil.encode(bigInteger);
        DecodeResult result = TupleFloatingUtil.decodeBigInt(bytes, 1);
        assertEquals(bigInteger, (BigInteger) result.o);
       
        bigInteger = new BigInteger("-12345678912345");
        bytes = TupleFloatingUtil.encode(bigInteger);
        result = TupleFloatingUtil.decodeBigInt(bytes, 1);
View Full Code Here

   
    @Test
    public void bigDecEncodingTest() {
        BigDecimal bigDecimal = new BigDecimal("123456789.123456789");
        byte[] bytes = TupleFloatingUtil.encode(bigDecimal);
        DecodeResult result = TupleFloatingUtil.decodeBigDecimal(bytes, 1);
        assertEquals(bigDecimal, (BigDecimal) result.o);
       
        bigDecimal = new BigDecimal("-123456789.123456789");
        bytes = TupleFloatingUtil.encode(bigDecimal);
        result = TupleFloatingUtil.decodeBigDecimal(bytes, 1);
View Full Code Here

    @Test
    public void booleanEncodingTest() {
        Boolean bool = new Boolean(true);
        byte[] bytes = TupleFloatingUtil.encode(bool);
        DecodeResult result = TupleFloatingUtil.decode(bytes, 0, 1);
        assertEquals(bool, (Boolean) result.o);

        bool = new Boolean(false);
        bytes = TupleFloatingUtil.encode(bool);
        result = TupleFloatingUtil.decode(bytes, 0, 1);
View Full Code Here

    }

    static DecodeResult decodeFloat(byte[] bytes, int start) {
        int end = start + FLOAT_LEN;
        bytes = floatingPointCoding(Arrays.copyOfRange(bytes, start, start + FLOAT_LEN), false);
        return new DecodeResult(end, byteArrayToFloat(bytes));
    }
View Full Code Here

    static DecodeResult decodeUUID(byte[] bytes, int start) {
            ByteBuffer bb = ByteBuffer.wrap(bytes, start, UUID_LEN).order(ByteOrder.BIG_ENDIAN);
            long msb = bb.getLong();
            long lsb = bb.getLong();
            return new DecodeResult(start + UUID_LEN, new UUID(msb, lsb));
        }   
View Full Code Here

        }   
   
    static DecodeResult decodeDouble(byte[] bytes, int start) {
        int end = start + DOUBLE_LEN;
        bytes = floatingPointCoding(Arrays.copyOfRange(bytes, start, end), false);
        return new DecodeResult(end, byteArrayToDouble(bytes));
    }
View Full Code Here

    }

    static DecodeResult decodeBigInt(byte[] bytes, int start) {
        int length = Math.abs(decodeIntNoTypeCode(Arrays.copyOfRange(bytes, start, start + INT_LEN)));
        BigInteger bigInt = decodeBigIntNoTypeCode(Arrays.copyOfRange(bytes, start + INT_LEN, start + INT_LEN + length));
        return new DecodeResult(start + INT_LEN + length, bigInt);
    }
View Full Code Here

    static DecodeResult decodeBigDecimal(byte[] bytes, int start) {
        int scale = decodeIntNoTypeCode(Arrays.copyOfRange(bytes, start, start + INT_LEN));
        int length = Math.abs(decodeIntNoTypeCode(Arrays.copyOfRange(bytes, start + INT_LEN, start + INT_LEN * 2)));
        BigInteger bigInt = decodeBigIntNoTypeCode(Arrays.copyOfRange(bytes, start + INT_LEN * 2, start + INT_LEN * 2 + length));
        return new DecodeResult(start + INT_LEN * 2 + length, new BigDecimal(bigInt, scale));
    }
View Full Code Here

TOP

Related Classes of com.foundationdb.tuple.TupleUtil.DecodeResult

Copyright © 2018 www.massapicom. 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.