use of org.apache.ignite.table.Table in project ignite-3 by apache.
the class ClientRecordViewTest method testBinaryPutPrimitiveGet.
@Test
public void testBinaryPutPrimitiveGet() {
Table table = defaultTable();
RecordView<Long> primitiveView = table.recordView(Mapper.of(Long.class));
table.recordView().upsert(null, tuple());
Long val = primitiveView.get(null, DEFAULT_ID);
Long missingVal = primitiveView.get(null, -1L);
assertEquals(DEFAULT_ID, val);
assertNull(missingVal);
}
use of org.apache.ignite.table.Table in project ignite-3 by apache.
the class ClientRecordViewTest method testGetAllPrimitive.
@Test
public void testGetAllPrimitive() {
Table table = oneColumnTable();
RecordView<String> primitiveView = table.recordView(Mapper.of(String.class));
primitiveView.upsertAll(null, List.of("a", "c"));
String[] res = primitiveView.getAll(null, List.of("a", "b", "c")).toArray(new String[0]);
assertEquals("a", res[0]);
assertEquals("c", res[1]);
}
use of org.apache.ignite.table.Table in project ignite-3 by apache.
the class ClientRecordViewTest method testColumnWithDefaultValueNotSetReturnsDefault.
@Test
public void testColumnWithDefaultValueNotSetReturnsDefault() {
Table table = tableWithDefaultValues();
RecordView<Tuple> recordView = table.recordView();
RecordView<PersonPojo> pojoView = table.recordView(PersonPojo.class);
pojoView.upsert(null, new PersonPojo());
var res = recordView.get(null, tupleKey(0));
assertEquals("def_str", res.stringValue("str"));
assertEquals("def_str2", res.stringValue("strNonNull"));
}
use of org.apache.ignite.table.Table in project ignite-3 by apache.
the class ClientRecordViewTest method testNullableColumnWithDefaultValueSetNullReturnsNull.
@Test
public void testNullableColumnWithDefaultValueSetNullReturnsNull() {
Table table = tableWithDefaultValues();
RecordView<Tuple> recordView = table.recordView();
RecordView<DefaultValuesPojo> pojoView = table.recordView(DefaultValuesPojo.class);
var pojo = new DefaultValuesPojo();
pojo.id = 1;
pojo.str = null;
pojo.strNonNull = "s";
pojoView.upsert(null, pojo);
var res = recordView.get(null, tupleKey(1));
assertNull(res.stringValue("str"));
}
use of org.apache.ignite.table.Table in project ignite-3 by apache.
the class ClientRecordViewTest method testAllColumnsBinaryPutPojoGet.
@Test
public void testAllColumnsBinaryPutPojoGet() {
Table table = fullTable();
RecordView<AllColumnsPojo> pojoView = table.recordView(Mapper.of(AllColumnsPojo.class));
table.recordView().upsert(null, allColumnsTableVal("foo"));
var key = new AllColumnsPojo();
key.gid = (int) (long) DEFAULT_ID;
key.id = String.valueOf(DEFAULT_ID);
AllColumnsPojo res = pojoView.get(null, key);
assertEquals(11, res.zbyte);
assertEquals(12, res.zshort);
assertEquals(13, res.zint);
assertEquals(14, res.zlong);
assertEquals(1.5f, res.zfloat);
assertEquals(1.6, res.zdouble);
assertEquals(localDate, res.zdate);
assertEquals(localTime.withNano(truncateNanosToMicros(localTime.getNano())), res.ztime);
assertEquals(instant.with(NANO_OF_SECOND, truncateNanosToMicros(instant.getNano())), res.ztimestamp);
assertEquals("foo", res.zstring);
assertArrayEquals(new byte[] { 1, 2 }, res.zbytes);
assertEquals(BitSet.valueOf(new byte[] { 32 }), res.zbitmask);
assertEquals(21, res.zdecimal.longValue());
assertEquals(22, res.znumber.longValue());
assertEquals(uuid, res.zuuid);
}
Aggregations