备份我的数据库花费的时间太长
在 Windows Mobile 设备上,我正在开发的软件依赖 sdf 文件作为数据库。 该软件针对的平台“不太理想”,并且每隔一段时间就会进行硬重置。在遥远的过去,我们丢失了数据。现在我们关闭数据库,并将SDF文件复制到SD卡上。如果设备硬重置,我们将恢复应用程序(也在 SD 卡上)和数据库。
我不关心恢复(目前还)。我们现在遇到的问题是,进行“备份”需要花费大量时间,因为 SDF 为 7+ 兆,并且写入 SD 卡的速度很慢很慢。
我的老板建议我们创建文件“块”的哈希值,然后仅当哈希值的比较为 != 时才写入目标文件。
那么问题来了。
如果您只能拥有文件的一份副本,因此无法将其与原始文件进行比较,您将如何测试文件是否已更改。
我只是想进行一些头脑风暴。
On a windows mobile unit, the software I'm working on relies on a sdf file as it's database.
The platform that the software is targeted towards is "less than optimal" and hard resets every once and a while. In the far distant past we lost data. Now we close the database, and copy the SDF file to the SD card. If the unit gets hard reset, we restore the app (also on the sd card) and the database.
I'm not concerned about the restore (just yet). The problem we have now is that doing a "backup" takes a crazy amount of time because the SDF is 7+ megs and writing to the SD card is slow slow slow.
My boss suggested we create hashes of "chunks" of the file and then write to the destination file only when a compare of the hashes is !=.
So here's the question.
How would you test if a file is changed if you can only have one copy of the file and thus can't compare it with it's original.
I'm just shooting for a bit of brain storming.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将块的哈希值存储在某处即可。如果您知道哈希值是什么,则不需要“备份”副本进行比较。显然,这对至少一个哈希造成了先有鸡还是先有蛋的问题,但复制单个“块”的问题要小得多。
不过,您提出的方法仍然存在性能问题,因为在由电池供电的慢速 CPU 上对大文件进行哈希处理并不是一个很好的操作。
我假设您没有精细的控制来跟踪您修改的文件部分,然后在需要备份时只更新这些部分?
Just store your hashes of your chunks somewhere. You don't need the "backup" copy to compare to if you know what your hashes are. Obviously this creates a chicken and egg problem for at least one hash, but copying a single "chunk" is a much smaller problem.
Your proposed approach will still have performance problems though, as hashing a large file isn't going to be a pretty operation on a slow CPU powered by a battery.
I assume you don't have the granular control to keep track of the parts of the file you modify, and then update just those sections when you need to do backup?