Search in sources :

Example 31 with RowAssembler

use of org.apache.ignite.internal.schema.row.RowAssembler in project ignite-3 by apache.

the class RowAssemblerSimpleSchemaTest method varlenKeyVarlenNullableValue.

/**
 * Validate row layout for schema of var-len non-null key and var-len nullable value.
 */
@Test
public void varlenKeyVarlenNullableValue() {
    SchemaDescriptor schema = new SchemaDescriptor(42, new Column[] { new Column("keyStrCol", STRING, false) }, new Column[] { new Column("valBytesCol", BYTES, true) });
    System.out.println(Integer.toHexString(((byte) -116) & 0xFF));
    System.out.println(Integer.toHexString(((byte) -99) & 0xFF));
    assertRowBytesEquals(new byte[] { 42, 0, 64, -119, 105, 64, 8, 0, 0, 0, 0, 107, 101, 121, 10, 0, 0, 0, 0, 0, -1, 1, 0, 120 }, new RowAssembler(schema, 1, 1).appendString("key").appendBytes(new byte[] { -1, 1, 0, 120 }).toBytes());
    // Null value.
    assertRowBytesEquals(new byte[] { 42, 0, 64, -119, 105, 64, 8, 0, 0, 0, 0, 107, 101, 121, 6, 0, 0, 0, 0, 1 }, new RowAssembler(schema, 1, 0).appendString("key").appendNull().toBytes());
    // No value.
    assertRowBytesEquals(new byte[] { 0, 0, 64, -119, 105, 64, 8, 0, 0, 0, 0, 107, 101, 121 }, new RowAssembler(schema, 1, 0).appendString("key").toBytes());
}
Also used : RowAssembler(org.apache.ignite.internal.schema.row.RowAssembler) Test(org.junit.jupiter.api.Test)

Example 32 with RowAssembler

use of org.apache.ignite.internal.schema.row.RowAssembler in project ignite-3 by apache.

the class RowAssemblerSimpleSchemaTest method fixedKeyFixedValue.

/**
 * Validate row layout for schema of fix-len non-null key and fix-len non-null value.
 */
@Test
public void fixedKeyFixedValue() {
    SchemaDescriptor schema = new SchemaDescriptor(42, new Column[] { new Column("keyShortCol", INT16, false) }, new Column[] { new Column("valShortCol", INT16, false) });
    // With value.
    assertRowBytesEquals(new byte[] { 42, 0, -45, 61, -70, -41, 7, 0, 0, 0, 0, 33, 0, 7, 0, 0, 0, 0, -71, -1 }, new RowAssembler(schema, 0, 0).appendShort((short) 33).appendShort((short) -71).toBytes());
    // No value.
    assertRowBytesEquals(new byte[] { 0, 0, -45, 61, -70, -41, 7, 0, 0, 0, 0, 33, 0 }, new RowAssembler(schema, 0, 0).appendShort((short) 33).toBytes());
}
Also used : RowAssembler(org.apache.ignite.internal.schema.row.RowAssembler) Test(org.junit.jupiter.api.Test)

Example 33 with RowAssembler

use of org.apache.ignite.internal.schema.row.RowAssembler in project ignite-3 by apache.

the class RowAssemblerSimpleSchemaTest method fixedKeyVarlenValue.

/**
 * Validate row layout for schema of fix-len non-null key and var-len non-null value.
 */
@Test
public void fixedKeyVarlenValue() {
    SchemaDescriptor schema = new SchemaDescriptor(42, new Column[] { new Column("keyShortCol", INT16, false) }, new Column[] { new Column("valStrCol", STRING, false) });
    assertRowBytesEquals(new byte[] { 42, 0, -23, -36, 114, 80, 7, 0, 0, 0, 0, -33, -1, 8, 0, 0, 0, 0, 118, 97, 108 }, new RowAssembler(schema, 0, 1).appendShort((short) -33).appendString("val").toBytes());
    // No value.
    assertRowBytesEquals(new byte[] { 0, 0, -45, 61, -70, -41, 7, 0, 0, 0, 0, 33, 0 }, new RowAssembler(schema, 0, 0).appendShort((short) 33).toBytes());
}
Also used : RowAssembler(org.apache.ignite.internal.schema.row.RowAssembler) Test(org.junit.jupiter.api.Test)

Example 34 with RowAssembler

use of org.apache.ignite.internal.schema.row.RowAssembler in project ignite-3 by apache.

the class RowAssemblerSimpleSchemaTest method varlenKeyFixedNullableValue.

/**
 * Validate row layout for schema of var-len non-null key and fix-len nullable value.
 */
@Test
public void varlenKeyFixedNullableValue() {
    SchemaDescriptor schema = new SchemaDescriptor(42, new Column[] { new Column("keyStrCol", STRING, false) }, new Column[] { new Column("valUuidCol", UUID, true) });
    assertRowBytesEquals(new byte[] { 42, 0, 64, -119, 105, 64, 8, 0, 0, 0, 0, 107, 101, 121, 22, 0, 0, 0, 0, 0, -117, -61, -31, 85, 61, -32, 57, 68, 111, 67, 56, -3, -99, -37, -58, -73 }, new RowAssembler(schema, 1, 0).appendString("key").appendUuid(uuidVal).toBytes());
    // Null value.
    assertRowBytesEquals(new byte[] { 42, 0, 64, -119, 105, 64, 8, 0, 0, 0, 0, 107, 101, 121, 6, 0, 0, 0, 0, 1 }, new RowAssembler(schema, 1, 0).appendString("key").appendNull().toBytes());
    // No value.
    assertRowBytesEquals(new byte[] { 0, 0, 64, -119, 105, 64, 8, 0, 0, 0, 0, 107, 101, 121 }, new RowAssembler(schema, 1, 0).appendString("key").toBytes());
}
Also used : RowAssembler(org.apache.ignite.internal.schema.row.RowAssembler) Test(org.junit.jupiter.api.Test)

Aggregations

RowAssembler (org.apache.ignite.internal.schema.row.RowAssembler)34 Test (org.junit.jupiter.api.Test)16 Row (org.apache.ignite.internal.schema.row.Row)13 Column (org.apache.ignite.internal.schema.Column)10 ByteBufferRow (org.apache.ignite.internal.schema.ByteBufferRow)6 BinaryRow (org.apache.ignite.internal.schema.BinaryRow)5 TestSimpleObject (org.apache.ignite.internal.schema.testobjects.TestSimpleObject)4 BigInteger (java.math.BigInteger)3 RelReferentialConstraint (org.apache.calcite.rel.RelReferentialConstraint)3 SchemaDescriptor (org.apache.ignite.internal.schema.SchemaDescriptor)3 NotNull (org.jetbrains.annotations.NotNull)3 Columns (org.apache.ignite.internal.schema.Columns)2 Object2IntOpenHashMap (it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap)1 ManagementFactory (java.lang.management.ManagementFactory)1 ThreadInfo (java.lang.management.ThreadInfo)1 ThreadMXBean (java.lang.management.ThreadMXBean)1 BigDecimal (java.math.BigDecimal)1 Instant (java.time.Instant)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1