
2001-08-10 Not Zed <NotZed@Ximian.com> * wordindexmem.c (sync_cache_entry): NOOP if writing to a failed file. (word_index_pre): NOOP if failed file. (ibex_create_word_index_mem): Setup blocks value. ** Added internal exception handling to libibex, in the case of errors with on-disk data, exceptions are returned. * block.c (ibex_block_cache_open): Detect fatal errors below us and clean up appropriately. (ibex_block_cache_fail): New function to handle the failure, and keep track of it. (ibex_block_cache_sync): Dont do anything if we've failed on this file. * disktail.c (tail_compress): Add blocks param so we can assert for exceptions. * hash.c, block.c disktail.c: g_assert->ibex_block_cache_assert where dealing with external data. * hash.c (hash_info): Add index param so we can assert for exceptions. * ibex_block.c (ibex_index_buffer): Setjmp before calling into internal routines. (ibex_save): " (ibex_unindex): " (ibex_find): " (ibex_find_name): " (ibex_contains_name): " (ibex_reset): Function to reset the index file if we have an error, call when we have an error. * block.h (ibex_block_cache_assert): Create assertion/exception macros, and include a setjmp buffer for returning it. 2001-08-09 Not Zed <NotZed@Ximian.com> * Makefile.am (libibex_la_SOURCES): Remove wordindex.c, wordindexmem is what's used. svn path=/trunk/; revision=11864
77 lines
2.8 KiB
C
77 lines
2.8 KiB
C
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
|
*
|
|
* Copyright (C) 2000 Ximian, Inc.
|
|
*
|
|
* Authors: Michael Zucchi <notzed@ximian.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public License
|
|
* as published by the Free Software Foundation; either version 2 of
|
|
* the License, or (at your option) any later version.
|
|
*
|
|
* This library 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
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
|
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#ifndef _WORDINDEX_H
|
|
#define _WORDINDEX_H
|
|
|
|
#include <glib.h>
|
|
|
|
#include "block.h"
|
|
#include "index.h"
|
|
|
|
struct _IBEXWord;
|
|
|
|
/* not used yet */
|
|
typedef void (*IBEXNormaliseFunc)(char *source, int len, char *dest);
|
|
|
|
struct _IBEXWordClass {
|
|
int (*sync)(struct _IBEXWord *);
|
|
int (*flush)(struct _IBEXWord *);
|
|
int (*close)(struct _IBEXWord *);
|
|
|
|
void (*index_pre)(struct _IBEXWord *); /* get ready for doing a lot of indexing. may be a nop */
|
|
void (*index_post)(struct _IBEXWord *);
|
|
|
|
void (*unindex_name)(struct _IBEXWord *, const char *name); /* unindex all entries for name */
|
|
gboolean (*contains_name)(struct _IBEXWord *, const char *name); /* index contains data for name */
|
|
GPtrArray *(*find)(struct _IBEXWord *, const char *word); /* returns all matches for word */
|
|
gboolean (*find_name)(struct _IBEXWord *, const char *name, const char *word); /* find if name contains word */
|
|
void (*add)(struct _IBEXWord *, const char *name, const char *word); /* adds a single word to name */
|
|
void (*add_list)(struct _IBEXWord *, const char *name, GPtrArray *words);/* adds a bunch of words to a given name */
|
|
};
|
|
|
|
struct _IBEXWord {
|
|
struct _IBEXWordClass *klass;
|
|
struct _IBEXStore *wordstore;
|
|
struct _IBEXIndex *wordindex;
|
|
struct _IBEXStore *namestore;
|
|
struct _IBEXIndex *nameindex;
|
|
|
|
struct _memcache *blocks;
|
|
|
|
/* word caching info (should probably be modularised) */
|
|
GHashTable *wordcache; /* word->struct _wordcache mapping */
|
|
struct _list wordnodes; /* LRU list of wordcache structures */
|
|
int wordcount; /* how much space used in cache */
|
|
int precount;
|
|
GHashTable *namecache; /* a list of names (only), cached for quick reference */
|
|
int nameinit;
|
|
};
|
|
|
|
|
|
/*struct _IBEXWord *ibex_create_word_index(struct _memcache *bc, blockid_t *wordroot, blockid_t *nameroot);*/
|
|
|
|
/* alternate implemenation */
|
|
struct _IBEXWord *ibex_create_word_index_mem(struct _memcache *bc, blockid_t *wordroot, blockid_t *nameroot);
|
|
|
|
#endif /* !_WORDINDEX_H */
|