Storing arrays in derby database
I have a 2d array with 24 columns and about 800 rows. Each column consist of values either 0 or 1. I woul开发者_运维技巧d like to store this array in derby database. I used the XMLEncoder and XMLDecoder but when deserializing 5 arrays it takes about 5 seconds which is way too long. Any other method to store it in the database? I am using JAVA.
Don't use XML for such huge data structures. Since all values are numbers, you can either use CSV (0,1,1,0,...
) or some other, more compact String representation.
If the data is guaranteed to be always 0 and 1, you can also use a bit field. BitSet
is not really useful because there is no String->BitSet converter, so you would have to write that yourself.
If you don't want that, try BigInteger.
That gives you large numbers which you can store in the database.
精彩评论