Search in sources :

Example 61 with Tuple

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);
}
Also used : Table(org.apache.ignite.table.Table) Tuple(org.apache.ignite.table.Tuple) Test(org.junit.jupiter.api.Test)

Example 62 with Tuple

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"));
}
Also used : BigInteger(java.math.BigInteger) Table(org.apache.ignite.table.Table) Tuple(org.apache.ignite.table.Tuple) Test(org.junit.jupiter.api.Test)

Example 63 with Tuple

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));
    }
}
Also used : Tuple(org.apache.ignite.table.Tuple) Test(org.junit.jupiter.api.Test)

Example 64 with Tuple

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"));
}
Also used : Table(org.apache.ignite.table.Table) Tuple(org.apache.ignite.table.Tuple) Test(org.junit.jupiter.api.Test)

Example 65 with Tuple

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"));
}
Also used : Table(org.apache.ignite.table.Table) Tuple(org.apache.ignite.table.Tuple) Test(org.junit.jupiter.api.Test)

Aggregations

Tuple (org.apache.ignite.table.Tuple)130 Test (org.junit.jupiter.api.Test)101 SchemaDescriptor (org.apache.ignite.internal.schema.SchemaDescriptor)33 Table (org.apache.ignite.table.Table)27 Column (org.apache.ignite.internal.schema.Column)25 Row (org.apache.ignite.internal.schema.row.Row)21 IgniteAbstractTest (org.apache.ignite.internal.testframework.IgniteAbstractTest)19 Ignite (org.apache.ignite.Ignite)17 TupleMarshaller (org.apache.ignite.internal.schema.marshaller.TupleMarshaller)17 TupleMarshallerImpl (org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl)17 DummySchemaManagerImpl (org.apache.ignite.internal.table.impl.DummySchemaManagerImpl)17 InternalTransaction (org.apache.ignite.internal.tx.InternalTransaction)15 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 ByteBufferRow (org.apache.ignite.internal.schema.ByteBufferRow)10 TableDefinition (org.apache.ignite.schema.definition.TableDefinition)9 ArrayList (java.util.ArrayList)8 Disabled (org.junit.jupiter.api.Disabled)7 MethodSource (org.junit.jupiter.params.provider.MethodSource)7 BigDecimal (java.math.BigDecimal)6 Transaction (org.apache.ignite.tx.Transaction)6