use of org.apache.ignite.table.Tuple in project ignite-3 by apache.
the class ClientKeyValueViewTest method testMissingValueColumnsAreSkipped.
@Test
public void testMissingValueColumnsAreSkipped() {
Table table = fullTable();
KeyValueView<Tuple, Tuple> kvView = table.keyValueView();
KeyValueView<IncompletePojo, IncompletePojo> pojoView = table.keyValueView(IncompletePojo.class, 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(0, val.gid);
assertNull(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 ClientKeyValueViewTest method testNullableColumnWithDefaultValueSetNullReturnsNull.
@Test
public void testNullableColumnWithDefaultValueSetNullReturnsNull() {
Table table = tableWithDefaultValues();
RecordView<Tuple> recordView = table.recordView();
KeyValueView<Integer, DefaultValuesPojo> pojoView = table.keyValueView(Integer.class, DefaultValuesPojo.class);
var pojo = new DefaultValuesPojo();
pojo.str = null;
pojo.strNonNull = "s";
pojoView.put(null, 1, pojo);
var res = recordView.get(null, tupleKey(1));
assertNull(res.stringValue("str"));
}
use of org.apache.ignite.table.Tuple in project ignite-3 by apache.
the class ClientRecordViewTest method testNullablePrimitiveFields.
@Test
public void testNullablePrimitiveFields() {
RecordView<IncompletePojoNullable> pojoView = fullTable().recordView(IncompletePojoNullable.class);
RecordView<Tuple> tupleView = fullTable().recordView();
var rec = new IncompletePojoNullable();
rec.id = "1";
rec.gid = 1;
pojoView.upsert(null, rec);
IncompletePojoNullable res = pojoView.get(null, rec);
Tuple binRes = tupleView.get(null, Tuple.create().set("id", "1").set("gid", 1L));
assertNotNull(res);
assertNotNull(binRes);
assertNull(res.zbyte);
assertNull(res.zshort);
assertNull(res.zint);
assertNull(res.zlong);
assertNull(res.zfloat);
assertNull(res.zdouble);
for (int i = 0; i < binRes.columnCount(); i++) {
if (binRes.columnName(i).endsWith("ID")) {
continue;
}
assertNull(binRes.value(i));
}
}
use of org.apache.ignite.table.Tuple 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.Tuple 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"));
}
Aggregations