2
$Id: pre_sort.c,v 1.7 2003/08/29 21:03:39 jmruiz Exp $
4
** This program and library is free software; you can redistribute it and/or
5
** modify it under the terms of the GNU (Library) General Public License
6
** as published by the Free Software Foundation; either version 2
7
** of the License, or any later version.
9
** This program is distributed in the hope that it will be useful,
10
** but WITHOUT ANY WARRANTY; without even the implied warranty of
11
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
** GNU (Library) General Public License for more details.
14
** You should have received a copy of the GNU (Library) General Public License
15
** along with this program; if not, write to the Free Software
16
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2
$Id: pre_sort.c,v 1.11 2005/05/12 15:41:05 karman Exp $
4
This file is part of Swish-e.
6
Swish-e is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
Swish-e is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with Swish-e; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
See the COPYING file that accompanies the Swish-e distribution for details
21
of the GNU GPL and the special exception available for linking against
24
** Mon May 9 14:53:51 CDT 2005
19
27
** jmruiz - 02/2001 - Sorting results module
290
298
/***********************************************************************
291
* Pre sort a single property
299
* Pre sort a single property
293
301
************************************************************************/
294
302
int *CreatePropSortArray(IndexFILE *indexf, struct metaEntry *m, FileRec *fi, int free_cache )
348
356
fi->filenum = i + 1;
350
358
/* Used cached seek pointers for this file, if not the first time */
351
if ( PropLookup[i].prop_index )
359
if ( PropLookup[i].prop_index )
352
360
fi->prop_index = PropLookup[i].prop_index;
354
362
fi->prop_index = NULL;
422
430
memset( &fi, 0, sizeof( FileRec ) );
432
#ifdef USE_PRESORT_ARRAY
425
433
DB_InitWriteSortedIndex(sw, indexf->DB ,header->property_count);
427
435
DB_InitWriteSortedIndex(sw, indexf->DB );
444
452
if ( !(m = getPropNameByID(&indexf->header, metaID )))
445
453
progerr("Failed to lookup propIDX %d (metaID %d)", propIDX, metaID );
448
456
/* Check if this property must be in a presorted index */
449
457
if (!is_presorted_prop(sw, m->metaName))
469
477
out_array = CreatePropSortArray( indexf, m, &fi, 0 );
473
DB_WriteSortedIndex(sw, metaID, (unsigned char *)out_array, total_files, indexf->DB);
480
#ifdef USE_PRESORT_ARRAY
481
DB_WriteSortedIndex(sw, metaID, out_array, total_files, indexf->DB);
475
483
for (i = 0; i < total_files; i++)
476
484
if ( PropLookup[i].SortProp )
477
485
freeProperty( PropLookup[i].SortProp );
479
out_buffer = emalloc( total_files * MAXINTCOMPSIZE );
487
out_buffer = emalloc( total_files * MAXINTCOMPSIZE );
482
490
/* Now compress */
491
/* $$$ this should be in db_natvie.c */
483
492
cur = out_buffer;
485
494
for (i = 0; i < total_files; i++)
487
496
cur = compress3( out_array[i], cur );
489
498
/* Free the property */
490
499
if ( PropLookup[i].SortProp )
491
500
freeProperty( PropLookup[i].SortProp );
530
539
/* Routines to get the proper sortorder of chars to be called when sorting */
531
540
/* sw_strcasecmp sw_strcmp */
542
/*** $$$!!!$$$ I do not think any of these routines are used any more
543
* Better to use locale settings, IMO. - moseley 2/2005
534
547
/* Exceptions to the standard translation table for sorting strings */
535
548
/* See initStrCaseCmpTranslationTable to see how it works */
636
649
iTranslationTableExceptions[i].order * 256 + iTranslationTableExceptions[i].offset;
639
/* Comparison string routine function.
652
/* Comparison string routine function.
640
653
** Similar to strcasecmp but using our own translation table
642
655
int sw_strcasecmp(unsigned char *s1, unsigned char *s2, int *iTranslationTable)
649
662
return iTranslationTable[*s1] - iTranslationTable[*s2];
652
/* Comparison string routine function.
665
/* Comparison string routine function.
653
666
** Similar to strcmp but using our own translation table
655
668
int sw_strcmp(unsigned char *s1, unsigned char *s2, int *iTranslationTable)