fury icon indicating copy to clipboard operation
fury copied to clipboard

[Question] Constructing a BinaryRow from serialized bytes

Open MC-2016 opened this issue 1 year ago • 1 comments

Question

I was looking for a way to re-create a BinaryRow object from a previously serialized bytes, but couldn't find it. The row format guide has an example of converting an object into a BinaryRow, which is not quite what I need.

What I am looking for is the following workflow:

  • Serialize my object into a byte array
  • Store the byte array... somewhere
  • Retrieve the byte array later on
  • Construct a BinaryRow from the byte array
  • Access parts of the original objects via the BinaryRow as shown in the guide without necessarily reconstructing the entire object

Any chance someone can tell me how to do that? An update to the guide would be awesome, too.

MC-2016 avatar Dec 09 '24 05:12 MC-2016

Hi @MC-2016 , to construct a BinaryRow, you can take following code as an example:

byte[] serializedBytes = xxx;
Schema schema = xxx;
BinaryRow newRow = new BinaryRow(schema);
MemoryBuffer buffer = MemoryBuffer.fromByteArray(serializedBytes);
newRow.pointTo(buffer, 0, buffer.size());

chaokunyang avatar Dec 09 '24 15:12 chaokunyang