<commit_before>'use strict';

/**
 * Module dependencies.
 */
var _ = require('lodash'),
    path = require('path'),
    mongoose = require('mongoose'),
    RideModel = mongoose.model('Ride'),
    errorHandler = require(path.resolve('./modules/core/server/controllers/errors.server.controller'));

var fs = require('fs'),
    parser = require('xml2json'),
    spawn = require('child_process').spawn,
    util = require('util'),
    geocoder = require('geocoder');

exports.generate = function(req, res) {
    var str = '',
        people = req.body.people,
        timestamp = new Date().getTime().toString(),
        inputFile = './scripts/input/in-' + timestamp;

    if(people.length > 0) {
        _.each(people, function(person) {
            var startLong = person.start.longitude,
                startLat = person.start.latitude,
                endLong = person.end.longitude,
                endLat = person.end.latitude;
            str += util.format('%s,%s,%s,%s,%s,%s,%s\n', person.name, startLong, startLat, endLong, endLat, person.driver, person.capacity);
        });
        fs.writeFileSync(inputFile, str);
        var child = spawn('/usr/bin/java', ['-jar', process.cwd() + '/scripts/genRides.jar', timestamp], {
            cwd: './scripts',
            stdio: 'inherit'
        });

        child.on('close', function(code) {
            if(code !== 0) {
                console.log('child exited with code: ' + code);
                return res.status(500).send({
                    message: 'Woops.. something happened..'
                });
            }
            var outputFile = './scripts/output/out-' + timestamp + '.xml';
            console.log('DONE, Reading ' + outputFile);

            fs.readFile(outputFile, function(err, data) {
                if(err) {
                    return res.status(500).send({
                        message: errorHandler.getErrorMessage(err)
                    });
                }<commit_msg>set max jvm heap size for ride gen execution<commit_after>'use strict';

/**
 * Module dependencies.
 */
var _ = require('lodash'),
    path = require('path'),
    mongoose = require('mongoose'),
    RideModel = mongoose.model('Ride'),
    errorHandler = require(path.resolve('./modules/core/server/controllers/errors.server.controller'));

var fs = require('fs'),
    parser = require('xml2json'),
    spawn = require('child_process').spawn,
    util = require('util'),
    geocoder = require('geocoder');

exports.generate = function(req, res) {
    var str = '',
        people = req.body.people,
        timestamp = new Date().getTime().toString(),
        inputFile = './scripts/input/in-' + timestamp;

    if(people.length > 0) {
        _.each(people, function(person) {
            var startLong = person.start.longitude,
                startLat = person.start.latitude,
                endLong = person.end.longitude,
                endLat = person.end.latitude;
            str += util.format('%s,%s,%s,%s,%s,%s,%s\n', person.name, startLong, startLat, endLong, endLat, person.driver, person.capacity);
        });
        fs.writeFileSync(inputFile, str);
        var child = spawn('/usr/bin/java', ['-jar', '-Xmx' + process.env.RIDE_GEN_HEAP_SIZE + 'm', process.cwd() + '/scripts/genRides.jar', timestamp], {
            cwd: './scripts',
            stdio: 'inherit'
        });
        console.log(process.env.RIDE_GEN_HEAP_SIZE);
        child.on('close', function(code) {
            if(code !== 0) {
                console.log('child exited with code: ' + code);
                return res.status(500).send({
                    message: 'Woops.. something happened..'
                });
            }
            var outputFile = './scripts/output/out-' + timestamp + '.xml';
            console.log('DONE, Reading ' + outputFile);

            fs.readFile(outputFile, function(err, data) {
                if(err) {
                    return res.status(500).send({
                        message: errorHandler.getErrorMessage(err)
                    });
                }
{'fraction_non_alphanumeric': 0.15641908509591737, 'fraction_numerical': 0.004426955238563699, 'mean_word_length': 2.003692762186115, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7587690', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1140, 'n_words': 220}