Efficiently search big file?

Discussion in 'iOS Programming' started by ranguvar, Mar 5, 2010.

  1. ranguvar macrumors 6502

    Joined:
    Sep 18, 2009
    #1
    Hi,

    I got a text file (~1.5 MB) that contains about 25,000 lines. Each line contains values of a location (name, latitude, longitude, etc...). In my app, the user will search for locations, and the app will have to look them up in the file.

    I thought about using CoreData (because of SQLite's great performance) to create a persistent store, then search it each time the user searches for a location.
    However, creating the whole managed object model etc. seems to be somewhat overkill for my quite trivial task.

    Is there any simpler way to do this, or do I have to use CoreData?

    Thanks!
    - ranguvar
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    If you want efficient search then you are probably going to be looking at some sort of indexed database style option at some point. One potentially simple option would be to split the file into a number of smaller files with a known set of properties: say latitude ranges. This would enable you to open and search a smaller file. This is basically a crude index on that value.

    Other than that you could write a script that loads the data into a SQLite database with one table and just use raw or thinly wrapped SQLite (FMDB seems popular) to search the table.

    I would probably look at the second option having the script to generate the SQLite database running as a build phase in your project.
     
  3. ranguvar thread starter macrumors 6502

    Joined:
    Sep 18, 2009
    #3
    How would that compare to using CoreData performance- and effortwise?
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Those more successful than me say that it'll perform way better than CoreData. Effort wise? Not sure but I imagine similar.
     
  5. ranguvar thread starter macrumors 6502

    Joined:
    Sep 18, 2009
    #5
    Many thanks for the link! Definitely a good read. From what I understand, what I'm trying to perform (sifting through a large table) is a "database-y" task. I'm not having any object relations, nor am I doing any object modifications, so I really only got "dumb" data. Thus, I should probably go with FMDB (or the likes), not CoreData.
     

Share This Page