-/*
- * Copyright (C) 1994-2002, Index Data
- * All rights reserved.
- * Sebastian Hammer, Adam Dickmeiss, Heikki Levanto
- *
- * $Id: trunc.c,v 1.26 2002-07-25 13:06:43 adam Exp $
- *
- */
+/* $Id: trunc.c,v 1.28.2.4 2005-10-22 17:27:28 adam Exp $
+ Copyright (C) 1995-2005
+ Index Data Aps
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Zebra; see the file LICENSE.zebra. If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+*/
+
+
#include <stdio.h>
#include <assert.h>
RSET result;
RSFD result_rsfd;
rset_temp_parms parms;
+ int nn = 0;
parms.cmp = key_compare_it;
parms.key_size = sizeof(struct it_key);
struct trunc_info *ti;
int rscur = 0;
int rsmax = (to-from)/i_add + 1;
+ int cmp_border = preserve_position ? 0 : 1;
rset = (RSET *) xmalloc (sizeof(*rset) * rsmax);
rsfd = (RSFD *) xmalloc (sizeof(*rsfd) * rsmax);
int n = ti->indx[ti->ptr[1]];
rset_write (result, result_rsfd, ti->heap[ti->ptr[1]]);
+ nn++;
while (1)
{
rset_delete (rset[n]);
break;
}
- if ((*ti->cmp)(ti->tmpbuf, ti->heap[ti->ptr[1]]) > 1)
+ if ((*ti->cmp)(ti->tmpbuf, ti->heap[ti->ptr[1]]) > cmp_border)
{
heap_delete (ti);
heap_insert (ti, ti->tmpbuf, n);
int n = ti->indx[ti->ptr[1]];
rset_write (result, result_rsfd, ti->heap[ti->ptr[1]]);
+ nn++;
if (preserve_position)
{
/* section that preserve all keys */
int n = ti->indx[ti->ptr[1]];
rset_write (result, result_rsfd, ti->heap[ti->ptr[1]]);
+ nn++;
if (preserve_position)
{
heap_delete (ti);
int n = ti->indx[ti->ptr[1]];
rset_write (result, result_rsfd, ti->heap[ti->ptr[1]]);
+ nn++;
#if 0
/* section that preserve all keys */
heap_delete (ti);
ISAMS_PP *ispt;
int i;
struct trunc_info *ti;
+ int nn = 0;
ispt = (ISAMS_PP *) xmalloc (sizeof(*ispt) * (to-from));
int n = ti->indx[ti->ptr[1]];
rset_write (result, result_rsfd, ti->heap[ti->ptr[1]]);
+ nn++;
while (1)
{
if (!isams_pp_read (ispt[n], ti->tmpbuf))
key_compare_it);
for (i = to-from; --i >= 0; )
{
- ispt[i] = isamb_pp_open (zi->reg->isamb, isam_p[from+i]);
- if (isamb_pp_read (ispt[i], ti->tmpbuf))
- heap_insert (ti, ti->tmpbuf, i);
- else
- isamb_pp_close (ispt[i]);
+ if (isam_p[from+i]) {
+ ispt[i] = isamb_pp_open (zi->reg->isamb, isam_p[from+i]);
+ if (isamb_pp_read (ispt[i], ti->tmpbuf))
+ heap_insert (ti, ti->tmpbuf, i);
+ else
+ isamb_pp_close (ispt[i]);
+ }
}
while (ti->heapnum)
{
int n = ti->indx[ti->ptr[1]];
rset_write (result, result_rsfd, ti->heap[ti->ptr[1]]);
+ nn++;
if (preserve_position)
{
else
logf (LOG_WARN, "Unknown isam set in rset_trunc_r");
+ parms.rset_term->nn = nn;
rset_close (result, result_rsfd);
return result;
}
parms.is = zi->reg->isamb;
parms.rset_term = rset_term_create (term, length, flags,
term_type);
- return rset_create (rset_kind_isamb, &parms);
+ if (res_get(zi->res, "rsetforward"))
+ return rset_create (rset_kind_isamb_forward, &parms);
+ else
+ return rset_create (rset_kind_isamb, &parms);
}
qsort (isam_p, no, sizeof(*isam_p), isamd_trunc_cmp);
}