寻找对数据存储在本地磁盘的想法 [英] Looking for ideas on storage of data on local disk

查看:105
本文介绍了寻找对数据存储在本地磁盘的想法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大量存储在XML文件中的数据,173 MB(460万行),我已经保存在我的Windows窗体应用程序的工作目录。这是写一个数据表到一个XML文件中的结果。是的渊源人口从查询到SQL Server的数据表。

这是我把它存储在本地,而不是从服务器请求它的原因是,该数据请求40秒,有时向上了超时,数据是静态的,永远不会改变,而且用户可以脱机,仍然使用数据。

加载文件回的数据表中需要20-30秒。我不太woried了时间,它采取了从磁盘加载,因为我让用户知道数据被加载和耐心。不过我不喜欢的XML文件格式,我找其他的想法进行磁盘存储。

数据表仅供崩作为中间人的集合对象的最终人口。如果你有sugestions我想听到他们的声音。

我希望能远离数据库解决方案,并倾向于二进制文件的方法。下面是我的第一次尝试,但我得到一个内存溢出异常:

 字节[] B = NULL;

使用(MemoryStream的流=新的MemoryStream())
{
   BinaryFormatter的bformatter =新的BinaryFormatter();
   bformatter.Serialize(流timeData);
   B = stream.ToArray();
}

使用(的FileStream FILESTREAM =新
   的FileStream(brad.bin,FileMode.Create,FileAccess.Write))
{
   fileStream.Write(B,0,b.length个);
}
 

解决方案

我想看看一个紧凑的(本地)数据库,如的 SQL Server CE的 SQLite的。数据库设计的正是这一点。

I have a large amount of data stored in an XML file, 173 MB (4.6 million lines), that I have stored in my Windows Forms application's working directory. It is the result of writing a datatable to an XML file. The datatable was originaly populated from a query to a SQL server.

The reason that I have it stored locally rather than requesting it from the server is that the data request took upwards of 40 seconds and at times timed out and the data is static and will never change, moreover the user can be offline and still use the data.

Loading the file back into the data table takes 20-30 seconds. I am not too woried about the time that it took to load from disk as I let the user know that data is loading and to be patient. However I don't like the XML file format and I am looking for other ideas for disk storage.

The data table is only beng used as a middleman for the eventual population of a collection object. If you have sugestions I would like to hear them.

I am hoping to stay away from a database solution and lean towards a binary file approach. Below is my first attempt, but I get an out of memory exception:

byte[] b = null;

using (MemoryStream stream = new MemoryStream())
{
   BinaryFormatter bformatter = new BinaryFormatter();
   bformatter.Serialize(stream, timeData);
   b = stream.ToArray();
}

using (FileStream fileStream = new
   FileStream("brad.bin", FileMode.Create, FileAccess.Write))
{
   fileStream.Write(b, 0, b.Length);
}

解决方案

I'd look at a compact (local) database such as SQL Server CE or SQLite. Databases are designed for exactly this.

这篇关于寻找对数据存储在本地磁盘的想法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆