在数据库中存储BitSet数组的最佳方法? [英] Best way to store an array of BitSet in database?
问题描述
我有一个数组 java.util.BitSet
,我想坚持在我的数据库,但我不知道什么是最好的方法做。
为了我想要存储的每个条目,我得到 x * y true或false
值。我要 java.util.BitSet
是一个很好的调用尝试,但我真的不知道如何可以将其存储在数据库。
我使用MySQL数据库与hibernate(带注释)。
这是我如何初始化我的地图:
Bitset [] map = new BitSet [x];
for(int i = 0; i map [i] = new BitSet(y);
}
更新: b
在这个数据集中没有关系,问题是我有大量的这些二维数组,一个大小约为360 * 180。
我也试图使它的图像,一个单色的pbm文件是很容易做到的。但是仍然数据不在数据库中,每次处理保存的图像文件是太夸张,我想和缓慢。
如果你有两列,并假设每一列都是32位,你可以把数据库中的列(或任何等价的)在
行1 col 1 32位,然后行1 col 2下32个,然后你去
行2 col 1和开始,等等。
这些位之间有什么关系,你可以利用吗?
或者它只是一个大转储?
注意:我使用这种技术来压缩/压缩数据,所以它可能不是你需要的。 >
EDIT:
我正在考虑存储原始blob并跟踪修改的位将它们存储在单独的实体(新表或更多列)中
您有原始blob,然后是 BitIndex:BitNewValue
的映射。
更适当的框架现在是地图缩小。
但是我可以看到,如果管理这样的东西,如果更改了很多位,会变得很头痛。
I got an array of java.util.BitSet
that i want to persist in my database, but i don't know whats the best way to do it.
To be precise i got x*y true or false
value for every entry that i want to store. I tought java.util.BitSet
is a good call to try, but i dont really know how could i store it in database.
I'm using MySQL database with hibernate(with annotation).
This is how i initialize my map:
Bitset[] map = new BitSet[x];
for (int i = 0; i < x; i++) {
map[i] = new BitSet(y);
}
Update:
There is no relation in this dataset, and the problem is that i have tons of these "2 dimensional arrays" and one piece is around 360*180 in size.
I also tried to make an image out of it, a monochrome pbm file is easy to make. But still the data is not in the database and every time processing the saved "image" file is overkill i think and kinda slow.
you could have column of ints (or whatever the equivalent is)in your database.
If you have 2 columns and assuming each column is 32 bits, you can put in row 1 col 1 32 bits, then row 1 col 2 the next 32, then you go to row 2 col 1 and start over and so on.
Is there any relationship between these bits that you can exploit? Or it's just a big dump?
Note: I used this technique to pack/compress data so it might not be exactly what you need.
EDIT:
I'm thinking of storing the raw blob and tracking the modified bits by storing them in a separate entity (new table or more columns)
You have the raw blob, then a mapping of BitIndex:BitNewValue
.
A more appropriate framework for this is now map reduce.
But I can see how managing something like this can become a huge headache if many bits are changed.
这篇关于在数据库中存储BitSet数组的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!