0

I am building an Android application, which loads a large dictionary into memory, such that remaining RAM is very limited.

I need to reference a second large word-list, but don't have the space to load it into RAM.

Since the "disk" on an Android device is actually also RAM, would it be practical to quickly search my second list without first loading it into memory?

I was thinking of some sort of disk-based divide-and-conquer algorithm.

For instance, I could format the 2nd list alphabetically with fixed-size fields,

  • seek to the middle of the file, and grab that word
  • determine if my word is in the first-half or second half
  • recurse until I find my word (or don't)

But I don't know what the performance of doing it this way would be. And I can't seem to find anything documented on the web about searching files this way.

Perhaps I am simply searching for the wrong terms.

If anybody can point me to a tutorial on filesystem-based seeking in java (android) I would appreciate it!

Brent
  • 16,259
  • 12
  • 42
  • 42
  • "Since the "disk" on an Android device is actually also RAM" -- no, it is not. "I was thinking of some sort of disk-based divide-and-conquer algorithm" -- is there any particular reason why you not using a database? Or at least an existing Java b-tree (or similar) library? – CommonsWare Jan 17 '14 at 20:36
  • @CommonsWare Can you implement a b-tree in the filesystem? If so, any idea how? – Brent Jan 17 '14 at 20:55
  • 2
    Try searching the Web for `java btree database`. Personally, I would just use SQLite until I demonstrated that it would have insufficient performance. – CommonsWare Jan 17 '14 at 20:59

0 Answers0