/** * Deserialize a byte array into a table schema. * * @param serializedTableSchema Byte array of the table schema [Not null] * @return An table schema for the byte array. */ public static TableSchema deserialize(byte[] serializedTableSchema) { checkNotNull(serializedTableSchema); checkArgument(serializedTableSchema.length > 0); SchemaVersionUtils.processSchemaVersion(serializedTableSchema[0], TableSchemaInfo.VER_CURRENT); return new TableSchema(Util.deserializeAvroObject(serializedTableSchema, reader)); }
/** * Deserialize the provided serialized row buffer to a new {@link Row} instance * * @param serializedRow byte buffer containing serialized Row * @return new Row instance from serializedRow */ public static Row deserialize(byte[] serializedRow) { checkNotNull(serializedRow); checkArgument(serializedRow.length > 0); SchemaVersionUtils.processSchemaVersion(serializedRow[0], RowSchemaInfo.VER_CURRENT); return new Row(Util.deserializeAvroObject(serializedRow, reader)); }
@Test(expected = UnknownSchemaVersionException.class) public void testProcessSchemaVersionUnsupportedVersion() { SchemaVersionUtils.processSchemaVersion((byte)0x02, 0); }
@Test(expected = IllegalArgumentException.class) public void testProcessSchemaVersionNegativeSupportedVersion() { SchemaVersionUtils.processSchemaVersion((byte)0x00, -1); }
@Test public void testProcessSchemaVersionSupportedVersion() { assertTrue(SchemaVersionUtils.processSchemaVersion((byte)0x7E, 63)); }