• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Caching big arrays

 
Serge Papin
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a ready-to-use solution for working with big arrays in Java so that only a part of the array is in memory and everything else is stored on disk?
Thanks.
 
Stephen Huey
Ranch Hand
Posts: 618
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know of anything like that in the API...
 
Rick O'Shay
Ranch Hand
Posts: 531
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NIO has classes that do just that. It's a fundamental requirement for a serious server environment and was added in Java 1.4. NIO used to be done using native method interfaces and that's no longer required.

http://javaalmanac.com/egs/java.nio/CreateMemMap.html
 
Serge Papin
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rick O'Shay:
NIO has classes that do just that. It's a fundamental requirement for a serious server environment and was added in Java 1.4. NIO used to be done using native method interfaces and that's no longer required.

http://javaalmanac.com/egs/java.nio/CreateMemMap.html


Thanks Rick.
So do you suggest creating FileChannel and using position() and read()/write() methods to do the job? Wouldn't that be too expensive and slow?
I thought of much more sophisticated approach.
 
Rick O'Shay
Ranch Hand
Posts: 531
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Impossible to say without analyzing your requirements. The disk is slower but usually plenty fast depending on the application and the bits are dirt cheap. Actually, I think dirts a little more
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic