java/openmldb-import/src/main/java/com/_4paradigm/openmldb/importer/Importer.java
private static void insertImportByRange(int X, List<CSVRecord> rows, SqlExecutor router, String dbName, String tableName) {
        int quotient = rows.size() / X;
        int remainder = rows.size() % X;
        // range is [left, right)
        List<Pair<Integer, Integer>> ranges = new ArrayList<>();
        int start = 0;
        for (int i = 0; i < remainder; ++i) {
            int rangeEnd = Math.min(start + quotient + 1, rows.size());
            ranges.add(Pair.of(start, rangeEnd));
            start = rangeEnd;
        }
        for (int i = remainder; i < X; ++i) {
            int rangeEnd = Math.min(start + quotient, rows.size());
            ranges.add(Pair.of(start, rangeEnd));
            start = rangeEnd;
        }

        List<Thread> threads = new ArrayList<>();
        for (Pair<Integer, Integer> range : ranges) {
            threads.add(new Thread(new InsertImporter(router, dbName, tableName, rows, range)));
        }

        threads.forEach(Thread::start);

        threads.forEach(thread -> {
            try {
                thread.join();
            } catch (InterruptedException e) {
                logger.error(e.getMessage());
            }
        });

    }
// can't find a good import tool framework, may ref mysqlimport
can't find a good import tool framework, may ref mysqlimport
can ' t find a good import tool framework may ref mysqlimport
private static void insertImportByRange(int X, List<CSVRecord> rows, SqlExecutor router, String dbName, String tableName) {
        int quotient = rows.size() / X;
        int remainder = rows.size() % X;
        List<Pair<Integer, Integer>> ranges = new ArrayList<>();
        int start = 0;
        for (int i = 0; i < remainder; ++i) {
            int rangeEnd = Math.min(start + quotient + 1, rows.size());
            ranges.add(Pair.of(start, rangeEnd));
            start = rangeEnd;
        }
        for (int i = remainder; i < X; ++i) {
            int rangeEnd = Math.min(start + quotient, rows.size());
            ranges.add(Pair.of(start, rangeEnd));
            start = rangeEnd;
        }
        List<Thread> threads = new ArrayList<>();
        for (Pair<Integer, Integer> range : ranges) {
            threads.add(new Thread(new InsertImporter(router, dbName, tableName, rows, range)));
        }
        threads.forEach(Thread::start);
        threads.forEach(thread -> {
            try {
                thread.join();
            } catch (InterruptedException e) {
                logger.error(e.getMessage());
            }
        });
    }
private static void insertImportByRange ( int X , List < CSVRecord > rows , SqlExecutor router , String dbName , String tableName ) { int quotient = rows . size ( ) / X ; int remainder = rows . size ( ) % X ; List < Pair < Integer , Integer > > ranges = new ArrayList < > ( ) ; int start = 0 ; for ( int i = 0 ; i < remainder ; ++ i ) { int rangeEnd = Math . min ( start + quotient + 1 , rows . size ( ) ) ; ranges . add ( Pair . of ( start , rangeEnd ) ) ; start = rangeEnd ; } for ( int i = remainder ; i < X ; ++ i ) { int rangeEnd = Math . min ( start + quotient , rows . size ( ) ) ; ranges . add ( Pair . of ( start , rangeEnd ) ) ; start = rangeEnd ; } List < Thread > threads = new ArrayList < > ( ) ; for ( Pair < Integer , Integer > range : ranges ) { threads . add ( new Thread ( new InsertImporter ( router , dbName , tableName , rows , range ) ) ) ; } threads . forEach ( Thread :: start ) ; threads . forEach ( thread -> { try { thread . join ( ) ; } catch ( InterruptedException e ) { logger . error ( e . getMessage ( ) ) ; } } ) ; }
can't find a good import tool framework, may ref mysqlimport
can ' t find a good import tool framework may ref mysqlimport
// range is [left, right)