Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8122517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:51:46+00:00 2026-06-06T05:51:46+00:00

I have an int and float array of length 220 million (fixed). Now, I

  • 0

I have an int and float array of length 220 million (fixed). Now, I want to store/upload those arrays to/from memory and disk. Currently, I am using Java NIO’s FileChannel and MappedByteBuffer to solve this. It works fine, but takes near about 5 seconds (Wall Clock Time) for storing/uploading array to/from memory to disk. Actually, I want more faster one. Can anybody help me, is there any inbuilt java library/ database / any other approach to make uploading/storing arrays much faster ? I specially care about uploading to memory from disk. I want to make it faster. So, if storing time will increase to do that I have no issue. Thanks in advance.

The code I am using is given below (if required):

int savenum = 220000000 ;

public void save() {
 try {
    long l = 0 ;
FileChannel channel = new RandomAccessFile(str1, "rw").getChannel();
MappedByteBuffer mbb = channel.map(FileChannel.MapMode.READ_WRITE, 0, savenum * 8);
mbb.order(ByteOrder.nativeOrder());

for(int i = 0 ; i < savenum ; i++){
l = a[i] ;
 mbb.putLong(l);
}
channel.close();

FileChannel channel1 = new RandomAccessFile(str2, "rw").getChannel();
MappedByteBuffer mbb1 = channel1.map(FileChannel.MapMode.READ_WRITE, 0, savenum * 4);
mbb1.order(ByteOrder.nativeOrder());

for(int i = 0 ; i < savenum ; i++){
 int ll = b[i] ;
 mbb1.putInt(ll);
 }
 channel1.close();
 }
  catch (Exception e){
    System.out.println("IOException : " + e);
  }
 }

 public void load(){
 try{
 FileChannel channel2 = new RandomAccessFile(str1, "r").getChannel();
  MappedByteBuffer mbb2 = channel2.map(FileChannel.MapMode.READ_ONLY, 0, channel2.size());
 mbb2.order(ByteOrder.nativeOrder());
  assert mbb2.remaining() == savenum * 8;
 for (int i = 0; i < savenum; i++) {
 long l = mbb2.getLong();
 a[i] = l ;
 }
 channel2.close();

  FileChannel channel3 = new RandomAccessFile(str2, "r").getChannel();
   MappedByteBuffer mbb3 = channel3.map(FileChannel.MapMode.READ_ONLY, 0, channel3.size());
   mbb3.order(ByteOrder.nativeOrder());
   assert mbb3.remaining() == savenum * 4;
    for (int i = 0; i < savenum; i++) {
    int l1 = mbb3.getInt();
    b[i] = l1 ;
    }
    channel3.close();
    }

    catch(Exception e){
    System.out.println(e) ;
      }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:51:47+00:00Added an answer on June 6, 2026 at 5:51 am

    If you want to speed up the operation, you can change your code so you are not doing the copy at all. i.e. use the ByteBuffer, or IntBuffer or LongBuffer. This has the benefit of saving a copy into heap of what you off heap already, but also you only load as you use it. i.e. your processing can be concurrent with the loading.

    Using this approach should cut your initial “load” time to around 10 ms, and there is no “save” time because it will already be available to the OS.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an int array containing gray scale values from 0-254, i also have
This is a follow up question from Problem with array assignment I now have
I have a few reasons to define a type for a fixed length array
I have a float array in java and want to convert each element to
Hi i have created a Generic Array that works fine for Int,String, Float or
Say we have a struct of an int array, a float array etc. and
I have 1000 float datas in an array. I want to separate into different
Let us suppose i have these three methods defined: int F1(int, int); int F1(float,
i have the following code: #include <stdio.h> int main(void) { float a[4] __attribute__((aligned(0x1000))) =
I have this situation: { float foo[10]; for (int i = 0; i <

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.