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 8824569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:39:59+00:00 2026-06-14T06:39:59+00:00

I have 3 millions line of data each has 30 features – it is

  • 0

I have 3 millions line of data each has 30 features – it is hard to include all in memory for my computer and slow to process it with learning algorithm – . I want to write a little code that makes random sampling but in JAVA and with my PC configurations it does not work or takes so much times to execute. I know that writing in C or C++ gives better solution but I am also curious about the availability of python for such case. Is it reasonable to use Python in such a case that Java is not working efficiently because of slowness and memory restriction – please do not say to increase heap size or such-?

  • 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-14T06:40:01+00:00Added an answer on June 14, 2026 at 6:40 am

    If performance is critical, this is the sort of solution I use.

    public class SimpleTable {
        private final List<RandomAccessFile> files = new ArrayList<RandomAccessFile>();
        private final List<FloatBuffer> buffers = new ArrayList<FloatBuffer>();
        private final File baseDir;
        private final int rows;
    
        private SimpleTable(File baseDir, int rows) {
            this.baseDir = baseDir;
            this.rows = rows;
        }
    
        public static SimpleTable create(String baseName, int rows) throws IOException {
            File baseDir = new File(baseName);
            if (!baseDir.mkdirs()) throw new IOException("Failed to create " + baseName);
            PrintWriter pw = new PrintWriter(baseName + "/rows");
            pw.println(rows);
            pw.close();
            return new SimpleTable(baseDir, rows);
        }
    
        public static SimpleTable load(String baseName) throws IOException {
            BufferedReader br = new BufferedReader(new FileReader(baseName + "/rows"));
            int rows = Integer.parseInt(br.readLine());
            br.close();
            File baseDir = new File(baseName);
            SimpleTable table = new SimpleTable(baseDir, rows);
            File[] files = baseDir.listFiles();
            Arrays.sort(files);
            for (File file : files) {
                if (!file.getName().endsWith(".float")) continue;
                table.addColumnForFile(file);
            }
            return table;
        }
    
        private FloatBuffer addColumnForFile(File file) throws IOException {
            RandomAccessFile rw = new RandomAccessFile(file, "rw");
            MappedByteBuffer mbb = rw.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, rows * 8);
            mbb.order(ByteOrder.nativeOrder());
            FloatBuffer db = mbb.asFloatBuffer();
            files.add(rw);
            buffers.add(db);
            return db;
        }
    
        public int rows() {
            return rows;
        }
    
        public int columns() {
            return buffers.size();
        }
    
        public FloatBuffer addColumn() throws IOException {
            return addColumnForFile(new File(baseDir, String.format("%04d.float", buffers.size())));
        }
    
        public FloatBuffer getColumn(int n) {
            return buffers.get(n);
        }
    
        public void close() throws IOException {
            for (RandomAccessFile file : files) {
                file.close();
            }
            files.clear();
            buffers.clear();
        }
    }
    
    public class SimpleTableTestMain {
        public static void main(String... args) throws IOException {
            long start = System.nanoTime();
            SimpleTable st = SimpleTable.create("test", 3 * 1000 * 1000);
            for (int i = 0; i < 50; i++) {
                FloatBuffer db = st.addColumn();
                for (int j = 0; j < db.capacity(); j++)
                    db.put(j, i + j);
            }
            st.close();
    
            long mid = System.nanoTime();
    
            SimpleTable st2 = SimpleTable.load("test");
            for (int i = 0; i < 50; i++) {
                FloatBuffer db = st2.getColumn(i);
                double sum = 0;
                for (int j = 0; j < db.capacity(); j++)
                    sum += db.get(j);
                assert sum > 0;
            }
    
            long end = System.nanoTime();
            System.out.printf("Took %.3f seconds to write and %.3f seconds to read %,d rows and %,d columns%n",
                    (mid - start) / 1e9, (end - mid) / 1e9, st2.rows(), st2.columns());
            st2.close();
        }
    }
    

    prints

    Took 2.070 seconds to write and 2.206 seconds to read 3,000,000 rows and 50 columns
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSV file with 6 millions rows. Each line is made up
I have a file with over a million lines of data, each line is
I have a program which writes some 8 millions line of data in a
I have to store millions of entries in a database. Each entry is identified
I have a CSV file. Each line is made up of the same format
We have millions of simple txt documents containing various data structures we extracted from
i have a postgres database with millions of rows in it it has a
I have a table that has about 1/2 million records in it. Each month
I have data that looks like this: token eps rank # first line names
Supposing that I have millions of user profiles, with hundreds of fields (name, gender,

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.