Java文件IO与本地数据库 [英] Java File IO vs Local database

查看:118
本文介绍了Java文件IO与本地数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个涉及快速解析大量数据的项目。目前,该数据在磁盘上并分解成目录层次结构:

 (Folder:DataSource) - > (文件:Day1,Day2,Day3 ... Day1000 ...)
(文件夹:DataSource2) - > (文件:Day1,Day2,Day3 ... Day1000 ...)
...
(文件夹:DataSource1000) - > ...
...

每天文件包含需要访问的条目非常快。



我最初的计划是在java中使用传统的FileIO来访问这些文件,但是在进一步阅读时,我开始担心这可能太慢。



简而言之,我可以从不同的DataSources和Days选择性加载来自我的文件系统的条目的最快的方法是什么?

解决方案

问题可以通过两种方式解决,但它取决于几个因素



go for FileIO


  1. 如果您不要像Jon Skeet这样的复杂查询说出

  2. 如果您的引用获取行是通过使用hte文件夹名称:DataSource作为键

转到DB b


  1. 如果您看到您的计划读取数百万条记录

  2. ,您可以进行复杂的选择

  3. 如果您知道为数据库创建基本表结构,则
  4. I am working on a project that involves parsing through a LARGE amount of data rapidly. Currently this data is on disk and broken down into a directory hierarchy:

    (Folder: DataSource) -> (Files: Day1, Day2, Day3...Day1000...)
    (Folder: DataSource2) -> (Files: Day1, Day2, Day3...Day1000...) 
    ...
    (Folder: DataSource1000) -> ...
    ...
    

    Each Day file consists of entries that need to be accessed very quickly.

    My initial plans were to use traditional FileIO in java to access these files, but upon further reading, I began to fear that this might be too slow.

    In short, what is the fastest way I can selectively load entries from my filesystem from varying DataSources and Days?

    解决方案

    The issue could be solved both ways but it depends on few factors

    go for FileIO.

    1. if the volume is < millons of rows
    2. if your dont do a complicated query like Jon Skeet said
    3. if your referance for fetching the row is by using hte Folder Name: "DataSource" as the key

    go for DB

    1. if you see your program reading through millions of records
    2. you can do complicated selection, even multiple rows using a single select.
    3. if you have knowledge of creating a basic table structure for DB

    这篇关于Java文件IO与本地数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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