tracker r1550 - in branches/xesam-support: . src/libtracker-common src/libtracker-db src/tracker-indexer
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1550 - in branches/xesam-support: . src/libtracker-common src/libtracker-db src/tracker-indexer
- Date: Fri, 30 May 2008 13:47:53 +0000 (UTC)
Author: pvanhoof
Date: Fri May 30 13:47:52 2008
New Revision: 1550
URL: http://svn.gnome.org/viewvc/tracker?rev=1550&view=rev
Log:
svn merge -r 1537:1549 ../indexer-split
Added:
branches/xesam-support/src/tracker-indexer/tracker-index.c
- copied unchanged from r1549, /branches/indexer-split/src/tracker-indexer/tracker-index.c
branches/xesam-support/src/tracker-indexer/tracker-index.h
- copied unchanged from r1549, /branches/indexer-split/src/tracker-indexer/tracker-index.h
Modified:
branches/xesam-support/ChangeLog
branches/xesam-support/src/libtracker-common/tracker-parser.c
branches/xesam-support/src/libtracker-db/Makefile.am
branches/xesam-support/src/tracker-indexer/Makefile.am
branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c
branches/xesam-support/src/tracker-indexer/tracker-indexer-db.h
branches/xesam-support/src/tracker-indexer/tracker-indexer.c
Modified: branches/xesam-support/src/libtracker-common/tracker-parser.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-parser.c (original)
+++ branches/xesam-support/src/libtracker-common/tracker-parser.c Fri May 30 13:47:52 2008
@@ -443,12 +443,12 @@
s = tracker_parser_text_to_string (text,
language,
- min_word_length,
max_word_length,
+ min_word_length,
TRUE,
FALSE,
FALSE);
- strv = g_strsplit (s, " ", -1);
+ strv = g_strsplit (g_strstrip (s), " ", -1);
g_free (s);
return strv;
Modified: branches/xesam-support/src/libtracker-db/Makefile.am
==============================================================================
--- branches/xesam-support/src/libtracker-db/Makefile.am (original)
+++ branches/xesam-support/src/libtracker-db/Makefile.am Fri May 30 13:47:52 2008
@@ -1,5 +1,4 @@
INCLUDES = \
- -g \
-DSHAREDIR=\""$(datadir)"\" \
-DG_LOG_DOMAIN=\"Tracker\" \
-I$(top_srcdir)/src \
Modified: branches/xesam-support/src/tracker-indexer/Makefile.am
==============================================================================
--- branches/xesam-support/src/tracker-indexer/Makefile.am (original)
+++ branches/xesam-support/src/tracker-indexer/Makefile.am Fri May 30 13:47:52 2008
@@ -18,6 +18,8 @@
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/xesam-support/src/tracker-indexer/tracker-indexer-db.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c (original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c Fri May 30 13:47:52 2008
@@ -525,33 +525,30 @@
void
tracker_db_increment_stats (TrackerDBInterface *iface,
- const gchar *service)
+ TrackerService *service)
{
- gchar *parent;
+ const gchar *service_type, *parent;
- tracker_db_interface_execute_procedure (iface, NULL, "IncStat", service, NULL);
+ service_type = tracker_service_get_name (service);
+ parent = tracker_service_get_parent (service);
- parent = tracker_ontology_get_parent_service (service);
+ tracker_db_interface_execute_procedure (iface, NULL, "IncStat", service_type, NULL);
if (parent) {
tracker_db_interface_execute_procedure (iface, NULL, "IncStat", parent, NULL);
- g_free (parent);
}
}
gboolean
tracker_db_create_service (TrackerDBInterface *iface,
guint32 id,
- const char *service_type,
+ TrackerService *service,
const gchar *path,
GHashTable *metadata)
{
- TrackerService *service;
gchar *id_str, *service_type_id_str;
gchar *dirname, *basename;
- service = tracker_ontology_get_service_type_by_name (service_type);
-
if (!service) {
return FALSE;
}
Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer-db.h
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer-db.h (original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer-db.h Fri May 30 13:47:52 2008
@@ -20,6 +20,7 @@
#ifndef __TRACKER_INDEXER_DB_H__
#define __TRACKER_INDEXER_DB_H__
+#include <libtracker-common/tracker-ontology.h>
#include <libtracker-db/tracker-db-interface.h>
G_BEGIN_DECLS
@@ -30,11 +31,11 @@
guint32 tracker_db_get_new_service_id (TrackerDBInterface *iface);
void tracker_db_increment_stats (TrackerDBInterface *iface,
- const gchar *service);
+ TrackerService *service);
gboolean tracker_db_create_service (TrackerDBInterface *iface,
guint32 id,
- const char *service_type,
+ TrackerService *service,
const gchar *path,
GHashTable *metadata);
Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer.c (original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer.c Fri May 30 13:47:52 2008
@@ -48,18 +48,21 @@
#include <libtracker-common/tracker-config.h>
#include <libtracker-common/tracker-file-utils.h>
+#include <libtracker-common/tracker-language.h>
+#include <libtracker-common/tracker-parser.h>
+#include <libtracker-common/tracker-ontology.h>
#include <libtracker-db/tracker-db-interface-sqlite.h>
-#include <qdbm/depot.h>
-
#include "tracker-indexer.h"
#include "tracker-indexer-module.h"
#include "tracker-indexer-db.h"
+#include "tracker-index.h"
#define TRACKER_INDEXER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_INDEXER, TrackerIndexerPrivate))
typedef struct TrackerIndexerPrivate TrackerIndexerPrivate;
typedef struct PathInfo PathInfo;
+typedef struct MetadataForeachData MetadataForeachData;
struct TrackerIndexerPrivate {
GQueue *dir_queue;
@@ -71,12 +74,13 @@
gchar *db_dir;
- DEPOT *index;
+ TrackerIndex *index;
TrackerDBInterface *metadata;
TrackerDBInterface *contents;
TrackerDBInterface *common;
TrackerConfig *config;
+ TrackerLanguage *language;
guint idle_id;
@@ -88,6 +92,14 @@
gchar *path;
};
+struct MetadataForeachData {
+ TrackerIndex *index;
+ TrackerLanguage *language;
+ TrackerConfig *config;
+ TrackerService *service;
+ guint32 id;
+};
+
enum {
PROP_0,
PROP_RUNNING,
@@ -141,6 +153,11 @@
g_hash_table_destroy (priv->indexer_modules);
g_object_unref (priv->config);
+ g_object_unref (priv->language);
+
+ if (priv->index) {
+ tracker_index_free (priv->index);
+ }
if (priv->common) {
g_object_unref (priv->common);
@@ -236,6 +253,7 @@
init_indexer (TrackerIndexer *indexer)
{
TrackerIndexerPrivate *priv;
+ gchar *index_file;
priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
@@ -243,10 +261,17 @@
tracker_dir_remove (priv->db_dir);
}
+ 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));
priv->common = tracker_indexer_db_get_common ();
priv->metadata = tracker_indexer_db_get_file_metadata ();
tracker_indexer_set_running (indexer, TRUE);
+
+ g_free (index_file);
+
return FALSE;
}
@@ -262,6 +287,7 @@
priv->dir_queue = g_queue_new ();
priv->file_process_queue = g_queue_new ();
priv->config = tracker_config_new ();
+ priv->language = tracker_language_new (priv->config);
priv->db_dir = g_build_filename (g_get_user_cache_dir (),
"tracker", NULL);
@@ -336,6 +362,62 @@
}
static void
+index_metadata_foreach (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ TrackerField *field;
+ MetadataForeachData *data;
+ gchar **arr;
+ gint i;
+
+ if (!value) {
+ return;
+ }
+
+ field = tracker_ontology_get_field_def ((gchar *) key);
+
+ data = (MetadataForeachData *) user_data;
+ arr = tracker_parser_text_into_array ((gchar *) value,
+ data->language,
+ tracker_config_get_max_word_length (data->config),
+ tracker_config_get_min_word_length (data->config));
+
+ 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));
+ }
+
+ g_strfreev (arr);
+}
+
+static void
+index_metadata (TrackerIndexer *indexer,
+ guint32 id,
+ TrackerService *service,
+ GHashTable *metadata)
+{
+ TrackerIndexerPrivate *priv;
+ MetadataForeachData data;
+
+ priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
+
+ data.index = priv->index;
+ data.language = priv->language;
+ data.config = priv->config;
+ data.service = service;
+ data.id = id;
+
+ g_hash_table_foreach (metadata, index_metadata_foreach, &data);
+
+ /* FIXME: flushing after adding each metadata set, not ideal */
+ tracker_index_flush (priv->index);
+}
+
+static void
process_file (TrackerIndexer *indexer,
PathInfo *info)
{
@@ -346,6 +428,7 @@
metadata = tracker_indexer_module_get_file_metadata (info->module, info->path);
if (metadata) {
+ TrackerService *service;
TrackerIndexerPrivate *priv;
const gchar *service_type;
guint32 id;
@@ -353,15 +436,18 @@
priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
service_type = tracker_indexer_module_get_name (info->module);
+ service = tracker_ontology_get_service_type_by_name (service_type);
id = tracker_db_get_new_service_id (priv->common);
- if (tracker_db_create_service (priv->metadata, id, service_type, info->path, metadata)) {
- tracker_db_increment_stats (priv->common, service_type);
+ if (tracker_db_create_service (priv->metadata, id, service, info->path, metadata)) {
+ tracker_db_increment_stats (priv->common, service);
/* FIXME
if (tracker_config_get_enable_xesam (tracker->config))
tracker_db_create_event (db_con, id, "Create");
*/
+
+ index_metadata (indexer, id, service, metadata);
}
g_hash_table_destroy (metadata);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]