• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Caching big arrays

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know of anything like that in the API...
 
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic