use of org.apache.ignite.internal.schema.BinaryRow in project ignite-3 by apache.
the class RecordMarshallerValidationsTest method truncatedKey.
@ParameterizedTest
@MethodSource("marshallerFactoryProvider")
public void truncatedKey(MarshallerFactory factory) throws MarshallerException {
SchemaDescriptor schema = new SchemaDescriptor(1, new Column[] { new Column("k1".toUpperCase(), INT32, false), new Column("k2".toUpperCase(), INT32, false) }, new Column[] { new Column("v1".toUpperCase(), STRING, false) });
RecordMarshaller<TestK1K2V1> marshallerFull = factory.create(schema, TestK1K2V1.class);
TestK1K2V1 fullRec = new TestK1K2V1(1, 1, "v1");
BinaryRow row = marshallerFull.marshal(fullRec);
Object restoredRec = marshallerFull.unmarshal(new Row(schema, row));
assertTrue(fullRec.getClass().isInstance(restoredRec));
assertThrows(IllegalArgumentException.class, () -> factory.create(schema, TestK2V1.class), "No field found for column k1");
}
use of org.apache.ignite.internal.schema.BinaryRow in project ignite-3 by apache.
the class SchemaRegistryImpl method resolveInternal.
/**
* Resolves a schema for row.
* The method is optimal when the latest schema is already gotten.
*
* @param row Binary row.
* @param curSchema The latest available local schema.
* @return Schema-aware rows.
*/
@Nullable
private Row resolveInternal(BinaryRow row, SchemaDescriptor curSchema) {
if (row == null) {
return null;
}
final SchemaDescriptor rowSchema = schema(row.schemaVersion());
if (curSchema.version() == rowSchema.version()) {
return new Row(rowSchema, row);
}
ColumnMapper mapping = resolveMapping(curSchema, rowSchema);
return new UpgradingRowAdapter(curSchema, rowSchema, row, mapping);
}
Aggregations