1 |
/* |
2 |
====================================================================== |
3 |
Header for N-way out-of-core merge sort for records with 3D keys. |
4 |
|
5 |
Roland Schregle (roland.schregle@{hslu.ch, gmail.com}) |
6 |
(c) Lucerne University of Applied Sciences and Arts, |
7 |
supported by the Swiss National Science Foundation (SNSF, #147053) |
8 |
====================================================================== |
9 |
|
10 |
$Id: oocsort.h,v 1.16 2015/09/15 13:33:22 taschreg Exp taschreg $ |
11 |
*/ |
12 |
|
13 |
#ifndef OOC_SORT_H |
14 |
#define OOC_SORT_H |
15 |
|
16 |
#include "fvect.h" |
17 |
#include <stdio.h> |
18 |
|
19 |
|
20 |
/* Sort records in inFile and append to outFile by subdividing inFile |
21 |
* into small blocks, sorting these in-core, and merging them out-of-core |
22 |
* via a priority queue. |
23 |
* |
24 |
* This is implemented as a recursive (numBlk)-way sort; the input is |
25 |
* successively split into numBlk smaller blocks until these are of size |
26 |
* <= blkSize, i.e. small enough for in-core sorting, then merging the |
27 |
* sorted blocks as the stack unwinds. The in-core sort is parallelised |
28 |
* over numProc processes. |
29 |
* |
30 |
* Parameters are as follows: |
31 |
* inFile Opened input file containing unsorted records |
32 |
* outFile Opened output file containing sorted records |
33 |
* numBlk Number of blocks to divide into / merge from |
34 |
* blkSize Max block size and size of in-core sort buffer, in bytes |
35 |
* numProc Number of parallel processes for in-core sort |
36 |
* recSize Size of input records in bytes |
37 |
* bbOrg Origin of bounding box containing record keys for Morton code |
38 |
* bbSize Extent of bounding box containing record keys for Morton code |
39 |
* key Callback to access 3D coords from records for Morton code |
40 |
*/ |
41 |
int OOC_Sort (FILE *inFile, FILE *outFile, unsigned numBlk, |
42 |
unsigned long blkSize, unsigned numProc, unsigned recSize, |
43 |
FVECT bbOrg, RREAL bbSize, RREAL *(*key)(const void*)); |
44 |
#endif |