diff options
| author | M.Shulhan <ms@kilabit.org> | 2009-04-05 17:52:57 +0700 |
|---|---|---|
| committer | M.Shulhan <ms@kilabit.org> | 2009-04-05 17:52:57 +0700 |
| commit | 19c3ee85ea45c5b5c2a479af17b86ba65d52673b (patch) | |
| tree | 2bf8fe1e94691e85d2c19adea8a42240586c5862 /proc/vos_sort.c | |
| parent | 459cd2d7715baea5a56090b3331f0b9b95e832c2 (diff) | |
| download | vos-19c3ee85ea45c5b5c2a479af17b86ba65d52673b.tar.xz | |
fix sort process.
type/vos_TStmtJoin:
- deleted, merge into vos_TStmtMeta.h
op/vos_File:
- file_open: fix memory leak on open fail.
- file_raw_copy: new, function to copy file.
- file_raw_get_dirname: new, function to get directory name from path.
op/vos_Stmt:
- stmt_find_by_name: re-structure the switch.
- stmt_update_meta: new, update meta filename to the last output name.
op/vos_StmtSort:
- stmtsort_create: remove free sort->in.
- stmtsort_init_output: split into stmtsort_init.
- stmtsort_init: new.
- stmtsort_destroy: remove unused temporary sort file.
proc/vos_create:
- vos_process_create: update meta object before processing.
proc/vos_join:
- change affect by split of stmtsort_init_output.
proc/vos_parser:
- use 'filename' as an alias if alias is not set in statement.
proc/vos_sort:
- vos_process_sort: fix bug in sort process.
when input file is splitted into several thread and the first split
is precisely end in a new-line character, this can cause losing of one
row in the output file.
- sort_write: use 'get_tmp_dir()' to get temporary directory.
proc/vos_sort_merge:
- vos_sort_merge: simplified the merge process if only one file to be merged.
- single_merge: new.
vos:
- get_tmp_dir: new, function to get temporary directory.
Diffstat (limited to 'proc/vos_sort.c')
| -rw-r--r-- | proc/vos_sort.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/proc/vos_sort.c b/proc/vos_sort.c index 6e2029c..a013bc4 100644 --- a/proc/vos_sort.c +++ b/proc/vos_sort.c @@ -128,22 +128,7 @@ static int sort_write(struct ProcSort *psort, struct Record *rows) str_create(&tmp); do { - /* get a path to temporary directory */ - if (_vos.proc_max > 1) { - do { - s = pthread_mutex_trylock(&_vos.proc_tmp_dir_lock); - } while (s); - } - - str_append(tmp, _vos.p_proc_tmp_dir->str); - - _vos.p_proc_tmp_dir = _vos.p_proc_tmp_dir->next; - if (! _vos.p_proc_tmp_dir) - _vos.p_proc_tmp_dir = _vos.proc_tmp_dir; - - if (_vos.proc_max > 1) { - pthread_mutex_unlock(&_vos.proc_tmp_dir_lock); - } + str_append(tmp, get_tmp_dir(1)); /* get random file name */ s = str_raw_randomize(VOS_SORT_TMP_FORMAT, &rndm_name); @@ -218,6 +203,10 @@ static void *sort_process(void *parm) goto err; } + if (_vos.debug & DBG_SORT) { + printf("(%lu) pos start : %ld\n", psort->tid, FCURP(F)); + } + /* phase 1: create & fill rows */ while (FCURP(F) < psort->pos_end) { s = record_read(&R, F, psort->sort->in->fields); @@ -230,6 +219,10 @@ static void *sort_process(void *parm) break; } + if (_vos.debug & DBG_SORT) { + printf("(%lu) pos end : %ld\n", psort->tid, FCURP(F)); + } + /* check if error, but not end of file */ if (s && s != E_FILE_END) goto err; @@ -359,7 +352,10 @@ int vos_process_sort(struct Stmt *sort) /* create thread for sort */ for (i = 0; i < _vos.proc_max; i++) { - sort_proc[i].pos_start = i * esize; + if (i == 0) + sort_proc[i].pos_start = i * esize; + else + sort_proc[i].pos_start = (i * esize) - 1; if ((i + 1) == _vos.proc_max) sort_proc[i].pos_end = fsize; |
