2

存储大对象的最佳方法是什么?就我而言,它类似于树或链表。

我尝试了以下方法:

1)关系数据库

不适合树结构。

2) 文档数据库

我尝试了 RavenDB,但是当我调用 SaveChanges 方法时它引发了 System.OutOfMemory 异常

3) .Net 序列化

它工作得很慢

4) Protobuf

它不能反序列List<List<>>化类型,我不确定链接结构。

所以...?

4

4 回答 4

3

您提到了 protobuf - 我经常将 protobuf-net 与数百兆字节大小的对象一起使用,但是:它确实需要适当地编写为 DTO,理想情况下是树(不是双向图,尽管支持这种用法在某些情况下)。

对于双向链表,这可能意味着:将“先前”链接标记为序列化,然后在反序列化后回调中进行修复,以正确设置“先前”链接。平时很容易。

您是正确的,因为它当前不支持嵌套列表。通过使用具有列表的东西的列表,这通常是微不足道的,但我很想把它隐式化——即库应该能够在不需要更改模型的情况下模拟这一点。如果您对我这样做感兴趣,请告诉我。

如果您有想要序列化的模型的具体示例,并希望我提供指导,请告诉我 - 如果您不能在此处发布,那么我的电子邮件在我的个人资料中。完全取决于你。

于 2012-06-09T08:51:01.167 回答
0

您是否尝试过 Json.NET 并将结果存储在文件中?

于 2012-06-09T08:40:11.180 回答
0

选项[2]:NOSQL(文档)数据库

我建议Cassandra


卡桑德拉维基

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,您应该没问题,只需确保限制文件大小,或将大文件分成块。

于 2012-06-09T08:40:29.853 回答
0

CouchDb 在应对此类挑战方面做得非常好。

在 CouchDb 中存储一棵树

在关系数据库中存储树

于 2012-06-09T08:50:02.790 回答