mysql bitset,在数据库中存储BitSet数组的最佳方法?

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值