简体   繁体   English

在derby数据库中存储数组

[英]Storing arrays in derby database

I have a 2d array with 24 columns and about 800 rows. 我有一个24列和大约800行的2d数组。 Each column consist of values either 0 or 1. I would like to store this array in derby database. 每列包含0或1的值。我想将此数组存储在derby数据库中。 I used the XMLEncoder and XMLDecoder but when deserializing 5 arrays it takes about 5 seconds which is way too long. 我使用了XMLEncoder和XMLDecoder,但是当反序列化5个数组时,它需要大约5秒,这太长了。 Any other method to store it in the database? 将其存储在数据库中的任何其他方法? I am using JAVA. 我正在使用JAVA。

Don't use XML for such huge data structures. 不要将XML用于如此庞大的数据结构。 Since all values are numbers, you can either use CSV ( 0,1,1,0,... ) or some other, more compact String representation. 由于所有值都是数字,因此您可以使用CSV( 0,1,1,0,... )或其他更紧凑的String表示。

If the data is guaranteed to be always 0 and 1, you can also use a bit field. 如果数据保证始终为0和1,则还可以使用位字段。 BitSet is not really useful because there is no String->BitSet converter, so you would have to write that yourself. BitSet不是很有用,因为没有String-> BitSet转换器,所以你必须自己编写。

If you don't want that, try BigInteger. 如果您不想这样,请尝试BigInteger。

That gives you large numbers which you can store in the database. 这为您提供了可以存储在数据库中的大量数字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM