Search in sources :

Example 1 with TupleSchema

use of com.boundary.tuple.TupleSchema in project SimpleFlatMapper by arnaudroger.

the class FastTupleTest method setUp.

@Before
public void setUp() throws Exception {
    TupleSchema schema = TupleSchema.builder().addField("fieldA", Long.TYPE).addField("fieldB", Integer.TYPE).addField("fieldC", Short.TYPE).heapMemory().build();
    tuple = schema.createTuple();
}
Also used : TupleSchema(com.boundary.tuple.TupleSchema) Before(org.junit.Before)

Example 2 with TupleSchema

use of com.boundary.tuple.TupleSchema in project SimpleFlatMapper by arnaudroger.

the class FastTupleTest method setUp.

@Before
public void setUp() throws Exception {
    TupleSchema schema = TupleSchema.builder().addField("fieldA", Long.TYPE).addField("fieldB", Integer.TYPE).addField("fieldC", Short.TYPE).heapMemory().build();
    tuple = schema.createTuple();
}
Also used : TupleSchema(com.boundary.tuple.TupleSchema) Before(org.junit.Before)

Example 3 with TupleSchema

use of com.boundary.tuple.TupleSchema in project SimpleFlatMapper by arnaudroger.

the class FastTupleTest method testMetaDataOnFastTupleDirectMemory.

@Test
public void testMetaDataOnFastTupleDirectMemory() throws Exception {
    final TupleSchema tupleSchema = TupleSchema.builder().addField("fieldA", Long.TYPE).addField("fieldB", Integer.TYPE).addField("fieldC", Short.TYPE).directMemory().build();
    final FastTuple tuple = tupleSchema.createTuple();
    // creates a new tuple allocated on the JVM heap
    @SuppressWarnings("unchecked") ClassMeta<FastTuple> cm = ReflectionService.newInstance().getClassMeta((Class<FastTuple>) tuple.getClass());
    final PropertyFinder<FastTuple> propertyFinder = cm.newPropertyFinder(ConstantPredicate.<PropertyMeta<?, ?>>truePredicate());
    final PropertyMeta<FastTuple, Long> fieldA = propertyFinder.findProperty(new DefaultPropertyNameMatcher("fieldA", 0, true, true), new Object[0]);
    final PropertyMeta<FastTuple, Integer> fieldB = propertyFinder.findProperty(new DefaultPropertyNameMatcher("fieldB", 0, true, true), new Object[0]);
    final PropertyMeta<FastTuple, Short> fieldC = propertyFinder.findProperty(new DefaultPropertyNameMatcher("fieldC", 0, true, true), new Object[0]);
    final PropertyMeta<FastTuple, ?> fieldD = propertyFinder.findProperty(new DefaultPropertyNameMatcher("fieldD", 0, true, true), new Object[0]);
    assertNotNull(fieldA);
    assertNotNull(fieldB);
    assertNotNull(fieldC);
    assertNull(fieldD);
    fieldA.getSetter().set(tuple, 6l);
    assertEquals(6l, fieldA.getGetter().get(tuple).longValue());
    fieldB.getSetter().set(tuple, 7);
    assertEquals(7, fieldB.getGetter().get(tuple).intValue());
    fieldC.getSetter().set(tuple, (short) 3);
    assertEquals(3, fieldC.getGetter().get(tuple).shortValue());
}
Also used : DefaultPropertyNameMatcher(org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher) TupleSchema(com.boundary.tuple.TupleSchema) FastTuple(com.boundary.tuple.FastTuple) Test(org.junit.Test)

Aggregations

TupleSchema (com.boundary.tuple.TupleSchema)3 Before (org.junit.Before)2 FastTuple (com.boundary.tuple.FastTuple)1 Test (org.junit.Test)1 DefaultPropertyNameMatcher (org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher)1