I am using MySqlLoader to load a large number of rows into a table and the performance is awesome, but it does not seem to handle binary data properly.
I followed the example from the documentation.
Some pseudo code to illustrate:
Var loader = new MySqlLoader(...);
Loader.CreateColumns();
Loader.Open();
Foreach (var item in distinctItems)
{
loader.SetValue(“Size”, item.Size); // item.Size is a long
loader.SetValue(“Data”, item.Data); // item.Data is a byte[16]
loader.NextRow();
}
loader.Close();
What I observe:
1. Item.Data is truncated to 13 bytes on the first loop, most likely because it is not properly escaped. But I don’t see a way to escape it.
2. On the next loop the “Data” column is not updated so it properly inserts rows with new “Size” values but all the “Data” values matches the first row value
I tried representing item.Data as “X’[hex representation of item.Data]’” but that complained about the string being too long.
Any ideas would be appreciated.
Thank you
MySqlLoader and binary data
Re: MySqlLoader and binary data
More information. So it is not actually truncating the binary data. It is storing the string ‘System.byte[]’ as bytes. I assume it is just doing a item.Data.ToString() type conversion.
Re: MySqlLoader and binary data
Specify the datatype of your Data column.
If it is BINARY or VARBINARY, try using MySqlBinaryString:
Does this help?
If it is BINARY or VARBINARY, try using MySqlBinaryString:
Code: Select all
loader.SetValue("Data", new MySqlBinaryString(item.Data));
Re: MySqlLoader and binary data
Thank you, it did work.