存储大对象的最佳方式是什么?在我的例子中,它类似于树或链表。
我尝试了以下几种方法:
1)关系数据库
对于树结构是不好的。
2)文档数据库
我尝试了RavenDB,但当我调用SaveChanges方法时,它引发了System.OutOfMemory异常
3) .Net序列化
它的运行速度非常慢
4) Protobuf
它不能反序列化List<List<>>类型,并且我不确定链接结构。
所以...?
发布于 2012-06-09 16:51:01
你提到过protobuf -我通常使用的protobuf-net的对象大小有几百兆字节,但是:它确实需要适当地写成DTO,理想情况下写成树(不是双向图,尽管在某些情况下支持这种用法)。
在双链表的情况下,这可能意味着:将“前一个”链接标记为而不是序列化,然后在反序列化后的回调中进行修复,以正确设置“前一个”链接。通常情况下很容易。
你是对的,因为它目前不支持嵌套列表。通过使用一个有列表的东西的列表,这通常是微不足道的,但我想把它隐含起来--也就是说,库应该能够模拟这一点,而不需要你改变你的模型。如果你对我这样做感兴趣,请让我知道。
如果你有一个想要连载的模型的具体例子,并希望我提供指导,请让我知道-如果你不能在这里张贴,那么我的电子邮件在我的个人资料中。完全由你决定。
发布于 2012-06-09 16:40:11
您是否尝试过Json.NET并将结果存储在文件中?
发布于 2012-06-09 16:40:30
选项2: NOSQL (文档)数据库
我建议使用Cassandra。
从cassandra wiki,
Cassandra's public API is based on Thrift, which offers no streaming abilities
any value written or fetched has to fit in memory. This is inherent to Thrift's
design and is therefore unlikely to change. So adding large object support to
Cassandra would need a special API that manually split the large objects up
into pieces. A potential approach is described in http://issues.apache.org/jira/browse/CASSANDRA-265.
As a workaround in the meantime, you can manually split files into chunks of whatever
size you are comfortable with -- at least one person is using 64MB -- and making a file correspond
to a row, with the chunks as column values.因此,如果你的文件小于10MB,你应该没问题,只要确保限制文件大小,或者将大文件分成块。
https://stackoverflow.com/questions/10959530
复制相似问题