IDZEBRA 2.2.8
kcontrol.c
Go to the documentation of this file.
1/* This file is part of the Zebra server.
2 Copyright (C) Index Data
3
4Zebra is free software; you can redistribute it and/or modify it under
5the terms of the GNU General Public License as published by the Free
6Software Foundation; either version 2, or (at your option) any later
7version.
8
9Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10WARRANTY; without even the implied warranty of MERCHANTABILITY or
11FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
18*/
19
20#if HAVE_CONFIG_H
21#include <config.h>
22#endif
23#include <assert.h>
24#include "index.h"
25
28 void (*filter_destroy)(void *data);
29};
30
31static void my_inc(struct rset_key_control *kc)
32{
33 struct context_control *cp;
34
35 assert(kc);
36 cp = kc->context;
37 (cp->ref_count)++;
38}
39
40static void my_dec(struct rset_key_control *kc)
41{
42 struct context_control *cp;
43
44 assert(kc);
45 cp = kc->context;
46 (cp->ref_count)--;
47 if (cp->ref_count == 0)
48 {
49 if (cp->filter_destroy)
50 (*cp->filter_destroy)(kc->filter_data);
51 xfree(cp);
52 xfree(kc);
53 }
54}
55
56
58{
59 struct rset_key_control *kc = xmalloc(sizeof(*kc));
60 struct context_control *cp = xmalloc(sizeof(*cp));
61
62 kc->context = cp;
63 kc->key_size = sizeof(struct it_key);
64 kc->cmp = key_compare;
66 kc->getseq = key_get_seq;
67
68 if (zh->m_segment_indexing)
69 {
70 kc->scope = 3; /* segment + seq is "same" record */
72 }
73 else
74 {
75 kc->scope = 2; /* seq is "same" record */
76 kc->get_segment = 0;
77 }
78
80 &kc->filter_func,
81 &cp->filter_destroy,
82 &kc->filter_data);
83 kc->inc = my_inc;
84 kc->dec = my_dec;
85 cp->ref_count = 1;
86 return kc;
87}
88
89/*
90 * Local variables:
91 * c-basic-offset: 4
92 * c-file-style: "Stroustrup"
93 * indent-tabs-mode: nil
94 * End:
95 * vim: shiftwidth=4 tabstop=8 expandtab
96 */
97
void zebra_limit_for_rset(struct zebra_limit *zl, int(**filter_func)(const void *buf, void *data), void(**filter_destroy)(void *data), void **filter_data)
Definition limit.c:96
zint key_get_segment(const void *p)
Definition it_key.c:104
int key_compare(const void *p1, const void *p2)
Definition it_key.c:74
void key_logdump_txt(int logmask, const void *p, const char *txt)
Definition it_key.c:38
zint key_get_seq(const void *p)
Definition it_key.c:97
static void my_inc(struct rset_key_control *kc)
Definition kcontrol.c:31
static void my_dec(struct rset_key_control *kc)
Definition kcontrol.c:40
struct rset_key_control * zebra_key_control_create(ZebraHandle zh)
Definition kcontrol.c:57
void(* filter_destroy)(void *data)
Definition kcontrol.c:28
void(* dec)(struct rset_key_control *kc)
Definition rset.h:138
void * filter_data
Definition rset.h:136
int(* cmp)(const void *p1, const void *p2)
Definition rset.h:131
void(* key_logdump_txt)(int logmask, const void *p, const char *txt)
Definition rset.h:132
int(* filter_func)(const void *p, void *data)
Definition rset.h:135
void(* inc)(struct rset_key_control *kc)
Definition rset.h:137
zint(* getseq)(const void *p)
Definition rset.h:133
void * context
Definition rset.h:127
zint(* get_segment)(const void *p)
Definition rset.h:134
int m_segment_indexing
Definition index.h:206
struct zebra_limit * m_limit
Definition index.h:232