#include "logerr.h"
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <sadie.h>
#include "Sadie_Index.h"
Go to the source code of this file.
Defines | |
#define | POSIX_THREADS 0 |
Turn off local flag for POSIX Threads support. | |
Typedefs | |
typedef Sad_property * | sad_propertyp_t |
property pointers. | |
typedef Sad_docitem * | sad_docitemp_t |
top-level item pointers. | |
typedef Sad_doc * | sad_docp_t |
top-level list pointers. | |
typedef Sad_propertyitem * | sad_propertyitemp_t |
property lists. | |
Functions | |
void | dispose_doclist (sad_doclistp_t thedoclist) |
Tear down a complete hash table. | |
sad_propertyp_t | make_property (sad_property_data_destructor_t yourdestruct, void *yourdata) |
Construct a new lower-level property. | |
sad_doclistp_t | make_doclist (int logsize) |
Create a new empty hash table. | |
int | sad_put_doc (sad_doclistp_t doclist, const char *dkey, int logpsize, const IMAGE *img) |
Insert a new top-level entry into the table. | |
int | sad_dispose_doc (sad_doclistp_t doclist, const char *dkey) |
Explicitly delete a top-level entry from the table. | |
int | sad_put_doc_property (sad_doclistp_t doclist, const char *dkey, const char *pkey, sad_property_data_destructor_t destruct, void *data) |
Add a new lower-level entry (property) to a existing top-level table entry. | |
void * | sad_get_doc_property (const sad_doclistp_t doclist, const char *dkey, const char *pkey) |
Given a hash table, a top-level entry key, and a sub-key, recover some data. |
SADIE represents images as structures that contain the pixel data and a limited range of other information. A simple in-memory database can however associate arbitrary metadata with the images, and track additional information not associated with a particular image. It is structured as a two-level hash table indexed by strings from which the Fowler/Noll/Vo (FNV) algorithm produces short hashes. See Landon Curt Noll's web site for extensive background and sample source code: http://www.isthe.com/chongo/tech/comp/fnv/ Each item at the upper level of the table will generally represent a single image that SADIE is displaying, thought of as a SADIE document. Nested within this at the lower level of the hierarchy will be the properties of the image. However the implementation is sufficiently general that you can stuff more or less anything that can be referenced by an opaque pointer and indexed by a sting into the table.
Definition in file Sadie_Index.c.
|
Tear down a complete hash table. We iterate through the entire table, reclaiming storage at all levels, but can't reset the pointer to it to NULL.
Definition at line 241 of file Sadie_Index.c. References Sad_doclist::buckets, Sad_doclist::lock, Sad_doclist::log2nbuckets, logerr_assert, LOGERR_DEBUG, LOGERR_FUNC, Sad_docitem::next, and POSIX_THREADS. Referenced by tclsadie_demolish_hashtable(). |
|
Create a new empty hash table. If we're in a multi-threaded environment we not only allocate storage for the table, but also initialize the lock used to serialize all accesses to it.
Definition at line 369 of file Sadie_Index.c. References Sad_doclist::buckets, Sad_doclist::lock, Sad_doclist::log2nbuckets, LOGERR_FUNC, and POSIX_THREADS. Referenced by Tcl_AppInit(). |
|
Construct a new lower-level property. We don't interpret this in any way, since all we have are opaque pointers to some kind of data structure & destructor about which we have no other information.
Definition at line 345 of file Sadie_Index.c. References Sad_property::data, Sad_property::datadestruct, logerr_assert, LOGERR_CRIT, and LOGERR_FUNC. Referenced by sad_put_doc_property(). |
|
Explicitly delete a top-level entry from the table. Given a hash table and the string key to one of the top-level entries, delete the entry, its data, and any of the lower level entries (properties). If locking is supported, we try to lock the entire hash table during the deletion.
Definition at line 596 of file Sadie_Index.c. References logerr_assert, LOGERR_CRIT, LOGERR_DEBUG, LOGERR_ERR, LOGERR_FUNC, Sad_docitem::next, and POSIX_THREADS. Referenced by Sadie_General_CloseCmd(). |
|
Given a hash table, a top-level entry key, and a sub-key, recover some data. The hash table is organized in two levels. We use the first key to find a top-level entry (generally representing the document or image), then use a second key to search the sub-table within it (generally its properties) and return the associated data (property value). If locking is supported, we try to lock the entire hash table during the retrieval.
Definition at line 842 of file Sadie_Index.c. References Sad_property::data, Sad_docitem::key, logerr_assert, LOGERR_CRIT, LOGERR_DEBUG, LOGERR_FUNC, Sad_docitem::next, and POSIX_THREADS. Referenced by CREATE_ROI(), Sadie_Classify_LvlSliceCmd(), Sadie_Classify_MaxLikeCmd(), and Sadie_Classify_MinDistCmd(). |
|
Insert a new top-level entry into the table. Given a table and a key string, we search for an existing entry with the same key. If it exists, we delete it (and all its lower-level entries), replacing it with a new empty entry. If it does not exist, we insert a new empty entry at the appropriate place. We use an FNV hash code to pick the initial hash bucket within which to search, then use ordinary string comparisons to match keys within the ordered list of entries within the bucket. If locking is supported, we try to lock the entire hash table during the insertion.
Definition at line 514 of file Sadie_Index.c. References Sad_doclist::buckets, Sad_doclist::lock, Sad_doclist::log2nbuckets, logerr_assert, LOGERR_CRIT, LOGERR_DEBUG, LOGERR_FUNC, Sad_docitem::next, and POSIX_THREADS. Referenced by Sadie_General_IndexImageCmd(). |
|
Add a new lower-level entry (property) to a existing top-level table entry. Given a table and a key string, we search for an existing entry with the same key. When found, we search beneath it for a second sub-key (property name). If this exists, we replace it with a new property, otherwise we insert the new entry at the appropriate place, including the key, data (property value), and data destructor function. Both searches use an FNV hash code to pick the initial hash bucket, then use ordinary string comparisons to match keys within the ordered list of entries within the buckets. If locking is supported, we try to lock the entire hash table during the insertion.
Definition at line 765 of file Sadie_Index.c. References Sad_docitem::key, logerr_assert, LOGERR_CRIT, LOGERR_DEBUG, LOGERR_FUNC, make_property(), Sad_docitem::next, and POSIX_THREADS. Referenced by CREATE_ROI(). |