Package com.boundary.tuple

Examples of com.boundary.tuple.TupleSchema


*/
public class TupleExpressionGeneratorTest {

    @Test
    public void testGetLongOut() throws Exception {
        TupleSchema schema = TupleSchema.builder().
                addField("a", Long.TYPE).
                addField("b", Long.TYPE).
                addField("c", Long.TYPE).
                heapMemory().
                build();

        FastTuple tuple = schema.createTuple();
        tuple.setLong(1, 100L);
        tuple.setLong(2, 600L);
        tuple.setLong(3, 1000L);

        TupleExpressionGenerator.LongTupleExpression eval = TupleExpressionGenerator.builder().expression("tuple.a + tuple.b + tuple.c").schema(schema).returnLong();
View Full Code Here


        assertEquals(1700L, eval.evaluate(tuple));
    }

    @Test
    public void testMultiExpr() throws Exception {
        TupleSchema schema = TupleSchema.builder().
                addField("a", Long.TYPE).
                addField("b", Long.TYPE).
                addField("c", Long.TYPE).
                heapMemory().
                build();

        FastTuple tuple = schema.createTuple();
        TupleExpressionGenerator.TupleExpression eval = TupleExpressionGenerator.builder().expression("tuple.a(100), tuple.b(200), tuple.c(300)").schema(schema).returnVoid();
        eval.evaluate(tuple);
        assertEquals(100L, tuple.getLong(1));
        assertEquals(200, tuple.getLong(2));
        assertEquals(300, tuple.getLong(3));
View Full Code Here

        assertGetterAndSetterGenerated(clazz, "g", double.class);
    }

    @Test
    public void testAccessorsWork() throws Exception {
        TupleSchema schema = TupleSchema.builder().
                addField("a", Long.TYPE).
                addField("b", Integer.TYPE).
                addField("c", Short.TYPE).
                addField("d", Character.TYPE).
                addField("e", Byte.TYPE).
                addField("f", Float.TYPE).
                addField("g", Double.TYPE).
                heapMemory().
                build();
        FastTuple tuple = schema.createTuple();
        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "a", Long.TYPE, 100L);
        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "b", Integer.TYPE, 40);
        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "c", Short.TYPE, (short)10);
        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "d", Character.TYPE, 'j');
        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "e", Byte.TYPE, (byte)255);
        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "f", Float.TYPE, 0.125f);
        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "g", Double.TYPE, 0.125);
    }
View Full Code Here

        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "g", Double.TYPE, 0.125);
    }

    @Test
    public void testIndexedSetAndGet() throws Exception {
        TupleSchema schema = TupleSchema.builder().
                addField("a", Long.TYPE).
                addField("b", Integer.TYPE).
                addField("c", Short.TYPE).
                addField("d", Character.TYPE).
                addField("e", Byte.TYPE).
                addField("f", Float.TYPE).
                addField("g", Double.TYPE).
                heapMemory().
                build();
        FastTuple tuple = schema.createTuple();
        assertIndexedGetterAndSetterRoundTrip(tuple, 1, 100L);
        assertIndexedGetterAndSetterRoundTrip(tuple, 2, 40);
        assertIndexedGetterAndSetterRoundTrip(tuple, 3, (short)10);
        assertIndexedGetterAndSetterRoundTrip(tuple, 4, 'j');
        assertIndexedGetterAndSetterRoundTrip(tuple, 5, (byte)255);
View Full Code Here

        assertIndexedGetterAndSetterRoundTrip(tuple, 7, 0.125);
    }

    @Test
    public void testIndexedTypedSetAndGet() throws Exception {
        TupleSchema schema = TupleSchema.builder().
                addField("a", Long.TYPE).
                addField("b", Integer.TYPE).
                addField("c", Short.TYPE).
                addField("d", Character.TYPE).
                addField("e", Byte.TYPE).
                addField("f", Float.TYPE).
                addField("g", Double.TYPE).
                heapMemory().
                build();
        FastTuple tuple = schema.createTuple();
        assertIndexedTypedGetterAndSetterRoundTrip(tuple, 1, 100L);
        assertIndexedTypedGetterAndSetterRoundTrip(tuple, 2, 40);
        assertIndexedTypedGetterAndSetterRoundTrip(tuple, 3, (short)10);
        assertIndexedTypedGetterAndSetterRoundTrip(tuple, 4, 'j');
        assertIndexedTypedGetterAndSetterRoundTrip(tuple, 5, (byte)255);
View Full Code Here

        assertIndexedTypedGetterAndSetterRoundTrip(tuple, 7, 0.125);
    }

    @Test
    public void testInterfaceIsImplemented() throws Exception {
        TupleSchema schema = TupleSchema.builder().
                addField("a", Long.TYPE).
                implementInterface(StaticBinding.class).
                heapMemory().
                build();
        FastTuple tuple = schema.createTuple();
        assertTrue(tuple instanceof StaticBinding);
    }
View Full Code Here

        assertGetterAndSetterGenerated(clazz, "g", double.class);
    }

    @Test
    public void testAccessorsWork() throws Exception {
        TupleSchema schema = TupleSchema.builder().
                addField("a", Long.TYPE).
                addField("b", Integer.TYPE).
                addField("c", Short.TYPE).
                addField("d", Character.TYPE).
                addField("e", Byte.TYPE).
                addField("f", Float.TYPE).
                addField("g", Double.TYPE).
                directMemory().
                build();
        FastTuple tuple = schema.createTuple();
        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "a", Long.TYPE, 100L);
        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "b", Integer.TYPE, 40);
        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "c", Short.TYPE, (short)10);
        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "d", Character.TYPE, 'j');
        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "e", Byte.TYPE, (byte)255);
        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "f", Float.TYPE, 0.125f);
        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "g", Double.TYPE, 0.125);
    }
View Full Code Here

        assertGetterAndSetterRoundTrip(tuple, schema.tupleClass(), "g", Double.TYPE, 0.125);
    }

    @Test
    public void testIndexedSetAndGet() throws Exception {
        TupleSchema schema = TupleSchema.builder().
                addField("a", Long.TYPE).
                addField("b", Integer.TYPE).
                addField("c", Short.TYPE).
                addField("d", Character.TYPE).
                addField("e", Byte.TYPE).
                addField("f", Float.TYPE).
                addField("g", Double.TYPE).
                directMemory().
                build();
        FastTuple tuple = schema.createTuple();
        assertIndexedGetterAndSetterRoundTrip(tuple, 1, 100L);
        assertIndexedGetterAndSetterRoundTrip(tuple, 2, 40);
        assertIndexedGetterAndSetterRoundTrip(tuple, 3, (short)10);
        assertIndexedGetterAndSetterRoundTrip(tuple, 4, 'j');
        assertIndexedGetterAndSetterRoundTrip(tuple, 5, (byte)255);
View Full Code Here

        assertIndexedGetterAndSetterRoundTrip(tuple, 7, 0.125);
    }

    @Test
    public void testIndexedTypedSetAndGet() throws Exception {
        TupleSchema schema = TupleSchema.builder().
                addField("a", Long.TYPE).
                addField("b", Integer.TYPE).
                addField("c", Short.TYPE).
                addField("d", Character.TYPE).
                addField("e", Byte.TYPE).
                addField("f", Float.TYPE).
                addField("g", Double.TYPE).
                directMemory().
                build();
        FastTuple tuple = schema.createTuple();
        assertIndexedTypedGetterAndSetterRoundTrip(tuple, 1, 100L);
        assertIndexedTypedGetterAndSetterRoundTrip(tuple, 2, 40);
        assertIndexedTypedGetterAndSetterRoundTrip(tuple, 3, (short) 10);
        assertIndexedTypedGetterAndSetterRoundTrip(tuple, 4, 'j');
        assertIndexedTypedGetterAndSetterRoundTrip(tuple, 5, (byte) 255);
View Full Code Here

        assertIndexedTypedGetterAndSetterRoundTrip(tuple, 7, 0.125);
    }

    @Test
    public void testInterfaceIsImplemented() throws Exception {
        TupleSchema schema = TupleSchema.builder().
                addField("a", Long.TYPE).
                implementInterface(StaticBinding.class).
                directMemory().
                build();
        FastTuple tuple = schema.createTuple();
        assertTrue(tuple instanceof StaticBinding);
    }
View Full Code Here

TOP

Related Classes of com.boundary.tuple.TupleSchema

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.