use of org.apache.ignite.table.Tuple in project ignite-3 by apache.
the class ClientKeyValueViewTest method testPrimitivePutBinaryGet.
@Test
public void testPrimitivePutBinaryGet() {
Table table = defaultTable();
KeyValueView<Long, String> primitiveView = table.keyValueView(Mapper.of(Long.class), Mapper.of(String.class));
primitiveView.put(null, DEFAULT_ID, DEFAULT_NAME);
Tuple tuple = table.recordView().get(null, tupleKey(DEFAULT_ID));
assertEquals(DEFAULT_NAME, tuple.stringValue(1));
}
use of org.apache.ignite.table.Tuple in project ignite-3 by apache.
the class ClientKeyValueViewTest method testAllColumnsPojoPutBinaryGet.
@Test
public void testAllColumnsPojoPutBinaryGet() {
Table table = fullTable();
KeyValueView<AllColumnsPojo, AllColumnsPojo> pojoView = table.keyValueView(Mapper.of(AllColumnsPojo.class), Mapper.of(AllColumnsPojo.class));
var val = new AllColumnsPojo();
val.gid = 111;
val.id = "112";
val.zbyte = 113;
val.zshort = 114;
val.zint = 115;
val.zlong = 116;
val.zfloat = 1.17f;
val.zdouble = 1.18;
val.zdate = localDate;
val.ztime = localTime;
val.ztimestamp = instant;
val.zstring = "119";
val.zbytes = new byte[] { 120 };
val.zbitmask = BitSet.valueOf(new byte[] { 121 });
val.zdecimal = BigDecimal.valueOf(122);
val.znumber = BigInteger.valueOf(123);
val.zuuid = uuid;
pojoView.put(null, val, val);
Tuple res = table.recordView().get(null, Tuple.create().set("id", "112").set("gid", 111));
assertNotNull(res);
assertEquals(111, res.intValue("gid"));
assertEquals("112", res.stringValue("id"));
assertEquals(113, res.byteValue("zbyte"));
assertEquals(114, res.shortValue("zshort"));
assertEquals(115, res.intValue("zint"));
assertEquals(116, res.longValue("zlong"));
assertEquals(1.17f, res.floatValue("zfloat"));
assertEquals(1.18, res.doubleValue("zdouble"));
assertEquals(localDate, res.dateValue("zdate"));
assertEquals(localTime.withNano(truncateNanosToMicros(localTime.getNano())), res.timeValue("ztime"));
assertEquals(instant.with(NANO_OF_SECOND, truncateNanosToMicros(instant.getNano())), res.timestampValue("ztimestamp"));
assertEquals("119", res.stringValue("zstring"));
assertEquals(120, ((byte[]) res.value("zbytes"))[0]);
assertEquals(BitSet.valueOf(new byte[] { 121 }), res.bitmaskValue("zbitmask"));
assertEquals(122, ((Number) res.value("zdecimal")).longValue());
assertEquals(BigInteger.valueOf(123), res.value("znumber"));
assertEquals(uuid, res.uuidValue("zuuid"));
}
use of org.apache.ignite.table.Tuple in project ignite-3 by apache.
the class ClientRecordViewTest method testPrimitivePutBinaryGet.
@Test
public void testPrimitivePutBinaryGet() {
Table table = oneColumnTable();
RecordView<String> primitiveView = table.recordView(Mapper.of(String.class));
primitiveView.upsert(null, "abc");
Tuple tuple = table.recordView().get(null, oneColumnTableKey("abc"));
assertEquals("abc", tuple.stringValue(0));
}
use of org.apache.ignite.table.Tuple in project ignite-3 by apache.
the class ClientRecordViewTest method testMissingValueColumnsAreSkipped.
@Test
public void testMissingValueColumnsAreSkipped() {
Table table = fullTable();
KeyValueView<Tuple, Tuple> kvView = table.keyValueView();
RecordView<IncompletePojo> pojoView = table.recordView(IncompletePojo.class);
kvView.put(null, allClumnsTableKey(1), allColumnsTableVal("x"));
var key = new IncompletePojo();
key.id = "1";
key.gid = 1;
// This POJO does not have fields for all table columns, and this is ok.
IncompletePojo val = pojoView.get(null, key);
assertEquals(1, val.gid);
assertEquals("1", val.id);
assertEquals("x", val.zstring);
assertEquals(2, val.zbytes[1]);
assertEquals(11, val.zbyte);
}
use of org.apache.ignite.table.Tuple in project ignite-3 by apache.
the class ClientRecordViewTest method testAllColumnsPojoPutBinaryGet.
@Test
public void testAllColumnsPojoPutBinaryGet() {
Table table = fullTable();
RecordView<AllColumnsPojo> pojoView = table.recordView(Mapper.of(AllColumnsPojo.class));
var val = new AllColumnsPojo();
val.gid = 111;
val.id = "112";
val.zbyte = 113;
val.zshort = 114;
val.zint = 115;
val.zlong = 116;
val.zfloat = 1.17f;
val.zdouble = 1.18;
val.zdate = localDate;
val.ztime = localTime;
val.ztimestamp = instant;
val.zstring = "119";
val.zbytes = new byte[] { 120 };
val.zbitmask = BitSet.valueOf(new byte[] { 121 });
val.zdecimal = BigDecimal.valueOf(122);
val.znumber = BigInteger.valueOf(123);
val.zuuid = uuid;
pojoView.upsert(null, val);
Tuple res = table.recordView().get(null, Tuple.create().set("id", "112").set("gid", 111));
assertNotNull(res);
assertEquals(111, res.intValue("gid"));
assertEquals("112", res.stringValue("id"));
assertEquals(113, res.byteValue("zbyte"));
assertEquals(114, res.shortValue("zshort"));
assertEquals(115, res.intValue("zint"));
assertEquals(116, res.longValue("zlong"));
assertEquals(1.17f, res.floatValue("zfloat"));
assertEquals(1.18, res.doubleValue("zdouble"));
assertEquals(localDate, res.dateValue("zdate"));
assertEquals(localTime.withNano(truncateNanosToMicros(localTime.getNano())), res.timeValue("ztime"));
assertEquals(instant.with(NANO_OF_SECOND, truncateNanosToMicros(instant.getNano())), res.timestampValue("ztimestamp"));
assertEquals("119", res.stringValue("zstring"));
assertEquals(120, ((byte[]) res.value("zbytes"))[0]);
assertEquals(BitSet.valueOf(new byte[] { 121 }), res.bitmaskValue("zbitmask"));
assertEquals(122, ((Number) res.value("zdecimal")).longValue());
assertEquals(BigInteger.valueOf(123), res.value("znumber"));
assertEquals(uuid, res.uuidValue("zuuid"));
}
Aggregations