android - How do I index a CSV file which maps (mostly) consecutive integers to Strings so that I can search it efficiently in Java? -
i have large csv file (8000 rows) consisting of 2 columns. first column integer ranging 1 10000, , second column string of 6 10 characters. because implementation in android, accessing file using assetmanager, must use inputstream read file.
the input system integer 1 through 10000, , output corresponding string, or null if there no integer match. general use case of app involves multiple (~4) such requests, each of which under current implementation freeze app 2-3 seconds.
i want able search efficiently, using phonebook (i.e., o(log(n)) time) search, without storing entire file in memory. assume should reformat file csv else... maybe sql database? appropriate implementation case?
i entirely unfamiliar large-scale data access, , honest mental model of how , when files loaded memory , accessed on android little fuzzy. in advance.
i recommend importing csv file sqlite database. here link on how that: sqlite3 csv , here excellent tutorial on using sqlite android: android sqlite database , contentprovider - tutorial
Comments
Post a Comment