Loading a huge 3d array into Java

What would you guys suggest I use if I want to load a large 3d array and not run out of space. I'm assuming an array as opposed to some sort of 3d linked list would space space and be faster but if I try to load a 100 by 100 by 100 array and initialize each spot with some sort of object it throws an out of space error. Storing all this information in a plain text file would probably pretty slow (this is for a simulation)

Would a DB --say mySQL -- be faster than a flat text file? where can I store all this information and have it accessible fairly quickly, would a flash drive be any faster than a HD? (I seriously doubt but I have to ask)

Thanks

[671 byte] By [mikebasa] at [2007-11-27 11:57:25]
# 1

I should add that the object at each pt is not too big. All it has is a single empty hashmap when initialized and probably the hash map will eventually have a few string keys (couple of letters less than 10) and a double value.

mikebasa at 2007-7-29 19:13:49 > top of Java-index,Java Essentials,Java Programming...
# 2

The best way to approach your problem is not to jump right into the technical details (arrays versus linked lists) but to state, clearly and concisely, what your goals are. What are you trying to do? Note: what, not how.

This is a lesson in Java. And life.

ParvatiDevia at 2007-7-29 19:13:49 > top of Java-index,Java Essentials,Java Programming...
# 3

Always appreciate a life lesson.

I am trying to store a large 3D Array of information. (Imagine if you were trying to model the room you're in and wanted in 3 dimensions to specify what exists at every point... Oxygen, 1/100th of a hair... etc...)

mikebasa at 2007-7-29 19:13:49 > top of Java-index,Java Essentials,Java Programming...
# 4

Will every (x,y,z) coordinate (all 1,000,000 of them) have data? Or will the grid be sparsely populated?

ParvatiDevia at 2007-7-29 19:13:49 > top of Java-index,Java Essentials,Java Programming...
# 5

> Always appreciate a life lesson.

>

> I am trying to store a large 3D Array of information.

> (Imagine if you were trying to model the room you're

> in and wanted in 3 dimensions to specify what exists

> at every point... Oxygen, 1/100th of a hair... etc...)

Usually when you model 3d spaces like this, you define where objects exist, not what exists at every location in the space. Define the size and location of the dresser, the hair, the dog, the dirty underwear on the floor, and assume that every location that doesn't have one of those objects in it is filled with air. That will make it a lot easier to find the location of a specified object, and add/remove/change objects in the room. It will also be faster to work with, since you have much less data to maintain at once.

hunter9000a at 2007-7-29 19:13:49 > top of Java-index,Java Essentials,Java Programming...
# 6

Well at the moment I'm assuming all of them will have data although initially they are all blank but it's not unlikely. Right now I initialize them to the object when they get data otherwise they are null. So there is no problem creating a 100 by 100 by 100 array because most of it is null, but my concern is what happens when the array does fill up? (There is a method that I have that fills up the entire thing, and this is a useful functionality)

Am I just running up against a hardware limitation or am I taking a wrong approach for this type of thing?

mikebasa at 2007-7-29 19:13:49 > top of Java-index,Java Essentials,Java Programming...
# 7

ok thanks guys.

mikebasa at 2007-7-29 19:13:49 > top of Java-index,Java Essentials,Java Programming...
# 8

You're still taking the wrong approach that you were originally taking, namely acting before thinking. "Sparse matrix" is your Google search words. Here's an example:

http://en.wikipedia.org/wiki/Sparse_matrix

You should be able to find useful techniques on the web rather than inventing your own from scratch.

DrClapa at 2007-7-29 19:13:49 > top of Java-index,Java Essentials,Java Programming...