tracker r2018 - in branches/indexer-split: . src/libtracker-common src/libtracker-db src/tracker-indexer src/trackerd tests/trackerd utils/qdbm
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2018 - in branches/indexer-split: . src/libtracker-common src/libtracker-db src/tracker-indexer src/trackerd tests/trackerd utils/qdbm
- Date: Thu, 7 Aug 2008 00:02:12 +0000 (UTC)
Author: mr
Date: Thu Aug 7 00:02:12 2008
New Revision: 2018
URL: http://svn.gnome.org/viewvc/tracker?rev=2018&view=rev
Log:
* src/libtracker-common/tracker-index-item.h: Added
TrackerSearchHit typedef here from the TrackerQueryTreeModule.
* configure.ac:
* src/libtracker-db/tracker-db-index-manager.[ch]:
* src/libtracker-db/tracker-db-index.[ch]:
* src/tracker-indexer/Makefile.am:
* src/tracker-indexer/tracker-indexer.c:
* src/tracker-indexer/tracker-main.c:
* src/trackerd/tracker-daemon.c:
* src/trackerd/tracker-db.[ch]:
* src/trackerd/tracker-dbus.[ch]:
* src/trackerd/tracker-keywords.c:
* src/trackerd/tracker-main.[ch]:
* src/trackerd/tracker-metadata.[ch]:
* src/trackerd/tracker-processor.c:
* src/trackerd/tracker-query-tree.[ch]:
* src/trackerd/tracker-search.[ch]:
* src/trackerd/tracker-xesam.[ch]: Moved tracker-index.[ch] in the
daemon and indexer into libtracker-db/tracker-db-index.[ch]
combining the APIs and code.
* tests/trackerd/tracker-index-test.c:
* tests/trackerd/Makefile.am: Disabled the index test, it is
broken.
* utils/qdbm/print-words.c:
* utils/qdbm/search-word.c: Fixed warnings.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/configure.ac
branches/indexer-split/src/libtracker-common/tracker-index-item.h
branches/indexer-split/src/libtracker-db/tracker-db-index-manager.c
branches/indexer-split/src/libtracker-db/tracker-db-index-manager.h
branches/indexer-split/src/libtracker-db/tracker-db-index.c
branches/indexer-split/src/libtracker-db/tracker-db-index.h
branches/indexer-split/src/tracker-indexer/Makefile.am
branches/indexer-split/src/tracker-indexer/tracker-indexer.c
branches/indexer-split/src/tracker-indexer/tracker-main.c
branches/indexer-split/src/trackerd/tracker-daemon.c
branches/indexer-split/src/trackerd/tracker-db.c
branches/indexer-split/src/trackerd/tracker-db.h
branches/indexer-split/src/trackerd/tracker-dbus.c
branches/indexer-split/src/trackerd/tracker-dbus.h
branches/indexer-split/src/trackerd/tracker-keywords.c
branches/indexer-split/src/trackerd/tracker-main.c
branches/indexer-split/src/trackerd/tracker-main.h
branches/indexer-split/src/trackerd/tracker-metadata.c
branches/indexer-split/src/trackerd/tracker-metadata.h
branches/indexer-split/src/trackerd/tracker-processor.c
branches/indexer-split/src/trackerd/tracker-query-tree.c
branches/indexer-split/src/trackerd/tracker-query-tree.h
branches/indexer-split/src/trackerd/tracker-search.c
branches/indexer-split/src/trackerd/tracker-search.h
branches/indexer-split/src/trackerd/tracker-xesam.c
branches/indexer-split/src/trackerd/tracker-xesam.h
branches/indexer-split/tests/trackerd/Makefile.am
branches/indexer-split/tests/trackerd/tracker-index-test.c
branches/indexer-split/utils/qdbm/print-words.c
branches/indexer-split/utils/qdbm/search-word.c
Modified: branches/indexer-split/configure.ac
==============================================================================
--- branches/indexer-split/configure.ac (original)
+++ branches/indexer-split/configure.ac Thu Aug 7 00:02:12 2008
@@ -769,8 +769,8 @@
# Dirty trick to compile the test for trackerd modules
# They are not part of a library... so i dont know how to link the test with them
#
-AC_CONFIG_LINKS(tests/trackerd/tracker-index.c:src/trackerd/tracker-index.c
- tests/trackerd/tracker-index.h:src/trackerd/tracker-index.h)
+AC_CONFIG_LINKS(tests/trackerd/tracker-db-index.c:src/libtracker-db/tracker-db-index.c
+ tests/trackerd/tracker-db-index.h:src/libtracker-db/tracker-db-index.h)
AC_OUTPUT
Modified: branches/indexer-split/src/libtracker-common/tracker-index-item.h
==============================================================================
--- branches/indexer-split/src/libtracker-common/tracker-index-item.h (original)
+++ branches/indexer-split/src/libtracker-common/tracker-index-item.h Thu Aug 7 00:02:12 2008
@@ -25,7 +25,7 @@
G_BEGIN_DECLS
-typedef struct {
+typedef struct {
/* Service ID number of the document */
guint32 id;
@@ -35,6 +35,12 @@
gint amalgamated;
} TrackerIndexItem;
+typedef struct {
+ guint32 service_id; /* Service ID of the document */
+ guint32 service_type_id; /* Service type ID of the document */
+ guint32 score; /* Ranking score */
+} TrackerSearchHit;
+
guint32 tracker_index_item_calc_amalgamated (gint service_type,
gint score);
guint8 tracker_index_item_get_service_type (TrackerIndexItem *details);
Modified: branches/indexer-split/src/libtracker-db/tracker-db-index-manager.c
==============================================================================
--- branches/indexer-split/src/libtracker-db/tracker-db-index-manager.c (original)
+++ branches/indexer-split/src/libtracker-db/tracker-db-index-manager.c Thu Aug 7 00:02:12 2008
@@ -31,36 +31,37 @@
#define MIN_BUCKET_DEFAULT 10
#define MAX_BUCKET_DEFAULT 20
-#define TRACKER_INDEX_FILENAME "index.db"
-#define TRACKER_INDEX_UPDATE_FILENAME "index-update.db"
+#define TRACKER_DB_INDEX_FILENAME "index.db"
+#define TRACKER_DB_INDEX_UPDATE_FILENAME "index-update.db"
#define MAX_INDEX_FILE_SIZE 2000000000
typedef struct {
- TrackerIndexType type;
- TrackerIndex *index;
- const gchar *file;
- const gchar *name;
- gchar *abs_filename;
-} TrackerIndexDefinition;
+ TrackerDBIndexType type;
+ TrackerDBIndex *index;
+ const gchar *file;
+ const gchar *name;
+ gchar *abs_filename;
+} TrackerDBIndexDefinition;
-static gboolean initialized;
+static gboolean initialized;
+static gchar *data_dir;
-static TrackerIndexDefinition indexes[] = {
- { TRACKER_INDEX_TYPE_INDEX,
+static TrackerDBIndexDefinition indexes[] = {
+ { TRACKER_DB_INDEX_TYPE_INDEX,
NULL,
- TRACKER_INDEX_FILENAME,
+ TRACKER_DB_INDEX_FILENAME,
"index",
NULL },
- { TRACKER_INDEX_TYPE_INDEX_UPDATE,
+ { TRACKER_DB_INDEX_TYPE_INDEX_UPDATE,
NULL,
- TRACKER_INDEX_UPDATE_FILENAME,
+ TRACKER_DB_INDEX_UPDATE_FILENAME,
"index-update",
NULL }
};
static gboolean
-has_tmp_merge_files (TrackerIndexType type)
+has_tmp_merge_files (TrackerDBIndexType type)
{
GFile *file;
GFileEnumerator *enumerator;
@@ -71,11 +72,11 @@
gchar *dirname;
gboolean found;
- if (type != TRACKER_INDEX_TYPE_INDEX) {
+ if (type != TRACKER_DB_INDEX_TYPE_INDEX) {
return FALSE;
}
- prefix = g_strconcat (indexes[TRACKER_INDEX_TYPE_INDEX].name, ".tmp", NULL);
+ prefix = g_strconcat (indexes[TRACKER_DB_INDEX_TYPE_INDEX].name, ".tmp", NULL);
dirname = g_path_get_dirname (indexes[type].abs_filename);
file = g_file_new_for_path (dirname);
@@ -131,17 +132,15 @@
}
gboolean
-tracker_index_manager_init (TrackerIndexManagerFlags flags,
- const gchar *data_dir,
- gint min_bucket,
- gint max_bucket)
+tracker_db_index_manager_init (TrackerDBIndexManagerFlags flags,
+ gint min_bucket,
+ gint max_bucket)
{
gchar *final_index_filename;
gchar *name;
gboolean need_reindex = FALSE;
guint i;
- g_return_val_if_fail (data_dir != NULL, FALSE);
g_return_val_if_fail (min_bucket >= 0, FALSE);
g_return_val_if_fail (max_bucket >= min_bucket, FALSE);
@@ -149,6 +148,12 @@
return TRUE;
}
+ g_message ("Setting index database locations");
+
+ data_dir = g_build_filename (g_get_user_cache_dir (),
+ "tracker",
+ NULL);
+
g_message ("Checking index directories exist");
g_mkdir_with_parents (data_dir, 00755);
@@ -169,7 +174,7 @@
g_message ("Merging old temporary indexes");
- i = TRACKER_INDEX_TYPE_INDEX;
+ i = TRACKER_DB_INDEX_TYPE_INDEX;
name = g_strconcat (indexes[i].name, "-final", NULL);
final_index_filename = g_build_filename (data_dir, name, NULL);
g_free (name);
@@ -188,7 +193,7 @@
/* Now we have cleaned up merge files, see if we are supposed
* to be reindexing.
*/
- if (flags & TRACKER_INDEX_MANAGER_FORCE_REINDEX || need_reindex) {
+ if (flags & TRACKER_DB_INDEX_MANAGER_FORCE_REINDEX || need_reindex) {
g_message ("Cleaning up index files for reindex");
for (i = 0; i < G_N_ELEMENTS (indexes); i++) {
@@ -199,9 +204,10 @@
g_message ("Creating index files, this may take a few moments...");
for (i = 0; i < G_N_ELEMENTS (indexes); i++) {
- indexes[i].index = tracker_index_new (indexes[i].abs_filename,
- min_bucket,
- max_bucket);
+ indexes[i].index = tracker_db_index_new (indexes[i].abs_filename,
+ min_bucket,
+ max_bucket,
+ flags & TRACKER_DB_INDEX_MANAGER_READONLY);
}
initialized = TRUE;
@@ -210,7 +216,7 @@
}
void
-tracker_index_manager_shutdown (void)
+tracker_db_index_manager_shutdown (void)
{
guint i;
@@ -226,23 +232,25 @@
indexes[i].abs_filename = NULL;
}
+ g_free (data_dir);
+
initialized = FALSE;
}
-TrackerIndex *
-tracker_index_manager_get_index (TrackerIndexType type)
+TrackerDBIndex *
+tracker_db_index_manager_get_index (TrackerDBIndexType type)
{
return indexes[type].index;
}
const gchar *
-tracker_index_manager_get_filename (TrackerIndexType type)
+tracker_db_index_manager_get_filename (TrackerDBIndexType type)
{
return indexes[type].abs_filename;
}
gboolean
-tracker_index_manager_are_indexes_too_big (void)
+tracker_db_index_manager_are_indexes_too_big (void)
{
gboolean too_big;
guint i;
Modified: branches/indexer-split/src/libtracker-db/tracker-db-index-manager.h
==============================================================================
--- branches/indexer-split/src/libtracker-db/tracker-db-index-manager.h (original)
+++ branches/indexer-split/src/libtracker-db/tracker-db-index-manager.h Thu Aug 7 00:02:12 2008
@@ -26,7 +26,7 @@
G_BEGIN_DECLS
-#include "tracker-index.h"
+#include "tracker-db-index.h"
typedef enum {
TRACKER_DB_INDEX_TYPE_INDEX,
@@ -35,16 +35,16 @@
typedef enum {
TRACKER_DB_INDEX_MANAGER_FORCE_REINDEX = 1 << 1,
+ TRACKER_DB_INDEX_MANAGER_READONLY = 1 << 2
} TrackerDBIndexManagerFlags;
-gboolean tracker_db_index_manager_init (TrackerDBIndexManagerFlags flags,
- const gchar *data_dir,
- gint min_bucket,
- gint max_bucket);
-void tracker_db_index_manager_shutdown (void);
-const gchar * tracker_db_index_manager_get_filename (TrackerDBIndexType index);
-TrackerIndex *tracker_db_index_manager_get_index (TrackerDBIndexType index);
-gboolean tracker_db_index_manager_are_indexes_too_big (void);
+gboolean tracker_db_index_manager_init (TrackerDBIndexManagerFlags flags,
+ gint min_bucket,
+ gint max_bucket);
+void tracker_db_index_manager_shutdown (void);
+const gchar * tracker_db_index_manager_get_filename (TrackerDBIndexType index);
+TrackerDBIndex *tracker_db_index_manager_get_index (TrackerDBIndexType index);
+gboolean tracker_db_index_manager_are_indexes_too_big (void);
G_END_DECLS
Modified: branches/indexer-split/src/libtracker-db/tracker-db-index.c
==============================================================================
--- branches/indexer-split/src/libtracker-db/tracker-db-index.c (original)
+++ branches/indexer-split/src/libtracker-db/tracker-db-index.c Thu Aug 7 00:02:12 2008
@@ -30,68 +30,73 @@
#include <libtracker-common/tracker-log.h>
#include <libtracker-common/tracker-file-utils.h>
-#include <libtracker-common/tracker-index-item.h>
#include <libtracker-db/tracker-db-manager.h>
-#include "tracker-index.h"
-#include "tracker-query-tree.h"
-#include "tracker-indexer-client.h"
+#include "tracker-db-index.h"
/* Size of free block pool of inverted index */
-#define MAX_HIT_BUFFER 480000
+#define MAX_HIT_BUFFER 480000
-#define TRACKER_INDEX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_INDEX, TrackerIndexPrivate))
+#define TRACKER_DB_INDEX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_DB_INDEX, TrackerDBIndexPrivate))
-typedef struct TrackerIndexPrivate TrackerIndexPrivate;
+typedef struct TrackerDBIndexPrivate TrackerDBIndexPrivate;
-struct TrackerIndexPrivate {
- DEPOT *word_index;
- GMutex *word_mutex;
+struct TrackerDBIndexPrivate {
+ /* From the daemon */
+ DEPOT *index;
+ GMutex *mutex;
- gchar *name;
- guint min_bucket;
- guint max_bucket;
+ guint min_bucket;
+ guint max_bucket;
- gboolean reload;
+ gboolean reload;
+ gboolean readonly;
+
+ /* From the indexer */
+ GHashTable *cache;
+ gchar *filename;
+ gint bucket_count;
};
-static void tracker_index_class_init (TrackerIndexClass *class);
-static void tracker_index_init (TrackerIndex *tree);
-static void tracker_index_finalize (GObject *object);
-static void tracker_index_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void tracker_index_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void tracker_db_index_class_init (TrackerDBIndexClass *class);
+static void tracker_db_index_init (TrackerDBIndex *tree);
+static void tracker_db_index_finalize (GObject *object);
+static void tracker_db_index_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void tracker_db_index_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void free_cache_values (GArray *array);
enum {
PROP_0,
- PROP_NAME,
+ PROP_FILENAME,
PROP_MIN_BUCKET,
PROP_MAX_BUCKET,
- PROP_RELOAD
+ PROP_RELOAD,
+ PROP_READONLY
};
-G_DEFINE_TYPE (TrackerIndex, tracker_index, G_TYPE_OBJECT)
+G_DEFINE_TYPE (TrackerDBIndex, tracker_db_index, G_TYPE_OBJECT)
static void
-tracker_index_class_init (TrackerIndexClass *klass)
+tracker_db_index_class_init (TrackerDBIndexClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = tracker_index_finalize;
- object_class->set_property = tracker_index_set_property;
- object_class->get_property = tracker_index_get_property;
+ object_class->finalize = tracker_db_index_finalize;
+ object_class->set_property = tracker_db_index_set_property;
+ object_class->get_property = tracker_db_index_get_property;
g_object_class_install_property (object_class,
- PROP_NAME,
- g_param_spec_string ("name",
- "Name",
- "Name",
+ PROP_FILENAME,
+ g_param_spec_string ("filename",
+ "Filename",
+ "Filename",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
@@ -113,73 +118,96 @@
1000000, /* FIXME MAX_GUINT ?? */
0,
G_PARAM_READWRITE));
+
g_object_class_install_property (object_class,
PROP_RELOAD,
g_param_spec_boolean ("reload",
"Reload the index file before read",
"Reload the index file before read",
TRUE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class,
+ PROP_READONLY,
+ g_param_spec_boolean ("readonly",
+ "Open the index for readonly purposes",
+ "Open the index for readonly purposes",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
- g_type_class_add_private (object_class, sizeof (TrackerIndexPrivate));
+ g_type_class_add_private (object_class, sizeof (TrackerDBIndexPrivate));
}
static void
-tracker_index_init (TrackerIndex *index)
+tracker_db_index_init (TrackerDBIndex *index)
{
- TrackerIndexPrivate *priv;
+ TrackerDBIndexPrivate *priv;
- priv = TRACKER_INDEX_GET_PRIVATE (index);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
- priv->word_mutex = g_mutex_new ();
+ priv->mutex = g_mutex_new ();
priv->reload = TRUE;
+
+ priv->cache = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) free_cache_values);
}
static void
-tracker_index_finalize (GObject *object)
+tracker_db_index_finalize (GObject *object)
{
- TrackerIndexPrivate *priv;
+ TrackerDBIndexPrivate *priv;
- priv = TRACKER_INDEX_GET_PRIVATE (object);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (object);
- g_mutex_lock (priv->word_mutex);
+ g_mutex_lock (priv->mutex);
- g_free (priv->name);
+ g_free (priv->filename);
- if (priv->word_index && !dpclose (priv->word_index)) {
- g_message ("Could not close index, %s",
- dperrmsg (dpecode));
+ if (g_hash_table_size (priv->cache) > 0) {
+ tracker_db_index_flush (TRACKER_DB_INDEX (object));
}
- g_mutex_unlock (priv->word_mutex);
- g_mutex_free (priv->word_mutex);
+ g_hash_table_destroy (priv->cache);
+
+ tracker_db_index_close (TRACKER_DB_INDEX (object));
- G_OBJECT_CLASS (tracker_index_parent_class)->finalize (object);
+ g_mutex_unlock (priv->mutex);
+ g_mutex_free (priv->mutex);
+
+ G_OBJECT_CLASS (tracker_db_index_parent_class)->finalize (object);
}
static void
-tracker_index_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+tracker_db_index_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
switch (prop_id) {
- case PROP_NAME:
- tracker_index_set_name (TRACKER_INDEX (object),
- g_value_get_string (value));
+ case PROP_FILENAME:
+ tracker_db_index_set_filename (TRACKER_DB_INDEX (object),
+ g_value_get_string (value));
break;
case PROP_MIN_BUCKET:
- tracker_index_set_min_bucket (TRACKER_INDEX (object),
+ tracker_db_index_set_min_bucket (TRACKER_DB_INDEX (object),
g_value_get_int (value));
break;
case PROP_MAX_BUCKET:
- tracker_index_set_max_bucket (TRACKER_INDEX (object),
+ tracker_db_index_set_max_bucket (TRACKER_DB_INDEX (object),
g_value_get_int (value));
break;
case PROP_RELOAD:
- tracker_index_set_reload (TRACKER_INDEX (object),
+ tracker_db_index_set_reload (TRACKER_DB_INDEX (object),
g_value_get_boolean (value));
break;
+ case PROP_READONLY:
+ tracker_db_index_set_readonly (TRACKER_DB_INDEX (object),
+ g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -187,18 +215,18 @@
}
static void
-tracker_index_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+tracker_db_index_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- TrackerIndexPrivate *priv;
+ TrackerDBIndexPrivate *priv;
- priv = TRACKER_INDEX_GET_PRIVATE (object);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (object);
switch (prop_id) {
- case PROP_NAME:
- g_value_set_string (value, priv->name);
+ case PROP_FILENAME:
+ g_value_set_string (value, priv->filename);
break;
case PROP_MIN_BUCKET:
g_value_set_int (value, priv->min_bucket);
@@ -209,40 +237,74 @@
case PROP_RELOAD:
g_value_set_boolean (value, priv->reload);
break;
+ case PROP_READONLY:
+ g_value_set_boolean (value, priv->readonly);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
+static void
+free_cache_values (GArray *array)
+{
+ g_array_free (array, TRUE);
+}
+
+TrackerDBIndex *
+tracker_db_index_new (const gchar *filename,
+ gint min_bucket,
+ gint max_bucket,
+ gboolean readonly)
+{
+ TrackerDBIndex *index;
+
+ g_return_val_if_fail (filename != NULL, NULL);
+ g_return_val_if_fail (min_bucket > 1, NULL);
+ g_return_val_if_fail (min_bucket > 1, NULL);
+ g_return_val_if_fail (min_bucket < max_bucket, NULL);
+
+ index = g_object_new (TRACKER_TYPE_DB_INDEX,
+ "filename", filename,
+ "min-bucket", min_bucket,
+ "max-bucket", max_bucket,
+ "readonly", readonly,
+ NULL);
+
+ tracker_db_index_open (index);
+
+ return index;
+}
+
void
-tracker_index_set_name (TrackerIndex *index,
- const gchar *name)
+tracker_db_index_set_filename (TrackerDBIndex *index,
+ const gchar *filename)
{
- TrackerIndexPrivate *priv;
+ TrackerDBIndexPrivate *priv;
- g_return_if_fail (TRACKER_IS_INDEX (index));
+ g_return_if_fail (TRACKER_IS_DB_INDEX (index));
- priv = TRACKER_INDEX_GET_PRIVATE (index);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
- if (priv->name) {
- g_free (priv->name);
+ if (priv->filename) {
+ g_free (priv->filename);
}
- priv->name = g_strdup (name);
+ priv->filename = g_strdup (filename);
- g_object_notify (G_OBJECT (index), "name");
+ g_object_notify (G_OBJECT (index), "filename");
}
void
-tracker_index_set_min_bucket (TrackerIndex *index,
- gint min_bucket)
+tracker_db_index_set_min_bucket (TrackerDBIndex *index,
+ gint min_bucket)
{
- TrackerIndexPrivate *priv;
+ TrackerDBIndexPrivate *priv;
- g_return_if_fail (TRACKER_IS_INDEX (index));
+ g_return_if_fail (TRACKER_IS_DB_INDEX (index));
- priv = TRACKER_INDEX_GET_PRIVATE (index);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
priv->min_bucket = min_bucket;
@@ -250,14 +312,14 @@
}
void
-tracker_index_set_max_bucket (TrackerIndex *index,
- gint max_bucket)
+tracker_db_index_set_max_bucket (TrackerDBIndex *index,
+ gint max_bucket)
{
- TrackerIndexPrivate *priv;
+ TrackerDBIndexPrivate *priv;
- g_return_if_fail (TRACKER_IS_INDEX (index));
+ g_return_if_fail (TRACKER_IS_DB_INDEX (index));
- priv = TRACKER_INDEX_GET_PRIVATE (index);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
priv->max_bucket = max_bucket;
@@ -265,61 +327,88 @@
}
void
-tracker_index_set_reload (TrackerIndex *index,
- gboolean reload)
+tracker_db_index_set_reload (TrackerDBIndex *index,
+ gboolean reload)
{
- TrackerIndexPrivate *priv;
+ TrackerDBIndexPrivate *priv;
- g_return_if_fail (TRACKER_IS_INDEX (index));
+ g_return_if_fail (TRACKER_IS_DB_INDEX (index));
- priv = TRACKER_INDEX_GET_PRIVATE (index);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
priv->reload = reload;
g_object_notify (G_OBJECT (index), "reload");
}
+void
+tracker_db_index_set_readonly (TrackerDBIndex *index,
+ gboolean readonly)
+{
+ TrackerDBIndexPrivate *priv;
+
+ g_return_if_fail (TRACKER_IS_DB_INDEX (index));
+
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
+
+ priv->readonly = readonly;
+
+ g_object_notify (G_OBJECT (index), "readonly");
+}
+
gboolean
-tracker_index_get_reload (TrackerIndex *index)
+tracker_db_index_get_reload (TrackerDBIndex *index)
{
- TrackerIndexPrivate *priv;
+ TrackerDBIndexPrivate *priv;
- g_return_val_if_fail (TRACKER_IS_INDEX (index), FALSE);
+ g_return_val_if_fail (TRACKER_IS_DB_INDEX (index), FALSE);
- priv = TRACKER_INDEX_GET_PRIVATE (index);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
return priv->reload;
}
+gboolean
+tracker_db_index_get_readonly (TrackerDBIndex *index)
+{
+ TrackerDBIndexPrivate *priv;
+
+ g_return_val_if_fail (TRACKER_IS_DB_INDEX (index), TRUE);
+
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
+
+ return priv->readonly;
+}
+
static inline gboolean
-has_word (TrackerIndex *index,
- const gchar *word)
+has_word (TrackerDBIndex *index,
+ const gchar *word)
{
- TrackerIndexPrivate *priv;
- gchar buffer[32];
- gint count;
-
- priv = TRACKER_INDEX_GET_PRIVATE (index);
-
- g_mutex_lock (priv->word_mutex);
- count = dpgetwb (priv->word_index, word, -1, 0, 32, buffer);
- g_mutex_unlock (priv->word_mutex);
+ TrackerDBIndexPrivate *priv;
+ gchar buffer[32];
+ gint count;
+
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
+
+ g_mutex_lock (priv->mutex);
+ count = dpgetwb (priv->index, word, -1, 0, 32, buffer);
+ g_mutex_unlock (priv->mutex);
return count > 7;
}
static inline gint
-count_hit_size_for_word (TrackerIndex *index,
+count_hit_size_for_word (TrackerDBIndex *index,
const gchar *word)
{
- TrackerIndexPrivate *priv;
+ TrackerDBIndexPrivate *priv;
gint tsiz;
- priv = TRACKER_INDEX_GET_PRIVATE (index);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
- g_mutex_lock (priv->word_mutex);
- tsiz = dpvsiz (priv->word_index, word, -1);
- g_mutex_unlock (priv->word_mutex);
+ g_mutex_lock (priv->mutex);
+ tsiz = dpvsiz (priv->index, word, -1);
+ g_mutex_unlock (priv->mutex);
return tsiz;
}
@@ -417,8 +506,9 @@
}
static gint
-count_hits_for_word (TrackerIndex *index,
- const gchar *str) {
+count_hits_for_word (TrackerDBIndex *index,
+ const gchar *str)
+{
gint tsiz;
gint hits = 0;
@@ -435,48 +525,226 @@
return hits;
}
-static inline void
-open_index (TrackerIndex *index)
+static gboolean
+check_index_is_up_to_date (TrackerDBIndex *index)
+{
+ TrackerDBIndexPrivate *priv;
+
+ g_return_val_if_fail (TRACKER_IS_DB_INDEX (index), FALSE);
+
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
+
+ g_mutex_lock (priv->mutex);
+
+ if (priv->reload) {
+ g_debug ("Reloading index:'%s'", priv->filename);
+
+ if (priv->index) {
+ g_debug ("Closing index:'%s'", priv->filename);
+
+ dpclose (priv->index);
+ priv->index = NULL;
+ }
+ }
+
+ if (!priv->index) {
+ tracker_db_index_open (index);
+ }
+
+ g_mutex_unlock (priv->mutex);
+
+ return !priv->reload;
+}
+
+/* Use for deletes or updates of multiple entities when they are not
+ * new.
+ */
+static gboolean
+indexer_update_word (DEPOT *index,
+ const gchar *word,
+ GArray *new_hits)
+{
+ TrackerIndexItem *new_hit, *previous_hits;
+ gboolean write_back = FALSE, edited = FALSE;
+ gint old_hit_count = 0;
+ GArray *pending_hits = NULL;
+ gboolean result;
+ gint tsiz, i, score;
+ guint j;
+ gint k;
+
+ g_return_val_if_fail (index != NULL, FALSE);
+ g_return_val_if_fail (word != NULL, FALSE);
+ g_return_val_if_fail (new_hits != NULL, FALSE);
+
+ previous_hits = (TrackerIndexItem *) dpget (index,
+ word,
+ -1,
+ 0,
+ MAX_HIT_BUFFER,
+ &tsiz);
+
+ /* New word in the index */
+ if (previous_hits == NULL) {
+ result = dpput (index,
+ word, -1,
+ (char *) new_hits->data,
+ new_hits->len * sizeof (TrackerIndexItem),
+ DP_DCAT);
+
+ if (!result) {
+ g_warning ("Could not store word:'%s'", word);
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ /* Word already exists */
+ old_hit_count = tsiz / sizeof (TrackerIndexItem);
+
+ for (j = 0; j < new_hits->len; j++) {
+ new_hit = &g_array_index (new_hits, TrackerIndexItem, j);
+ edited = FALSE;
+
+ for (i = 0; i < old_hit_count; i++) {
+ if (previous_hits[i].id == new_hit->id) {
+ write_back = TRUE;
+
+ /* NB the paramter score can be negative */
+ score = tracker_index_item_get_score (&previous_hits[i]);
+ score += tracker_index_item_get_score (new_hit);
+
+ /* Check for deletion */
+ if (score < 1) {
+ /* Shift all subsequent records in array down one place */
+ for (k = i + 1; k < old_hit_count; k++) {
+ previous_hits[k - 1] = previous_hits[k];
+ }
+
+ old_hit_count--;
+ } else {
+ guint32 service_type;
+
+ service_type = tracker_index_item_get_service_type (&previous_hits[i]);
+ previous_hits[i].amalgamated =
+ tracker_index_item_calc_amalgamated (service_type, score);
+ }
+
+ edited = TRUE;
+ break;
+ }
+ }
+
+ /* Add hits that could not be updated directly here so
+ * they can be appended later
+ */
+ if (!edited) {
+ if (!pending_hits) {
+ pending_hits = g_array_new (FALSE, TRUE, sizeof (TrackerIndexItem));
+ }
+
+ g_array_append_val (pending_hits, *new_hit);
+ }
+ }
+
+ /* Write back if we have modded anything */
+ if (write_back) {
+ /* If the word has no hits, remove it! Otherwise
+ * overwrite the value with the new hits array
+ */
+ if (old_hit_count < 1) {
+ dpout (index, word, -1);
+ } else {
+ dpput (index,
+ word, -1,
+ (char *) previous_hits,
+ old_hit_count * sizeof (TrackerIndexItem),
+ DP_DOVER);
+ }
+ }
+
+ /* Append new occurences */
+ if (pending_hits) {
+ dpput (index,
+ word, -1,
+ (char*) pending_hits->data,
+ pending_hits->len * sizeof (TrackerIndexItem),
+ DP_DCAT);
+ g_array_free (pending_hits, TRUE);
+ }
+
+ g_free (previous_hits);
+
+ return TRUE;
+}
+
+static gboolean
+cache_flush_foreach (gpointer key,
+ gpointer value,
+ gpointer user_data)
{
- TrackerIndexPrivate *priv;
- gint bucket_count;
- gint rec_count;
+ GArray *array;
+ DEPOT *index;
+ gchar *word;
+
+ word = (gchar *) key;
+ array = (GArray *) value;
+ index = (DEPOT *) user_data;
+
+ /* Mark element for removal if succesfull insertion */
+ return indexer_update_word (index, word, array);
+}
- g_return_if_fail (TRACKER_IS_INDEX (index));
+gboolean
+tracker_db_index_open (TrackerDBIndex *index)
+{
+ TrackerDBIndexPrivate *priv;
+ gint flags;
+ gint bucket_count;
+ gint rec_count;
- priv = TRACKER_INDEX_GET_PRIVATE (index);
+ g_return_val_if_fail (TRACKER_IS_DB_INDEX (index), FALSE);
- g_return_if_fail (priv->name);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
- g_message ("Opening index:'%s'", priv->name);
+ g_return_val_if_fail (priv->filename != NULL, FALSE);
+
+ g_message ("Opening index:'%s'", priv->filename);
+
+ if (priv->readonly) {
+ flags = DP_OREADER | DP_ONOLCK;
+ } else {
+ flags = DP_OWRITER | DP_OCREAT | DP_ONOLCK;
+ }
- priv->word_index = dpopen (priv->name,
- DP_OREADER | DP_ONOLCK,
- priv->max_bucket);
+ priv->index = dpopen (priv->filename,
+ flags,
+ priv->max_bucket);
- if (!priv->word_index) {
+ if (!priv->index) {
g_debug ("Index doesnt exists or was not closed properly, index:'%s', %s",
- priv->name,
+ priv->filename,
dperrmsg (dpecode));
- if (g_file_test (priv->name, G_FILE_TEST_EXISTS)) {
- if (dprepair (priv->name)) {
- priv->word_index = dpopen (priv->name,
- DP_OREADER | DP_ONOLCK,
- priv->max_bucket);
+ if (g_file_test (priv->filename, G_FILE_TEST_EXISTS)) {
+ if (dprepair (priv->filename)) {
+ priv->index = dpopen (priv->filename,
+ flags,
+ priv->max_bucket);
} else {
g_critical ("Corrupted index file %s.",
- priv->name);
+ priv->filename);
}
}
}
- if (priv->word_index) {
- dpsetalign (priv->word_index, 8);
+ if (priv->index) {
+ dpsetalign (priv->index, 8);
/* Reoptimize database if bucket count < rec count */
- bucket_count = dpbnum (priv->word_index);
- rec_count = dprnum (priv->word_index);
+ bucket_count = dpbnum (priv->index);
+ rec_count = dprnum (priv->index);
g_debug ("Bucket count (max is %d) is %d and record count is %d",
priv->max_bucket,
@@ -485,91 +753,88 @@
priv->reload = FALSE;
- return;
+ return TRUE;
}
priv->reload = TRUE;
+
+ return FALSE;
}
-static gboolean
-check_index_is_up_to_date (TrackerIndex *index)
+gboolean
+tracker_db_index_close (TrackerDBIndex *index)
{
- TrackerIndexPrivate *priv;
-
- g_return_val_if_fail (TRACKER_IS_INDEX (index), FALSE);
-
- priv = TRACKER_INDEX_GET_PRIVATE (index);
+ TrackerDBIndexPrivate *priv;
- g_mutex_lock (priv->word_mutex);
+ g_return_val_if_fail (TRACKER_IS_DB_INDEX (index), FALSE);
- if (priv->reload) {
- g_debug ("Reloading index:'%s'", priv->name);
-
- if (priv->word_index) {
- g_debug ("Closing index:'%s'", priv->name);
-
- dpclose (priv->word_index);
- priv->word_index = NULL;
- }
- }
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
- if (!priv->word_index) {
- open_index (index);
+ if (priv->index && !dpclose (priv->index)) {
+ g_message ("Could not close index, %s",
+ dperrmsg (dpecode));
+ return FALSE;
}
- g_mutex_unlock (priv->word_mutex);
-
- return !priv->reload;
+ return TRUE;
}
-TrackerIndex *
-tracker_index_new (const gchar *name,
- gint min_bucket,
- gint max_bucket)
+guint
+tracker_db_index_flush (TrackerDBIndex *index)
{
- TrackerIndex *index;
+ TrackerDBIndexPrivate *priv;
+ guint size;
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (min_bucket > 1, NULL);
- g_return_val_if_fail (min_bucket > 1, NULL);
- g_return_val_if_fail (min_bucket < max_bucket, NULL);
+ g_return_val_if_fail (TRACKER_IS_DB_INDEX (index), 0);
- index = g_object_new (TRACKER_TYPE_INDEX,
- "name", name,
- "min-bucket", min_bucket,
- "max-bucket", max_bucket,
- NULL);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
- return index;
+ if (!priv->index) {
+ g_warning ("Flushing index while closed, "
+ "this indicates a problem in the software");
+
+ if (!tracker_db_index_open (index)) {
+ return 0;
+ }
+ }
+
+ size = g_hash_table_size (priv->cache);
+ g_debug ("Flushing index with %d items in cache", size);
+
+ g_hash_table_foreach_remove (priv->cache,
+ cache_flush_foreach,
+ priv->index);
+
+ return size;
}
guint32
-tracker_index_get_size (TrackerIndex *index)
+tracker_db_index_get_size (TrackerDBIndex *index)
{
- TrackerIndexPrivate *priv;
+ TrackerDBIndexPrivate *priv;
guint32 size;
- g_return_val_if_fail (TRACKER_IS_INDEX (index), 0);
+ g_return_val_if_fail (TRACKER_IS_DB_INDEX (index), 0);
if (!check_index_is_up_to_date (index)) {
return 0;
}
- priv = TRACKER_INDEX_GET_PRIVATE (index);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
- g_mutex_lock (priv->word_mutex);
- dpfsiz (priv->word_index);
- g_mutex_unlock (priv->word_mutex);
+ g_mutex_lock (priv->mutex);
+ dpfsiz (priv->index);
+ g_mutex_unlock (priv->mutex);
return size;
}
gchar *
-tracker_index_get_suggestion (TrackerIndex *index,
- const gchar *term,
- gint maxdist)
+tracker_db_index_get_suggestion (TrackerDBIndex *index,
+ const gchar *term,
+ gint maxdist)
{
- TrackerIndexPrivate *priv;
+ TrackerDBIndexPrivate *priv;
gchar *str;
gint dist;
gchar *winner_str;
@@ -577,7 +842,7 @@
gint hits;
GTimeVal start, current;
- g_return_val_if_fail (TRACKER_IS_INDEX (index), NULL);
+ g_return_val_if_fail (TRACKER_IS_DB_INDEX (index), NULL);
g_return_val_if_fail (term != NULL, NULL);
g_return_val_if_fail (maxdist >= 0, NULL);
@@ -585,18 +850,18 @@
return NULL;
}
- priv = TRACKER_INDEX_GET_PRIVATE (index);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
winner_str = g_strdup (term);
winner_dist = G_MAXINT; /* Initialize to the worst case */
- g_mutex_lock (priv->word_mutex);
- dpiterinit (priv->word_index);
+ g_mutex_lock (priv->mutex);
+ dpiterinit (priv->index);
g_get_current_time (&start);
- str = dpiternext (priv->word_index, NULL);
- g_mutex_unlock (priv->word_mutex);
+ str = dpiternext (priv->index, NULL);
+ g_mutex_unlock (priv->mutex);
while (str != NULL) {
dist = levenshtein (term, str, 0);
@@ -631,34 +896,34 @@
break;
}
- g_mutex_lock (priv->word_mutex);
- str = dpiternext (priv->word_index, NULL);
- g_mutex_unlock (priv->word_mutex);
+ g_mutex_lock (priv->mutex);
+ str = dpiternext (priv->index, NULL);
+ g_mutex_unlock (priv->mutex);
}
return winner_str;
}
TrackerIndexItem *
-tracker_index_get_word_hits (TrackerIndex *index,
- const gchar *word,
- guint *count)
+tracker_db_index_get_word_hits (TrackerDBIndex *index,
+ const gchar *word,
+ guint *count)
{
- TrackerIndexPrivate *priv;
+ TrackerDBIndexPrivate *priv;
TrackerIndexItem *details;
gint tsiz;
gchar *tmp;
- g_return_val_if_fail (TRACKER_IS_INDEX (index), NULL);
+ g_return_val_if_fail (TRACKER_IS_DB_INDEX (index), NULL);
g_return_val_if_fail (word != NULL, NULL);
- priv = TRACKER_INDEX_GET_PRIVATE (index);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
if (!check_index_is_up_to_date (index)) {
return NULL;
}
- g_mutex_lock (priv->word_mutex);
+ g_mutex_lock (priv->mutex);
details = NULL;
@@ -666,7 +931,7 @@
*count = 0;
}
- if ((tmp = dpget (priv->word_index, word, -1, 0, MAX_HIT_BUFFER, &tsiz)) != NULL) {
+ if ((tmp = dpget (priv->index, word, -1, 0, MAX_HIT_BUFFER, &tsiz)) != NULL) {
if (tsiz >= (gint) sizeof (TrackerIndexItem)) {
details = (TrackerIndexItem *) tmp;
@@ -676,11 +941,73 @@
}
}
- g_mutex_unlock (priv->word_mutex);
+ g_mutex_unlock (priv->mutex);
return details;
}
+void
+tracker_db_index_add_word (TrackerDBIndex *index,
+ const gchar *word,
+ guint32 service_id,
+ gint service_type,
+ gint weight)
+{
+ TrackerDBIndexPrivate *priv;
+ TrackerIndexItem elem;
+ TrackerIndexItem *current;
+ GArray *array;
+ guint i, new_score;
+
+ g_return_if_fail (TRACKER_IS_DB_INDEX (index));
+ g_return_if_fail (word != NULL);
+
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
+
+ elem.id = service_id;
+ elem.amalgamated = tracker_index_item_calc_amalgamated (service_type, weight);
+
+ array = g_hash_table_lookup (priv->cache, word);
+
+ if (!array) {
+ /* Create the array if it didn't exist (first time we
+ * find the word)
+ */
+ array = g_array_new (FALSE, TRUE, sizeof (TrackerIndexItem));
+ g_hash_table_insert (priv->cache, g_strdup (word), array);
+ g_array_append_val (array, elem);
+ return;
+ }
+
+ /* It is not the first time we find the word */
+ for (i = 0; i < array->len; i++) {
+ current = &g_array_index (array, TrackerIndexItem, i);
+
+ if (current->id == service_id) {
+ /* The word was already found in the same
+ * service_id (file), increase score
+ */
+ new_score = tracker_index_item_get_score (current) + weight;
+ if (new_score < 1) {
+ array = g_array_remove_index (array, i);
+ if (array->len == 0) {
+ g_hash_table_remove (priv->cache, word);
+ }
+ } else {
+ guint32 service_type;
+
+ service_type = tracker_index_item_get_service_type (current);
+ current->amalgamated = tracker_index_item_calc_amalgamated (service_type, new_score);
+ }
+
+ return;
+ }
+ }
+
+ /* First time in the file */
+ g_array_append_val (array, elem);
+}
+
/*
* UNUSED
*
@@ -688,16 +1015,16 @@
* TrackerSearchHit structs.
*/
gboolean
-tracker_index_remove_dud_hits (TrackerIndex *index,
- const gchar *word,
- GSList *dud_list)
+tracker_db_index_remove_dud_hits (TrackerDBIndex *index,
+ const gchar *word,
+ GSList *dud_list)
{
- TrackerIndexPrivate *priv;
+ TrackerDBIndexPrivate *priv;
gchar *tmp;
gint tsiz;
g_return_val_if_fail (index, FALSE);
- g_return_val_if_fail (priv->word_index, FALSE);
+ g_return_val_if_fail (priv->index, FALSE);
g_return_val_if_fail (word, FALSE);
g_return_val_if_fail (dud_list, FALSE);
@@ -705,17 +1032,17 @@
return TRUE;
}
- priv = TRACKER_INDEX_GET_PRIVATE (index);
+ priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
/* Check if existing record is there */
- g_mutex_lock (priv->word_mutex);
- tmp = dpget (priv->word_index,
+ g_mutex_lock (priv->mutex);
+ tmp = dpget (priv->index,
word,
-1,
0,
MAX_HIT_BUFFER,
&tsiz);
- g_mutex_unlock (priv->word_mutex);
+ g_mutex_unlock (priv->mutex);
if (!tmp) {
return FALSE;
@@ -754,9 +1081,9 @@
}
}
- g_mutex_lock (priv->word_mutex);
- dpput (priv->word_index, word, -1, (gchar *) details, tsiz, DP_DOVER);
- g_mutex_unlock (priv->word_mutex);
+ g_mutex_lock (priv->mutex);
+ dpput (priv->index, word, -1, (gchar *) details, tsiz, DP_DOVER);
+ g_mutex_unlock (priv->mutex);
g_free (tmp);
@@ -767,4 +1094,3 @@
return FALSE;
}
-
Modified: branches/indexer-split/src/libtracker-db/tracker-db-index.h
==============================================================================
--- branches/indexer-split/src/libtracker-db/tracker-db-index.h (original)
+++ branches/indexer-split/src/libtracker-db/tracker-db-index.h Thu Aug 7 00:02:12 2008
@@ -19,8 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __TRACKERD_INDEX_H__
-#define __TRACKERD_INDEX_H__
+#ifndef __TRACKER_DB_INDEX_H__
+#define __TRACKER_DB_INDEX_H__
G_BEGIN_DECLS
@@ -28,49 +28,65 @@
#include <libtracker-common/tracker-index-item.h>
-#define TRACKER_TYPE_INDEX (tracker_index_get_type())
-#define TRACKER_INDEX(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_INDEX, TrackerIndex))
-#define TRACKER_INDEX_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_INDEX, TrackerIndexClass))
-#define TRACKER_IS_INDEX(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_INDEX))
-#define TRACKER_IS_INDEX_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), TRACKER_TYPE_INDEX))
-#define TRACKER_INDEX_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_INDEX, TrackerIndexClass))
-
-typedef struct TrackerIndex TrackerIndex;
-typedef struct TrackerIndexClass TrackerIndexClass;
-typedef struct TrackerIndexWordDetails TrackerIndexWordDetails;
+#define TRACKER_TYPE_DB_INDEX (tracker_db_index_get_type())
+#define TRACKER_DB_INDEX(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_DB_INDEX, TrackerDBIndex))
+#define TRACKER_DB_INDEX_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_DB_INDEX, TrackerDBIndexClass))
+#define TRACKER_IS_DB_INDEX(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_DB_INDEX))
+#define TRACKER_IS_DB_INDEX_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), TRACKER_TYPE_DB_INDEX))
+#define TRACKER_DB_INDEX_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_DB_INDEX, TrackerDBIndexClass))
+
+typedef struct TrackerDBIndex TrackerDBIndex;
+typedef struct TrackerDBIndexClass TrackerDBIndexClass;
+typedef struct TrackerDBIndexWordDetails TrackerDBIndexWordDetails;
-struct TrackerIndex {
+struct TrackerDBIndex {
GObject parent;
};
-struct TrackerIndexClass {
+struct TrackerDBIndexClass {
GObjectClass parent_class;
};
-GType tracker_index_get_type (void);
-TrackerIndex * tracker_index_new (const gchar *name,
- gint min_bucket,
- gint max_bucket);
-void tracker_index_set_name (TrackerIndex *index,
- const gchar *name);
-void tracker_index_set_min_bucket (TrackerIndex *index,
- gint min_bucket);
-void tracker_index_set_max_bucket (TrackerIndex *index,
- gint max_bucket);
-void tracker_index_set_reload (TrackerIndex *index,
- gboolean reload);
-gboolean tracker_index_get_reload (TrackerIndex *index);
-guint32 tracker_index_get_size (TrackerIndex *index);
-char * tracker_index_get_suggestion (TrackerIndex *index,
- const gchar *term,
- gint maxdist);
-TrackerIndexItem *tracker_index_get_word_hits (TrackerIndex *index,
- const gchar *word,
- guint *count);
-gboolean tracker_index_remove_dud_hits (TrackerIndex *index,
- const gchar *word,
- GSList *dud_list);
+GType tracker_db_index_get_type (void);
+TrackerDBIndex * tracker_db_index_new (const gchar *filename,
+ gint min_bucket,
+ gint max_bucket,
+ gboolean readonly);
+void tracker_db_index_set_filename (TrackerDBIndex *index,
+ const gchar *filename);
+void tracker_db_index_set_min_bucket (TrackerDBIndex *index,
+ gint min_bucket);
+void tracker_db_index_set_max_bucket (TrackerDBIndex *index,
+ gint max_bucket);
+void tracker_db_index_set_reload (TrackerDBIndex *index,
+ gboolean reload);
+void tracker_db_index_set_readonly (TrackerDBIndex *index,
+ gboolean readonly);
+gboolean tracker_db_index_get_reload (TrackerDBIndex *index);
+gboolean tracker_db_index_get_readonly (TrackerDBIndex *index);
+
+/* Open/Close/Flush */
+gboolean tracker_db_index_open (TrackerDBIndex *index);
+gboolean tracker_db_index_close (TrackerDBIndex *index);
+guint tracker_db_index_flush (TrackerDBIndex *index);
+
+/* Using the index */
+guint32 tracker_db_index_get_size (TrackerDBIndex *index);
+char * tracker_db_index_get_suggestion (TrackerDBIndex *index,
+ const gchar *term,
+ gint maxdist);
+TrackerIndexItem *tracker_db_index_get_word_hits (TrackerDBIndex *index,
+ const gchar *word,
+ guint *count);
+void tracker_db_index_add_word (TrackerDBIndex *index,
+ const gchar *word,
+ guint32 service_id,
+ gint service_type,
+ gint weight);
+gboolean tracker_db_index_remove_dud_hits (TrackerDBIndex *index,
+ const gchar *word,
+ GSList *dud_list);
G_END_DECLS
-#endif /* __TRACKERD_INDEX_H__ */
+#endif /* __TRACKER_DB_INDEX_H__ */
Modified: branches/indexer-split/src/tracker-indexer/Makefile.am
==============================================================================
--- branches/indexer-split/src/tracker-indexer/Makefile.am (original)
+++ branches/indexer-split/src/tracker-indexer/Makefile.am Thu Aug 7 00:02:12 2008
@@ -17,8 +17,6 @@
tracker-dbus.h \
tracker-ioprio.c \
tracker-ioprio.h \
- tracker-index.c \
- tracker-index.h \
tracker-indexer.c \
tracker-indexer.h \
tracker-indexer-db.c \
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.c Thu Aug 7 00:02:12 2008
@@ -64,6 +64,7 @@
#include <libtracker-common/tracker-utils.h>
#include <libtracker-db/tracker-db-manager.h>
+#include <libtracker-db/tracker-db-index-manager.h>
#include <libtracker-db/tracker-db-interface-sqlite.h>
#include "tracker-indexer.h"
@@ -105,7 +106,7 @@
gchar *db_dir;
- TrackerIndex *index;
+ TrackerDBIndex *index;
TrackerDBInterface *file_metadata;
TrackerDBInterface *file_contents;
@@ -142,7 +143,7 @@
};
struct MetadataForeachData {
- TrackerIndex *index;
+ TrackerDBIndex *index;
TrackerLanguage *language;
TrackerConfig *config;
@@ -275,7 +276,7 @@
stop_transaction (indexer);
}
- tracker_index_flush (indexer->private->index);
+ tracker_db_index_flush (indexer->private->index);
signal_status (indexer, "flush");
return FALSE;
@@ -400,7 +401,7 @@
g_object_unref (priv->language);
g_object_unref (priv->config);
- tracker_index_free (priv->index);
+ g_object_unref (priv->index);
g_free (priv->db_dir);
@@ -629,8 +630,8 @@
tracker_indexer_init (TrackerIndexer *indexer)
{
TrackerIndexerPrivate *priv;
+ TrackerDBIndex *index;
gint low_disk_space_limit;
- gchar *index_file;
GList *l;
priv = indexer->private = TRACKER_INDEXER_GET_PRIVATE (indexer);
@@ -683,10 +684,8 @@
}
/* Set up indexer */
- index_file = g_build_filename (priv->db_dir, "file-index.db", NULL);
- priv->index = tracker_index_new (index_file,
- tracker_config_get_max_bucket_count (priv->config));
- g_free (index_file);
+ index = tracker_db_index_manager_get_index (TRACKER_DB_INDEX_TYPE_INDEX);
+ priv->index = g_object_ref (index);
/* Set up databases, these pointers are mostly used to
* start/stop transactions, since TrackerDBManager treats
@@ -773,11 +772,11 @@
arr = g_strsplit (parsed_value, " ", -1);
for (i = 0; arr[i]; i++) {
- tracker_index_add_word (data->index,
- arr[i],
- data->id,
- tracker_service_get_id (data->service),
- tracker_field_get_weight (field));
+ tracker_db_index_add_word (data->index,
+ arr[i],
+ data->id,
+ tracker_service_get_id (data->service),
+ tracker_field_get_weight (field));
}
tracker_db_set_metadata (data->service, data->id, field, (gchar *) value, parsed_value);
@@ -876,11 +875,11 @@
for (iter = words; iter != NULL; iter = iter->next) {
weight = GPOINTER_TO_INT (g_hash_table_lookup (parsed, (gchar *)iter->data));
- tracker_index_add_word (indexer->private->index,
- (gchar *)iter->data,
- service_id,
- service_type,
- weight);
+ tracker_db_index_add_word (indexer->private->index,
+ (gchar *)iter->data,
+ service_id,
+ service_type,
+ weight);
}
tracker_parser_text_free (parsed);
@@ -1482,13 +1481,13 @@
indexer->private->idle_id = 0;
indexer->private->is_paused = TRUE;
- tracker_index_close (indexer->private->index);
+ tracker_db_index_close (indexer->private->index);
g_signal_emit (indexer, signals[PAUSED], 0);
} else {
indexer->private->is_paused = FALSE;
indexer->private->idle_id = g_idle_add (process_func, indexer);
- tracker_index_open (indexer->private->index);
+ tracker_db_index_open (indexer->private->index);
g_signal_emit (indexer, signals[CONTINUED], 0);
}
}
Modified: branches/indexer-split/src/tracker-indexer/tracker-main.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-main.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-main.c Thu Aug 7 00:02:12 2008
@@ -34,7 +34,9 @@
#include <libtracker-common/tracker-log.h>
#include <libtracker-common/tracker-ontology.h>
#include <libtracker-common/tracker-module-config.h>
+
#include <libtracker-db/tracker-db-manager.h>
+#include <libtracker-db/tracker-db-index-manager.h>
#include "tracker-dbus.h"
#include "tracker-indexer.h"
@@ -292,6 +294,12 @@
}
tracker_db_manager_init (flags, NULL);
+ if (!tracker_db_index_manager_init (0,
+ tracker_config_get_min_bucket_count (config),
+ tracker_config_get_max_bucket_count (config))) {
+ return EXIT_FAILURE;
+ }
+
tracker_module_config_init ();
#ifdef HAVE_IOPRIO
Modified: branches/indexer-split/src/trackerd/tracker-daemon.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-daemon.c (original)
+++ branches/indexer-split/src/trackerd/tracker-daemon.c Thu Aug 7 00:02:12 2008
@@ -30,6 +30,7 @@
#include <libtracker-common/tracker-dbus.h>
#include <libtracker-db/tracker-db-dbus.h>
+#include <libtracker-db/tracker-db-index.h>
#include <libtracker-db/tracker-db-manager.h>
#include "tracker-dbus.h"
@@ -39,7 +40,6 @@
#include "tracker-main.h"
#include "tracker-status.h"
#include "tracker-marshal.h"
-#include "tracker-index.h"
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_DAEMON, TrackerDaemonPriv))
Modified: branches/indexer-split/src/trackerd/tracker-db.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db.c (original)
+++ branches/indexer-split/src/trackerd/tracker-db.c Thu Aug 7 00:02:12 2008
@@ -36,6 +36,7 @@
#include <libtracker-common/tracker-type-utils.h>
#include <libtracker-common/tracker-utils.h>
+#include <libtracker-db/tracker-db-index.h>
#include <libtracker-db/tracker-db-interface-sqlite.h>
#include <libtracker-db/tracker-db-manager.h>
@@ -51,7 +52,7 @@
static TrackerConfig *config;
static TrackerLanguage *language;
-static TrackerIndex *file_index;
+static TrackerDBIndex *db_index;
static gchar *
compress_string (const gchar *ptr,
@@ -493,11 +494,11 @@
void
tracker_db_init (TrackerConfig *this_config,
TrackerLanguage *this_language,
- TrackerIndex *this_file_index)
+ TrackerDBIndex *this_index)
{
g_return_if_fail (TRACKER_IS_CONFIG (this_config));
g_return_if_fail (TRACKER_IS_LANGUAGE (this_language));
- g_return_if_fail (TRACKER_IS_INDEX (this_file_index));
+ g_return_if_fail (TRACKER_IS_DB_INDEX (this_index));
if (initialized) {
return;
@@ -505,7 +506,7 @@
config = g_object_ref (this_config);
language = g_object_ref (this_language);
- file_index = g_object_ref (this_file_index);
+ db_index = g_object_ref (this_index);
}
void
@@ -515,8 +516,8 @@
return;
}
- g_object_unref (file_index);
- file_index = NULL;
+ g_object_unref (db_index);
+ db_index = NULL;
g_object_unref (language);
language = NULL;
@@ -676,7 +677,7 @@
}
tree = tracker_query_tree_new (search_string,
- file_index,
+ db_index,
config,
language,
services);
@@ -784,16 +785,16 @@
/* Delete duds */
if (duds) {
- TrackerIndex *indexer;
- GSList *words, *w;
+ TrackerDBIndex *index;
+ GSList *words, *w;
words = tracker_query_tree_get_words (tree);
- indexer = tracker_query_tree_get_index (tree);
+ index = tracker_query_tree_get_index (tree);
for (w = words; w; w = w->next) {
- tracker_index_remove_dud_hits (indexer,
- (const gchar *) w->data,
- duds);
+ tracker_db_index_remove_dud_hits (index,
+ (const gchar *) w->data,
+ duds);
}
g_slist_free (words);
@@ -837,7 +838,7 @@
services = db_create_array_of_services ();
tree = tracker_query_tree_new (text,
- file_index,
+ db_index,
config,
language,
services);
@@ -933,7 +934,7 @@
services = db_create_array_of_services ();
tree = tracker_query_tree_new (text,
- file_index,
+ db_index,
config,
language,
services);
@@ -1031,7 +1032,7 @@
services = db_create_array_of_services ();
tree = tracker_query_tree_new (text,
- file_index,
+ db_index,
config,
language,
services);
Modified: branches/indexer-split/src/trackerd/tracker-db.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db.h (original)
+++ branches/indexer-split/src/trackerd/tracker-db.h Thu Aug 7 00:02:12 2008
@@ -34,15 +34,15 @@
#include <libtracker-db/tracker-db-interface.h>
#include <libtracker-db/tracker-db-file-info.h>
+#include <libtracker-db/tracker-db-index.h>
-#include "tracker-index.h"
#include "tracker-utils.h"
G_BEGIN_DECLS
void tracker_db_init (TrackerConfig *this_config,
TrackerLanguage *this_language,
- TrackerIndex *this_file_index);
+ TrackerDBIndex *this_file_index);
void tracker_db_shutdown (void);
/* Operations for TrackerDBInterface */
Modified: branches/indexer-split/src/trackerd/tracker-dbus.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus.c (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus.c Thu Aug 7 00:02:12 2008
@@ -301,14 +301,14 @@
gboolean
tracker_dbus_register_objects (TrackerConfig *config,
TrackerLanguage *language,
- TrackerIndex *index,
+ TrackerDBIndex *index,
TrackerProcessor *processor)
{
gpointer object;
g_return_val_if_fail (TRACKER_IS_CONFIG (config), FALSE);
g_return_val_if_fail (TRACKER_IS_LANGUAGE (language), FALSE);
- g_return_val_if_fail (TRACKER_IS_INDEX (index), FALSE);
+ g_return_val_if_fail (TRACKER_IS_DB_INDEX (index), FALSE);
if (!connection || !proxy) {
g_critical ("DBus support must be initialized before registering objects!");
Modified: branches/indexer-split/src/trackerd/tracker-dbus.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus.h (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus.h Thu Aug 7 00:02:12 2008
@@ -29,7 +29,8 @@
#include <libtracker-common/tracker-config.h>
#include <libtracker-common/tracker-language.h>
-#include "tracker-index.h"
+#include <libtracker-db/tracker-db-index.h>
+
#include "tracker-processor.h"
G_BEGIN_DECLS
@@ -38,7 +39,7 @@
void tracker_dbus_shutdown (void);
gboolean tracker_dbus_register_objects (TrackerConfig *config,
TrackerLanguage *language,
- TrackerIndex *file,
+ TrackerDBIndex *file,
TrackerProcessor *processor);
GObject *tracker_dbus_get_object (GType type);
DBusGProxy *tracker_dbus_indexer_get_proxy (void);
Modified: branches/indexer-split/src/trackerd/tracker-keywords.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-keywords.c (original)
+++ branches/indexer-split/src/trackerd/tracker-keywords.c Thu Aug 7 00:02:12 2008
@@ -26,13 +26,13 @@
#include <libtracker-common/tracker-utils.h>
#include <libtracker-db/tracker-db-dbus.h>
+#include <libtracker-db/tracker-db-index.h>
#include <libtracker-db/tracker-db-manager.h>
#include "tracker-dbus.h"
#include "tracker-keywords.h"
#include "tracker-db.h"
#include "tracker-marshal.h"
-#include "tracker-index.h"
#include "tracker-indexer-client.h"
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_KEYWORDS, TrackerKeywordsPriv))
Modified: branches/indexer-split/src/trackerd/tracker-main.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.c (original)
+++ branches/indexer-split/src/trackerd/tracker-main.c Thu Aug 7 00:02:12 2008
@@ -48,12 +48,12 @@
#include <libtracker-common/tracker-nfs-lock.h>
#include <libtracker-db/tracker-db-manager.h>
+#include <libtracker-db/tracker-db-index.h>
+#include <libtracker-db/tracker-db-index-manager.h>
#include "tracker-crawler.h"
#include "tracker-dbus.h"
-#include "tracker-index.h"
#include "tracker-indexer-client.h"
-#include "tracker-index-manager.h"
#include "tracker-main.h"
#include "tracker-monitor.h"
#include "tracker-processor.h"
@@ -528,18 +528,18 @@
gint
main (gint argc, gchar *argv[])
{
- GOptionContext *context = NULL;
- GOptionGroup *group;
- GError *error = NULL;
- TrackerConfig *config;
- TrackerLanguage *language;
- TrackerHal *hal;
- TrackerProcessor *processor;
- TrackerIndex *index;
- TrackerIndex *index_update;
- TrackerRunningLevel runtime_level;
- TrackerDBManagerFlags flags;
- TrackerIndexManagerFlags iflags = 0;
+ GOptionContext *context = NULL;
+ GOptionGroup *group;
+ GError *error = NULL;
+ TrackerConfig *config;
+ TrackerLanguage *language;
+ TrackerHal *hal;
+ TrackerProcessor *processor;
+ TrackerDBIndex *index;
+ TrackerDBIndex *index_update;
+ TrackerRunningLevel runtime_level;
+ TrackerDBManagerFlags flags;
+ TrackerDBIndexManagerFlags index_flags;
g_type_init ();
@@ -682,10 +682,11 @@
tracker_module_config_init ();
flags = TRACKER_DB_MANAGER_REMOVE_CACHE;
+ index_flags = 0;
if (force_reindex) {
flags |= TRACKER_DB_MANAGER_FORCE_REINDEX;
- iflags |= TRACKER_INDEX_MANAGER_FORCE_REINDEX;
+ index_flags |= TRACKER_DB_INDEX_MANAGER_FORCE_REINDEX;
}
if (tracker_config_get_low_memory_mode (config)) {
@@ -693,9 +694,9 @@
}
tracker_db_manager_init (flags, &is_first_time_index);
- if (!tracker_index_manager_init (iflags, tracker_get_data_dir (),
- tracker_config_get_min_bucket_count (config),
- tracker_config_get_max_bucket_count (config))) {
+ if (!tracker_db_index_manager_init (index_flags,
+ tracker_config_get_min_bucket_count (config),
+ tracker_config_get_max_bucket_count (config))) {
return EXIT_FAILURE;
}
@@ -721,11 +722,11 @@
return EXIT_FAILURE;
}
- index = tracker_index_manager_get_index (TRACKER_INDEX_TYPE_INDEX);
- index_update = tracker_index_manager_get_index (TRACKER_INDEX_TYPE_INDEX_UPDATE);
+ index = tracker_db_index_manager_get_index (TRACKER_DB_INDEX_TYPE_INDEX);
+ index_update = tracker_db_index_manager_get_index (TRACKER_DB_INDEX_TYPE_INDEX_UPDATE);
- if (!TRACKER_IS_INDEX (index) ||
- !TRACKER_IS_INDEX (index_update)) {
+ if (!TRACKER_IS_DB_INDEX (index) ||
+ !TRACKER_IS_DB_INDEX (index_update)) {
g_critical ("Could not create indexer for all indexes (index, index-update)");
return EXIT_FAILURE;
}
@@ -804,7 +805,7 @@
tracker_xesam_manager_shutdown ();
tracker_dbus_shutdown ();
tracker_db_manager_shutdown ();
- tracker_index_manager_shutdown ();
+ tracker_db_index_manager_shutdown ();
tracker_db_shutdown ();
tracker_module_config_shutdown ();
tracker_nfs_lock_shutdown ();
@@ -834,12 +835,6 @@
}
const gchar *
-tracker_get_data_dir (void)
-{
- return data_dir;
-}
-
-const gchar *
tracker_get_sys_tmp_dir (void)
{
return sys_tmp_dir;
Modified: branches/indexer-split/src/trackerd/tracker-main.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.h (original)
+++ branches/indexer-split/src/trackerd/tracker-main.h Thu Aug 7 00:02:12 2008
@@ -29,7 +29,6 @@
void tracker_shutdown (void);
-const gchar *tracker_get_data_dir (void);
const gchar *tracker_get_sys_tmp_dir (void);
gboolean tracker_get_is_readonly (void);
Modified: branches/indexer-split/src/trackerd/tracker-metadata.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-metadata.c (original)
+++ branches/indexer-split/src/trackerd/tracker-metadata.c Thu Aug 7 00:02:12 2008
@@ -30,6 +30,7 @@
#include <libtracker-common/tracker-type-utils.h>
#include <libtracker-db/tracker-db-dbus.h>
+#include <libtracker-db/tracker-db-index.h>
#include <libtracker-db/tracker-db-manager.h>
#include "tracker-indexer-client.h"
@@ -37,7 +38,6 @@
#include "tracker-metadata.h"
#include "tracker-db.h"
#include "tracker-marshal.h"
-#include "tracker-index.h"
G_DEFINE_TYPE(TrackerMetadata, tracker_metadata, G_TYPE_OBJECT)
Modified: branches/indexer-split/src/trackerd/tracker-metadata.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-metadata.h (original)
+++ branches/indexer-split/src/trackerd/tracker-metadata.h Thu Aug 7 00:02:12 2008
@@ -24,7 +24,7 @@
#include <glib-object.h>
-#include "tracker-index.h"
+#include <libtracker-db/tracker-db-index.h>
#define TRACKER_METADATA_SERVICE "org.freedesktop.Tracker"
#define TRACKER_METADATA_PATH "/org/freedesktop/Tracker/Metadata"
Modified: branches/indexer-split/src/trackerd/tracker-processor.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-processor.c (original)
+++ branches/indexer-split/src/trackerd/tracker-processor.c Thu Aug 7 00:02:12 2008
@@ -31,12 +31,13 @@
#include <libtracker-common/tracker-module-config.h>
#include <libtracker-common/tracker-utils.h>
+#include <libtracker-db/tracker-db-index.h>
+#include <libtracker-db/tracker-db-index-manager.h>
+
#include "tracker-processor.h"
#include "tracker-crawler.h"
#include "tracker-daemon.h"
#include "tracker-dbus.h"
-#include "tracker-index.h"
-#include "tracker-index-manager.h"
#include "tracker-indexer-client.h"
#include "tracker-main.h"
#include "tracker-monitor.h"
@@ -866,7 +867,7 @@
gpointer user_data)
{
TrackerProcessor *processor;
- TrackerIndex *index;
+ TrackerDBIndex *index;
GQueue *queue;
GFile *file;
gchar *path = NULL;
@@ -904,8 +905,8 @@
* module_name->index type so we don't do this for both
* every time:
*/
- index = tracker_index_manager_get_index (TRACKER_INDEX_TYPE_INDEX);
- tracker_index_set_reload (index, TRUE);
+ index = tracker_db_index_manager_get_index (TRACKER_DB_INDEX_TYPE_INDEX);
+ tracker_db_index_set_reload (index, TRUE);
/* Message to the console about state */
str1 = tracker_seconds_estimate_to_string (seconds_elapsed,
@@ -932,7 +933,7 @@
gpointer user_data)
{
TrackerProcessor *processor;
- TrackerIndex *index;
+ TrackerDBIndex *index;
gchar *str;
processor = user_data;
@@ -950,8 +951,8 @@
* module_name->index type so we don't do this for both
* every time:
*/
- index = tracker_index_manager_get_index (TRACKER_INDEX_TYPE_INDEX);
- tracker_index_set_reload (index, TRUE);
+ index = tracker_db_index_manager_get_index (TRACKER_DB_INDEX_TYPE_INDEX);
+ tracker_db_index_set_reload (index, TRUE);
/* Message to the console about state */
str = tracker_seconds_to_string (seconds_elapsed, FALSE);
Modified: branches/indexer-split/src/trackerd/tracker-query-tree.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-query-tree.c (original)
+++ branches/indexer-split/src/trackerd/tracker-query-tree.c Thu Aug 7 00:02:12 2008
@@ -68,7 +68,7 @@
struct TrackerQueryTreePrivate {
gchar *query_str;
TreeNode *tree;
- TrackerIndex *index;
+ TrackerDBIndex *index;
TrackerConfig *config;
TrackerLanguage *language;
GArray *services;
@@ -129,7 +129,7 @@
g_param_spec_object ("index",
"Index",
"Index",
- tracker_index_get_type (),
+ tracker_db_index_get_type (),
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_CONFIG,
@@ -277,13 +277,13 @@
TrackerQueryTree *
tracker_query_tree_new (const gchar *query_str,
- TrackerIndex *index,
+ TrackerDBIndex *index,
TrackerConfig *config,
TrackerLanguage *language,
GArray *services)
{
g_return_val_if_fail (query_str != NULL, NULL);
- g_return_val_if_fail (TRACKER_IS_INDEX (index), NULL);
+ g_return_val_if_fail (TRACKER_IS_DB_INDEX (index), NULL);
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
g_return_val_if_fail (language != NULL, NULL);
@@ -484,12 +484,12 @@
void
tracker_query_tree_set_index (TrackerQueryTree *tree,
- TrackerIndex *index)
+ TrackerDBIndex *index)
{
TrackerQueryTreePrivate *priv;
g_return_if_fail (TRACKER_IS_QUERY_TREE (tree));
- g_return_if_fail (TRACKER_IS_INDEX (index));
+ g_return_if_fail (TRACKER_IS_DB_INDEX (index));
priv = TRACKER_QUERY_TREE_GET_PRIVATE (tree);
@@ -506,7 +506,7 @@
g_object_notify (G_OBJECT (tree), "index");
}
-TrackerIndex *
+TrackerDBIndex *
tracker_query_tree_get_index (TrackerQueryTree *tree)
{
TrackerQueryTreePrivate *priv;
@@ -703,7 +703,7 @@
result = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) search_hit_data_free);
- details = tracker_index_get_word_hits (priv->index, term, &count);
+ details = tracker_db_index_get_word_hits (priv->index, term, &count);
if (!details)
return result;
Modified: branches/indexer-split/src/trackerd/tracker-query-tree.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-query-tree.h (original)
+++ branches/indexer-split/src/trackerd/tracker-query-tree.h Thu Aug 7 00:02:12 2008
@@ -30,7 +30,7 @@
#include <libtracker-common/tracker-config.h>
#include <libtracker-common/tracker-language.h>
-#include "tracker-index.h"
+#include <libtracker-db/tracker-db-index.h>
#define TRACKER_TYPE_QUERY_TREE (tracker_query_tree_get_type())
#define TRACKER_QUERY_TREE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_QUERY_TREE, TrackerQueryTree))
@@ -41,7 +41,6 @@
typedef struct TrackerQueryTree TrackerQueryTree;
typedef struct TrackerQueryTreeClass TrackerQueryTreeClass;
-typedef struct TrackerSearchHit TrackerSearchHit;
typedef struct TrackerHitCount TrackerHitCount;
struct TrackerQueryTree {
@@ -52,12 +51,6 @@
GObjectClass parent_class;
};
-struct TrackerSearchHit {
- guint32 service_id; /* Service ID of the document */
- guint32 service_type_id; /* Service type ID of the document */
- guint32 score; /* Ranking score */
-};
-
struct TrackerHitCount {
guint service_type_id;
guint count;
@@ -65,16 +58,16 @@
GType tracker_query_tree_get_type (void);
TrackerQueryTree * tracker_query_tree_new (const gchar *query_str,
- TrackerIndex *indexer,
+ TrackerDBIndex *index,
TrackerConfig *config,
TrackerLanguage *language,
GArray *services);
G_CONST_RETURN gchar *tracker_query_tree_get_query (TrackerQueryTree *tree);
void tracker_query_tree_set_query (TrackerQueryTree *tree,
const gchar *query_str);
-TrackerIndex * tracker_query_tree_get_index (TrackerQueryTree *tree);
+TrackerDBIndex * tracker_query_tree_get_index (TrackerQueryTree *tree);
void tracker_query_tree_set_index (TrackerQueryTree *tree,
- TrackerIndex *indexer);
+ TrackerDBIndex *indexer);
TrackerConfig * tracker_query_tree_get_config (TrackerQueryTree *tree);
void tracker_query_tree_set_config (TrackerQueryTree *tree,
TrackerConfig *config);
Modified: branches/indexer-split/src/trackerd/tracker-search.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-search.c (original)
+++ branches/indexer-split/src/trackerd/tracker-search.c Thu Aug 7 00:02:12 2008
@@ -32,6 +32,7 @@
#include <libtracker-common/tracker-utils.h>
#include <libtracker-db/tracker-db-dbus.h>
+#include <libtracker-db/tracker-db-index.h>
#include <libtracker-db/tracker-db-manager.h>
#include "tracker-db.h"
@@ -39,7 +40,6 @@
#include "tracker-search.h"
#include "tracker-rdf-query.h"
#include "tracker-query-tree.h"
-#include "tracker-index.h"
#include "tracker-marshal.h"
#define DEFAULT_SEARCH_MAX_HITS 1024
@@ -51,7 +51,7 @@
TrackerConfig *config;
TrackerLanguage *language;
- TrackerIndex *index;
+ TrackerDBIndex *index;
} TrackerSearchPriv;
static void search_finalize (GObject *object);
@@ -96,14 +96,14 @@
TrackerSearch *
tracker_search_new (TrackerConfig *config,
TrackerLanguage *language,
- TrackerIndex *index)
+ TrackerDBIndex *index)
{
TrackerSearch *object;
TrackerSearchPriv *priv;
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
g_return_val_if_fail (TRACKER_IS_LANGUAGE (language), NULL);
- g_return_val_if_fail (TRACKER_IS_INDEX (index), NULL);
+ g_return_val_if_fail (TRACKER_IS_DB_INDEX (index), NULL);
object = g_object_new (TRACKER_TYPE_SEARCH, NULL);
@@ -1238,7 +1238,7 @@
priv = GET_PRIV (object);
- value = tracker_index_get_suggestion (priv->index, search_text, max_dist);
+ value = tracker_db_index_get_suggestion (priv->index, search_text, max_dist);
if (!value) {
g_set_error (&actual_error,
Modified: branches/indexer-split/src/trackerd/tracker-search.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-search.h (original)
+++ branches/indexer-split/src/trackerd/tracker-search.h Thu Aug 7 00:02:12 2008
@@ -26,7 +26,7 @@
#include <libtracker-common/tracker-language.h>
-#include "tracker-index.h"
+#include <libtracker-db/tracker-db-index.h>
#define TRACKER_SEARCH_SERVICE "org.freedesktop.Tracker"
#define TRACKER_SEARCH_PATH "/org/freedesktop/Tracker/Search"
@@ -55,7 +55,7 @@
GType tracker_search_get_type (void);
TrackerSearch *tracker_search_new (TrackerConfig *config,
TrackerLanguage *language,
- TrackerIndex *index);
+ TrackerDBIndex *index);
void tracker_search_get_hit_count (TrackerSearch *object,
const gchar *service,
const gchar *search_text,
Modified: branches/indexer-split/src/trackerd/tracker-xesam.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam.c (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam.c Thu Aug 7 00:02:12 2008
@@ -29,13 +29,14 @@
#include <libtracker-common/tracker-ontology.h>
#include <libtracker-common/tracker-utils.h>
+#include <libtracker-db/tracker-db-index.h>
+
#include "tracker-dbus.h"
#include "tracker-xesam.h"
#include "tracker-status.h"
#include "tracker-xesam-manager.h"
#include "tracker-rdf-query.h"
#include "tracker-query-tree.h"
-#include "tracker-index.h"
#include "tracker-marshal.h"
enum {
Modified: branches/indexer-split/src/trackerd/tracker-xesam.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam.h (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam.h Thu Aug 7 00:02:12 2008
@@ -26,8 +26,9 @@
#include <dbus/dbus-glib-bindings.h>
+#include <libtracker-db/tracker-db-index.h>
+
#include "tracker-db.h"
-#include "tracker-index.h"
#define TRACKER_XESAM_SERVICE "org.freedesktop.xesam.searcher"
#define TRACKER_XESAM_PATH "/org/freedesktop/xesam/searcher/main"
Modified: branches/indexer-split/tests/trackerd/Makefile.am
==============================================================================
--- branches/indexer-split/tests/trackerd/Makefile.am (original)
+++ branches/indexer-split/tests/trackerd/Makefile.am Thu Aug 7 00:02:12 2008
@@ -43,18 +43,18 @@
endif
-TEST_PROGS += tracker-index
+#TEST_PROGS += tracker-index
-tracker_index_SOURCES = \
- tracker-index-test.c \
- tracker-index.c
+#tracker_index_SOURCES = \
+# tracker-index-test.c \
+# tracker-db-index.c
-tracker_index_LDADD = \
- $(top_builddir)/tests/common/libtracker-testcommon.la \
- $(GMODULE_LIBS) \
- $(GTHREAD_LIBS) \
- $(GLIB2_LIBS) \
- $(DBUS_LIBS) \
- $(GIO_LIBS) \
- $(QDBM_LIBS)
+#tracker_index_LDADD = \
+# $(top_builddir)/tests/common/libtracker-testcommon.la \
+# $(GMODULE_LIBS) \
+# $(GTHREAD_LIBS) \
+# $(GLIB2_LIBS) \
+# $(DBUS_LIBS) \
+# $(GIO_LIBS) \
+# $(QDBM_LIBS)
Modified: branches/indexer-split/tests/trackerd/tracker-index-test.c
==============================================================================
--- branches/indexer-split/tests/trackerd/tracker-index-test.c (original)
+++ branches/indexer-split/tests/trackerd/tracker-index-test.c Thu Aug 7 00:02:12 2008
@@ -3,7 +3,7 @@
#include <tracker-test-helpers.h>
#include <gio/gio.h>
-#include "tracker-index.h"
+#include "tracker-db-index.h"
/* From libtracker-common/tracker-config.c */
#define DEFAULT_MAX_BUCKET_COUNT 524288
@@ -12,16 +12,17 @@
static void
test_get_suggestion ()
{
- TrackerIndex *index;
- gchar *suggestion;
+ TrackerDBIndex *index;
+ gchar *suggestion;
- index = tracker_index_new ("./example.index",
- DEFAULT_MIN_BUCKET_COUNT,
- DEFAULT_MAX_BUCKET_COUNT);
+ index = tracker_db_index_new ("./example.index",
+ DEFAULT_MIN_BUCKET_COUNT,
+ DEFAULT_MAX_BUCKET_COUNT,
+ TRUE);
- g_assert (tracker_index_get_reload (index));
+ g_assert (tracker_db_index_get_reload (index));
- suggestion = tracker_index_get_suggestion (index, "Thiz", 9);
+ suggestion = tracker_db_index_get_suggestion (index, "Thiz", 9);
g_assert (tracker_test_helpers_cmpstr_equal (suggestion, "this"));
@@ -33,19 +34,20 @@
static void
test_reloading ()
{
- TrackerIndex *index;
+ TrackerDBIndex *index;
TrackerIndexItem *hits;
guint count;
- index = tracker_index_new ("./example.index",
- DEFAULT_MIN_BUCKET_COUNT,
- DEFAULT_MAX_BUCKET_COUNT);
+ index = tracker_db_index_new ("./example.index",
+ DEFAULT_MIN_BUCKET_COUNT,
+ DEFAULT_MAX_BUCKET_COUNT,
+ TRUE);
- tracker_index_set_reload (index, TRUE);
- g_assert (tracker_index_get_reload (index)); /* Trivial check of get/set */
+ tracker_db_index_set_reload (index, TRUE);
+ g_assert (tracker_db_index_get_reload (index)); /* Trivial check of get/set */
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- hits = tracker_index_get_word_hits (index, "this", &count);
+ hits = tracker_db_index_get_word_hits (index, "this", &count);
g_free (hits);
}
@@ -55,37 +57,39 @@
static void
test_bad_index ()
{
- TrackerIndex *index;
- guint count;
+ TrackerDBIndex *index;
+ guint count;
- index = tracker_index_new ("unknown-index",
- DEFAULT_MIN_BUCKET_COUNT,
- DEFAULT_MAX_BUCKET_COUNT);
+ index = tracker_db_index_new ("unknown-index",
+ DEFAULT_MIN_BUCKET_COUNT,
+ DEFAULT_MAX_BUCKET_COUNT,
+ TRUE);
/* Reload true: lazy opening */
- g_assert (tracker_index_get_reload (index));
+ g_assert (tracker_db_index_get_reload (index));
/* Return NULL, the index cannot reload the file */
- g_assert (!tracker_index_get_word_hits (index, "this", &count));
+ g_assert (!tracker_db_index_get_word_hits (index, "this", &count));
/* Return NULL, the index cannot reload the file */
- g_assert (!tracker_index_get_suggestion (index, "Thiz", 9));
+ g_assert (!tracker_db_index_get_suggestion (index, "Thiz", 9));
}
static void
test_created_file_in_the_mean_time ()
{
- TrackerIndex *index;
+ TrackerDBIndex *index;
GFile *good, *bad;
guint count;
- index = tracker_index_new ("./unknown-index",
- DEFAULT_MIN_BUCKET_COUNT,
- DEFAULT_MAX_BUCKET_COUNT);
+ index = tracker_db_index_new ("./unknown-index",
+ DEFAULT_MIN_BUCKET_COUNT,
+ DEFAULT_MAX_BUCKET_COUNT,
+ TRUE);
/* Reload true: Lazy opening */
- g_assert (tracker_index_get_reload (index));
+ g_assert (tracker_db_index_get_reload (index));
good = g_file_new_for_path ("./example.index");
bad = g_file_new_for_path ("./unknown-index");
@@ -93,10 +97,10 @@
g_file_copy (good, bad, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL);
/* Now the first operation reload the index */
- g_assert (tracker_index_get_word_hits (index, "this", &count));
+ g_assert (tracker_db_index_get_word_hits (index, "this", &count));
/* Reload false: It is already reloaded */
- g_assert (!tracker_index_get_reload (index));
+ g_assert (!tracker_db_index_get_reload (index));
g_file_delete (bad, NULL, NULL);
}
Modified: branches/indexer-split/utils/qdbm/print-words.c
==============================================================================
--- branches/indexer-split/utils/qdbm/print-words.c (original)
+++ branches/indexer-split/utils/qdbm/print-words.c Thu Aug 7 00:02:12 2008
@@ -51,11 +51,10 @@
}
void
-load_terms_from_index (gchar* filename){
-
+load_terms_from_index (gchar* filename)
+{
DEPOT *depot;
char *key;
- int counter = 0, start_time, total_time;
guint hits, i;
TrackerIndexItem *results;
Modified: branches/indexer-split/utils/qdbm/search-word.c
==============================================================================
--- branches/indexer-split/utils/qdbm/search-word.c (original)
+++ branches/indexer-split/utils/qdbm/search-word.c Thu Aug 7 00:02:12 2008
@@ -73,7 +73,6 @@
show_term_in_index (const gchar* filename, const gchar *word){
DEPOT *depot;
- int counter = 0, start_time, total_time;
gint hits, i;
TrackerIndexerWordDetails *results;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]