<commit_before>/****************************************************************************/
/* This file is part of the Simbatch project                                */
/* written by <NAME>, ENS Lyon                                  */
/*                                                                          */
/* Copyright (c) 2009 <NAME>. All rights reserved.                   */
/*                                                                          */
/* This program is free software; you can redistribute it and/or modify it  */
/* under the terms of the license (GNU LGPL) which comes with this package. */
/****************************************************************************/


#include <stdlib.h>
#include <stdio.h>

#include <xbt/sysdep.h>
#include <xbt/fifo.h>

#include "plugin_input.h"
#include "job.h"


/******** Functions ********/
static xbt_fifo_t wld_parse(const char * wld_file, const char * name);

/***************************/

plugin_input_t init_input(plugin_input_t p) {
    p->create_list = wld_parse;
    
    return p;
}

/*
 * fields :
 * 1 -> submit_time : job will be submit at time t
 * 2 -> run_time : time needed for the job to be done
 *      (it will be soon amount of computation)
 * 3 -> input_size : amount of data to transfert before treatment
 * 4 -> ouput_size : amount of data to transfert after
 * 5 -> requested time : define the end size of a reservation
 * 6 -> nb_procs : nb procs requested for a task   
 * 7 -> service : type of job
 * 8 -> priority : priority of the task
 */
static xbt_fifo_t wld_parse(const char * wld_file, const char * name) {
    int i = 1;
    FILE * f = NULL;
    char buf[512];
    xbt_fifo_t list = NULL;
    
    
    /* Papa's got a brand new bag... */
    printf ("parsing %s\n", wld_file);
    if ((f = fopen(wld_file, "r")) == NULL) {
	fprintf (stderr, "%s:line %d, function %s, fopen failed : %s \n",\
		 __FILE__, __LINE__, __func__, wld_file);
	return NULL;
    }
    
    list = xbt_fifo_new();
    
    while (fgets(buf,512,f) != NULL) {
	/* Comments */
	if (buf[0] != ';') {
	    job_t job;
	    
	    job = xbt_malloc(sizeof(*job));
	    job->start_time = 0.0;
	    /* Need to ajsust and keep only the usefull data */
	    sscanf(buf,"%lu %lf %lf %lf %lf %lf %d %d %u", 
                &(job->user_id), &(job->submit_time), &(job->run_time),
                &(job->input_size), &(job->output_size), &(job->wall_time),
                   &(job->nb_procs), &(job->priority), &(job->service));
	    job->state = WAITING;
	    job->free_on_completion = 1;
	    sprintf(job->name, "%s%lu", name, job->user_id);
	    xbt_fifo_push(list,job);
#ifdef DEBUG
	    printf("%s %lf %lf %lf %lf %d %u\n", job->name, job->submit_time,
		   job->run_time, job->input_size, job->wall_time, 
                   job->nb_procs, job->service);
#endif
	    }
    }
    fclose(f);
    
    return list;
}
<commit_msg>correction bug sur le mapping des jobs (initialisation a NULL.<commit_after>/****************************************************************************/
/* This file is part of the Simbatch project                                */
/* written by <NAME>, ENS Lyon                                  */
/*                                                                          */
/* Copyright (c) 2009 <NAME>. All rights reserved.                   */
/*                                                                          */
/* This program is free software; you can redistribute it and/or modify it  */
/* under the terms of the license (GNU LGPL) which comes with this package. */
/****************************************************************************/


#include <stdlib.h>
#include <stdio.h>

#include <xbt/sysdep.h>
#include <xbt/fifo.h>

#include "plugin_input.h"
#include "job.h"


/******** Functions ********/
static xbt_fifo_t wld_parse(const char * wld_file, const char * name);

/***************************/

plugin_input_t init_input(plugin_input_t p) {
    p->create_list = wld_parse;
    
    return p;
}

/*
 * fields :
 * 1 -> submit_time : job will be submit at time t
 * 2 -> run_time : time needed for the job to be done
 *      (it will be soon amount of computation)
 * 3 -> input_size : amount of data to transfert before treatment
 * 4 -> ouput_size : amount of data to transfert after
 * 5 -> requested time : define the end size of a reservation
 * 6 -> nb_procs : nb procs requested for a task   
 * 7 -> service : type of job
 * 8 -> priority : priority of the task
 */
static xbt_fifo_t wld_parse(const char * wld_file, const char * name) {
    int i = 1;
    FILE * f = NULL;
    char buf[512];
    xbt_fifo_t list = NULL;
    
    
    /* Papa's got a brand new bag... */
    printf ("parsing %s\n", wld_file);
    if ((f = fopen(wld_file, "r")) == NULL) {
	fprintf (stderr, "%s:line %d, function %s, fopen failed : %s \n",\
		 __FILE__, __LINE__, __func__, wld_file);
	return NULL;
    }
    
    list = xbt_fifo_new();
    
    while (fgets(buf,512,f) != NULL) {
	/* Comments */
	if (buf[0] != ';') {
	    job_t job;
	    
	    job = xbt_malloc(sizeof(*job));
	    job->start_time = 0.0;
	    /* Need to ajsust and keep only the usefull data */
	    sscanf(buf,"%lu %lf %lf %lf %lf %lf %d %d %u", 
                &(job->user_id), &(job->submit_time), &(job->run_time),
                &(job->input_size), &(job->output_size), &(job->wall_time),
                   &(job->nb_procs), &(job->priority), &(job->service));
	    job->state = WAITING;
	    job->free_on_completion = 1;
	    job->mapping = NULL;
	    sprintf(job->name, "%s%lu", name, job->user_id);
	    xbt_fifo_push(list,job);
#ifdef DEBUG
	    printf("%s %lf %lf %lf %lf %d %u\n", job->name, job->submit_time,
		   job->run_time, job->input_size, job->wall_time, 
                   job->nb_procs, job->service);
#endif
	    }
    }
    fclose(f);
    
    return list;
}

{'fraction_non_alphanumeric': 0.19758954337124426, 'fraction_numerical': 0.007808521473434052, 'mean_word_length': 2.1609442060085837, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 76, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1843047', 'n_tokens_mistral': 1948, 'n_tokens_neox': 1828, 'n_words': 545}