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());
}
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());
}
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());
}
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());
}
Aggregations