tracker r2019 - in branches/indexer-split: . src/libtracker-common src/libtracker-db src/tracker-indexer src/trackerd tests/libtracker-common tests/tracker-indexer utils/qdbm
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2019 - in branches/indexer-split: . src/libtracker-common src/libtracker-db src/tracker-indexer src/trackerd tests/libtracker-common tests/tracker-indexer utils/qdbm
- Date: Thu, 7 Aug 2008 08:53:24 +0000 (UTC)
Author: mr
Date: Thu Aug 7 08:53:24 2008
New Revision: 2019
URL: http://svn.gnome.org/viewvc/tracker?rev=2019&view=rev
Log:
* configure.ac:
* tests/libtracker-common/tracker-type-utils-test.c:
* tests/tracker-indexer/Makefile.am:
* tests/tracker-indexer/tracker-index-test.c: Removed dirty hacks
for testing the index API and cleaned up the code a little.
* src/libtracker-common/Makefile.am:
* src/libtracker-common/tracker-index-item.[ch]:
* src/libtracker-db/Makefile.am:
* src/libtracker-db/tracker-db-index-item.[ch]:
* src/libtracker-db/tracker-db-index.[ch]:
* src/tracker-indexer/tracker-indexer.c:
* src/trackerd/tracker-db.c:
* src/trackerd/tracker-query-tree.c: Renamed TrackerIndexItem to
TrackerDBIndexItem and TrackerSearchHit to TrackerDBIndexItemRank.
Also moved those both to libtracker-db from libtracker-common.
* utils/qdbm/Makefile.am:
* utils/qdbm/print-words.c:
* utils/qdbm/search-word.c: Fixed tools.
Added:
branches/indexer-split/src/libtracker-db/tracker-db-index-item.c
- copied, changed from r2017, /branches/indexer-split/src/libtracker-common/tracker-index-item.c
branches/indexer-split/src/libtracker-db/tracker-db-index-item.h
- copied, changed from r2018, /branches/indexer-split/src/libtracker-common/tracker-index-item.h
Removed:
branches/indexer-split/src/libtracker-common/tracker-index-item.c
branches/indexer-split/src/libtracker-common/tracker-index-item.h
branches/indexer-split/src/tracker-indexer/tracker-index.c
branches/indexer-split/src/tracker-indexer/tracker-index.h
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/configure.ac
branches/indexer-split/src/libtracker-common/Makefile.am
branches/indexer-split/src/libtracker-db/Makefile.am
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/tracker-indexer.c
branches/indexer-split/src/trackerd/tracker-db.c
branches/indexer-split/src/trackerd/tracker-query-tree.c
branches/indexer-split/tests/libtracker-common/tracker-type-utils-test.c
branches/indexer-split/tests/tracker-indexer/Makefile.am
branches/indexer-split/tests/tracker-indexer/tracker-index-test.c
branches/indexer-split/utils/qdbm/Makefile.am
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 08:53:24 2008
@@ -765,13 +765,6 @@
])
AC_CONFIG_HEADERS([config.h])
-#
-# 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-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/Makefile.am
==============================================================================
--- branches/indexer-split/src/libtracker-common/Makefile.am (original)
+++ branches/indexer-split/src/libtracker-common/Makefile.am Thu Aug 7 08:53:24 2008
@@ -38,8 +38,6 @@
tracker-field-data.h \
tracker-file-utils.c \
tracker-file-utils.h \
- tracker-index-item.c \
- tracker-index-item.h \
tracker-language.c \
tracker-language.h \
tracker-log.c \
Modified: branches/indexer-split/src/libtracker-db/Makefile.am
==============================================================================
--- branches/indexer-split/src/libtracker-db/Makefile.am (original)
+++ branches/indexer-split/src/libtracker-db/Makefile.am Thu Aug 7 08:53:24 2008
@@ -18,6 +18,8 @@
tracker-db-file-info.h \
tracker-db-index.c \
tracker-db-index.h \
+ tracker-db-index-item.c \
+ tracker-db-index-item.h \
tracker-db-index-manager.c \
tracker-db-index-manager.h \
tracker-db-interface.c \
Copied: branches/indexer-split/src/libtracker-db/tracker-db-index-item.c (from r2017, /branches/indexer-split/src/libtracker-common/tracker-index-item.c)
==============================================================================
--- /branches/indexer-split/src/libtracker-common/tracker-index-item.c (original)
+++ branches/indexer-split/src/libtracker-db/tracker-db-index-item.c Thu Aug 7 08:53:24 2008
@@ -18,11 +18,11 @@
* Boston, MA 02110-1301, USA.
*/
-#include "tracker-index-item.h"
+#include "tracker-db-index-item.h"
guint32
-tracker_index_item_calc_amalgamated (gint service_type,
- gint score)
+tracker_db_index_item_calc_amalgamated (gint service_type,
+ gint score)
{
unsigned char a[4];
gint16 score16;
@@ -48,28 +48,30 @@
}
guint8
-tracker_index_item_get_service_type (TrackerIndexItem *details)
+tracker_db_index_item_get_service_type (TrackerDBIndexItem *item)
{
- g_return_val_if_fail (details != NULL, 0);
+ g_return_val_if_fail (item != NULL, 0);
- return (details->amalgamated >> 24) & 0xFF;
+ return (item->amalgamated >> 24) & 0xFF;
}
gint16
-tracker_index_item_get_score (TrackerIndexItem *details)
+tracker_db_index_item_get_score (TrackerDBIndexItem *item)
{
unsigned char a[2];
- g_return_val_if_fail (details != NULL, 0);
+ g_return_val_if_fail (item != NULL, 0);
- a[0] = (details->amalgamated >> 16) & 0xFF;
- a[1] = (details->amalgamated >> 8) & 0xFF;
+ a[0] = (item->amalgamated >> 16) & 0xFF;
+ a[1] = (item->amalgamated >> 8) & 0xFF;
return (gint16) (a[0] << 8) | (a[1]);
}
guint32
-tracker_index_item_get_id (TrackerIndexItem *item)
+tracker_db_index_item_get_id (TrackerDBIndexItem *item)
{
+ g_return_val_if_fail (item != NULL, 0);
+
return item->id;
}
Copied: branches/indexer-split/src/libtracker-db/tracker-db-index-item.h (from r2018, /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-db/tracker-db-index-item.h Thu Aug 7 08:53:24 2008
@@ -18,8 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __TRACKER_INDEX_ITEM_H__
-#define __TRACKER_INDEX_ITEM_H__
+#ifndef __TRACKER_DB_INDEX_ITEM_H__
+#define __TRACKER_DB_INDEX_ITEM_H__
#include <glib.h>
@@ -33,20 +33,20 @@
* document's metadata.
*/
gint amalgamated;
-} TrackerIndexItem;
+} TrackerDBIndexItem;
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;
+} TrackerDBIndexItemRank;
-guint32 tracker_index_item_calc_amalgamated (gint service_type,
- gint score);
-guint8 tracker_index_item_get_service_type (TrackerIndexItem *details);
-gint16 tracker_index_item_get_score (TrackerIndexItem *details);
-guint32 tracker_index_item_get_id (TrackerIndexItem *details);
+guint32 tracker_db_index_item_calc_amalgamated (gint service_type,
+ gint score);
+guint8 tracker_db_index_item_get_service_type (TrackerDBIndexItem *details);
+gint16 tracker_db_index_item_get_score (TrackerDBIndexItem *details);
+guint32 tracker_db_index_item_get_id (TrackerDBIndexItem *details);
G_END_DECLS
-#endif /* __TRACKER_INDEX_ITEM_H__ */
+#endif /* __TRACKER_DB_INDEX_ITEM_H__ */
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 08:53:24 2008
@@ -516,11 +516,11 @@
tsiz = count_hit_size_for_word (index, str);
if (tsiz == -1 ||
- tsiz % sizeof (TrackerIndexItem) != 0) {
+ tsiz % sizeof (TrackerDBIndexItem) != 0) {
return -1;
}
- hits = tsiz / sizeof (TrackerIndexItem);
+ hits = tsiz / sizeof (TrackerDBIndexItem);
return hits;
}
@@ -564,32 +564,40 @@
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;
+ TrackerDBIndexItem *new_hit;
+ TrackerDBIndexItem *previous_hits;
+ GArray *pending_hits;
+ gboolean write_back;
+ gboolean edited;
+ gboolean result;
+ gint old_hit_count;
+ gint score;
+ gint tsiz;
+ guint j;
+ gint i, 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);
+ write_back = FALSE;
+ edited = FALSE;
+ old_hit_count = 0;
+ pending_hits = NULL;
+
+ previous_hits = (TrackerDBIndexItem *) 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),
+ new_hits->len * sizeof (TrackerDBIndexItem),
DP_DCAT);
if (!result) {
@@ -601,10 +609,10 @@
}
/* Word already exists */
- old_hit_count = tsiz / sizeof (TrackerIndexItem);
+ old_hit_count = tsiz / sizeof (TrackerDBIndexItem);
for (j = 0; j < new_hits->len; j++) {
- new_hit = &g_array_index (new_hits, TrackerIndexItem, j);
+ new_hit = &g_array_index (new_hits, TrackerDBIndexItem, j);
edited = FALSE;
for (i = 0; i < old_hit_count; i++) {
@@ -612,8 +620,8 @@
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);
+ score = tracker_db_index_item_get_score (&previous_hits[i]);
+ score += tracker_db_index_item_get_score (new_hit);
/* Check for deletion */
if (score < 1) {
@@ -626,9 +634,11 @@
} else {
guint32 service_type;
- service_type = tracker_index_item_get_service_type (&previous_hits[i]);
+ service_type =
+ tracker_db_index_item_get_service_type (&previous_hits[i]);
previous_hits[i].amalgamated =
- tracker_index_item_calc_amalgamated (service_type, score);
+ tracker_db_index_item_calc_amalgamated (service_type,
+ score);
}
edited = TRUE;
@@ -641,7 +651,7 @@
*/
if (!edited) {
if (!pending_hits) {
- pending_hits = g_array_new (FALSE, TRUE, sizeof (TrackerIndexItem));
+ pending_hits = g_array_new (FALSE, TRUE, sizeof (TrackerDBIndexItem));
}
g_array_append_val (pending_hits, *new_hit);
@@ -659,7 +669,7 @@
dpput (index,
word, -1,
(char *) previous_hits,
- old_hit_count * sizeof (TrackerIndexItem),
+ old_hit_count * sizeof (TrackerDBIndexItem),
DP_DOVER);
}
}
@@ -669,7 +679,7 @@
dpput (index,
word, -1,
(char*) pending_hits->data,
- pending_hits->len * sizeof (TrackerIndexItem),
+ pending_hits->len * sizeof (TrackerDBIndexItem),
DP_DCAT);
g_array_free (pending_hits, TRUE);
}
@@ -904,15 +914,15 @@
return winner_str;
}
-TrackerIndexItem *
+TrackerDBIndexItem *
tracker_db_index_get_word_hits (TrackerDBIndex *index,
const gchar *word,
guint *count)
{
TrackerDBIndexPrivate *priv;
- TrackerIndexItem *details;
- gint tsiz;
- gchar *tmp;
+ TrackerDBIndexItem *details;
+ gint tsiz;
+ gchar *tmp;
g_return_val_if_fail (TRACKER_IS_DB_INDEX (index), NULL);
g_return_val_if_fail (word != NULL, NULL);
@@ -932,11 +942,11 @@
}
if ((tmp = dpget (priv->index, word, -1, 0, MAX_HIT_BUFFER, &tsiz)) != NULL) {
- if (tsiz >= (gint) sizeof (TrackerIndexItem)) {
- details = (TrackerIndexItem *) tmp;
+ if (tsiz >= (gint) sizeof (TrackerDBIndexItem)) {
+ details = (TrackerDBIndexItem *) tmp;
if (count) {
- *count = tsiz / sizeof (TrackerIndexItem);
+ *count = tsiz / sizeof (TrackerDBIndexItem);
}
}
}
@@ -954,8 +964,8 @@
gint weight)
{
TrackerDBIndexPrivate *priv;
- TrackerIndexItem elem;
- TrackerIndexItem *current;
+ TrackerDBIndexItem elem;
+ TrackerDBIndexItem *current;
GArray *array;
guint i, new_score;
@@ -965,7 +975,7 @@
priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
elem.id = service_id;
- elem.amalgamated = tracker_index_item_calc_amalgamated (service_type, weight);
+ elem.amalgamated = tracker_db_index_item_calc_amalgamated (service_type, weight);
array = g_hash_table_lookup (priv->cache, word);
@@ -973,7 +983,7 @@
/* Create the array if it didn't exist (first time we
* find the word)
*/
- array = g_array_new (FALSE, TRUE, sizeof (TrackerIndexItem));
+ array = g_array_new (FALSE, TRUE, sizeof (TrackerDBIndexItem));
g_hash_table_insert (priv->cache, g_strdup (word), array);
g_array_append_val (array, elem);
return;
@@ -981,13 +991,13 @@
/* It is not the first time we find the word */
for (i = 0; i < array->len; i++) {
- current = &g_array_index (array, TrackerIndexItem, i);
+ current = &g_array_index (array, TrackerDBIndexItem, 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;
+ new_score = tracker_db_index_item_get_score (current) + weight;
if (new_score < 1) {
array = g_array_remove_index (array, i);
if (array->len == 0) {
@@ -996,8 +1006,11 @@
} else {
guint32 service_type;
- service_type = tracker_index_item_get_service_type (current);
- current->amalgamated = tracker_index_item_calc_amalgamated (service_type, new_score);
+ service_type =
+ tracker_db_index_item_get_service_type (current);
+ current->amalgamated =
+ tracker_db_index_item_calc_amalgamated (service_type,
+ new_score);
}
return;
@@ -1048,36 +1061,38 @@
return FALSE;
}
- if (tsiz >= (int) sizeof (TrackerIndexItem)) {
- TrackerIndexItem *details;
- gint wi, i, pnum;
+ if (tsiz >= (int) sizeof (TrackerDBIndexItem)) {
+ TrackerDBIndexItem *details;
+ gint wi, i, pnum;
- details = (TrackerIndexItem *) tmp;
- pnum = tsiz / sizeof (TrackerIndexItem);
+ details = (TrackerDBIndexItem *) tmp;
+ pnum = tsiz / sizeof (TrackerDBIndexItem);
wi = 0;
for (i = 0; i < pnum; i++) {
GSList *lst;
for (lst = dud_list; lst; lst = lst->next) {
- TrackerSearchHit *hit = lst->data;
+ TrackerDBIndexItemRank *rank = lst->data;
- if (hit) {
- if (details[i].id == hit->service_id) {
- gint k;
-
- /* Shift all subsequent records in array down one place */
- for (k = i + 1; k < pnum; k++) {
- details[k - 1] = details[k];
- }
-
- /* Make size of array one size smaller */
- tsiz -= sizeof (TrackerIndexItem);
- pnum--;
-
- break;
- }
- }
+ if (!rank) {
+ continue;
+ }
+
+ if (details[i].id == rank->service_id) {
+ gint k;
+
+ /* Shift all subsequent records in array down one place */
+ for (k = i + 1; k < pnum; k++) {
+ details[k - 1] = details[k];
+ }
+
+ /* Make size of array one size smaller */
+ tsiz -= sizeof (TrackerDBIndexItem);
+ pnum--;
+
+ break;
+ }
}
}
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 08:53:24 2008
@@ -26,7 +26,8 @@
#include <glib-object.h>
-#include <libtracker-common/tracker-index-item.h>
+#include <libtracker-db/tracker-db-index-item.h>
+
#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))
@@ -47,45 +48,45 @@
GObjectClass parent_class;
};
-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);
+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);
+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);
+guint32 tracker_db_index_get_size (TrackerDBIndex *index);
+char * tracker_db_index_get_suggestion (TrackerDBIndex *index,
+ const gchar *term,
+ gint maxdist);
+TrackerDBIndexItem *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
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 08:53:24 2008
@@ -70,7 +70,6 @@
#include "tracker-indexer.h"
#include "tracker-indexer-module.h"
#include "tracker-indexer-db.h"
-#include "tracker-index.h"
#include "tracker-module.h"
#include "tracker-marshal.h"
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 08:53:24 2008
@@ -694,15 +694,15 @@
count = 0;
for (i = 0; i < hits->len; i++) {
- TrackerSearchHit hit;
- char *str_id;
+ TrackerDBIndexItemRank rank;
+ gchar *str_id;
if (count >= limit) {
break;
}
- hit = g_array_index (hits, TrackerSearchHit, i);
- str_id = tracker_uint_to_string (hit.service_id);
+ rank = g_array_index (hits, TrackerDBIndexItemRank, i);
+ str_id = tracker_uint_to_string (rank.service_id);
/* We save results into SearchResults table instead of
* returing an array of array of strings
@@ -710,7 +710,7 @@
if (save_results) {
gchar *str_score;
- str_score = tracker_int_to_string (hit.score);
+ str_score = tracker_int_to_string (rank.score);
tracker_db_exec_proc (iface,
"InsertSearchResult1",
str_id,
@@ -775,7 +775,7 @@
g_object_unref (result_set);
} else {
g_message ("Dud hit for search detected");
- duds = g_slist_prepend (duds, &hit);
+ duds = g_slist_prepend (duds, &rank);
}
}
@@ -845,13 +845,13 @@
hits = tracker_query_tree_get_hits (tree, 0, 0);
for (i = 0, count = 0; i < hits->len; i++) {
- TrackerDBResultSet *result_set2;
- TrackerSearchHit hit;
- gchar *str_id, *mimetype;
+ TrackerDBResultSet *result_set2;
+ TrackerDBIndexItemRank rank;
+ gchar *str_id, *mimetype;
- hit = g_array_index (hits, TrackerSearchHit, i);
+ rank = g_array_index (hits, TrackerDBIndexItemRank, i);
- str_id = tracker_uint_to_string (hit.service_id);
+ str_id = tracker_uint_to_string (rank.service_id);
result_set2 = tracker_db_exec_proc (iface,
"GetFileByID",
str_id,
@@ -941,13 +941,13 @@
hits = tracker_query_tree_get_hits (tree, 0, 0);
for (i = 0, count = 0; i < hits->len; i++) {
- TrackerDBResultSet *result_set2;
- TrackerSearchHit hit;
- gchar *str_id, *path;
+ TrackerDBResultSet *result_set2;
+ TrackerDBIndexItemRank rank;
+ gchar *str_id, *path;
- hit = g_array_index (hits, TrackerSearchHit, i);
+ rank = g_array_index (hits, TrackerDBIndexItemRank, i);
- str_id = tracker_uint_to_string (hit.service_id);
+ str_id = tracker_uint_to_string (rank.service_id);
result_set2 = tracker_db_exec_proc (iface,
"GetFileByID",
str_id,
@@ -1039,17 +1039,17 @@
hits = tracker_query_tree_get_hits (tree, 0, 0);
for (i = 0, count = 0; i < hits->len; i++) {
- TrackerDBResultSet *result_set2;
- TrackerSearchHit hit;
- gchar *str_id, *path, *mimetype;
+ TrackerDBResultSet *result_set2;
+ TrackerDBIndexItemRank rank;
+ gchar *str_id, *path, *mimetype;
- hit = g_array_index (hits, TrackerSearchHit, i);
+ rank = g_array_index (hits, TrackerDBIndexItemRank, i);
- str_id = tracker_uint_to_string (hit.service_id);
+ str_id = tracker_uint_to_string (rank.service_id);
result_set2 = tracker_db_exec_proc (iface,
- "GetFileByID",
- str_id,
- NULL);
+ "GetFileByID",
+ str_id,
+ NULL);
g_free (str_id);
if (result_set2) {
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 08:53:24 2008
@@ -35,7 +35,8 @@
#include <libtracker-common/tracker-config.h>
#include <libtracker-common/tracker-parser.h>
#include <libtracker-common/tracker-ontology.h>
-#include <libtracker-common/tracker-index-item.h>
+
+#include <libtracker-db/tracker-db-index-item.h>
#include "tracker-query-tree.h"
#include "tracker-utils.h"
@@ -656,13 +657,13 @@
}
static gint
-get_idf_score (TrackerIndexItem *details,
- gfloat idf)
+get_idf_score (TrackerDBIndexItem *details,
+ gfloat idf)
{
guint32 score;
gfloat f;
- score = tracker_index_item_get_score (details);
+ score = tracker_db_index_item_get_score (details);
f = idf * score * SCORE_MULTIPLIER;
return (f > 1.0) ? lrintf (f) : 1;
@@ -695,7 +696,7 @@
const gchar *term)
{
TrackerQueryTreePrivate *priv;
- TrackerIndexItem *details;
+ TrackerDBIndexItem *details;
GHashTable *result;
guint count, i;
@@ -712,7 +713,7 @@
SearchHitData *data;
gint service;
- service = tracker_index_item_get_service_type (&details[i]);
+ service = tracker_db_index_item_get_service_type (&details[i]);
if (in_array (priv->services, service)) {
data = g_slice_new (SearchHitData);
@@ -826,27 +827,27 @@
gpointer user_data)
{
GArray *array;
- TrackerSearchHit hit;
+ TrackerDBIndexItemRank rank;
SearchHitData *hit_data;
array = (GArray *) user_data;
hit_data = (SearchHitData *) value;
- hit.service_id = GPOINTER_TO_UINT (key);
- hit.service_type_id = hit_data->service_type_id;
- hit.score = hit_data->score;
+ rank.service_id = GPOINTER_TO_UINT (key);
+ rank.service_type_id = hit_data->service_type_id;
+ rank.score = hit_data->score;
- g_array_append_val (array, hit);
+ g_array_append_val (array, rank);
}
static gint
compare_search_hits (gconstpointer a,
gconstpointer b)
{
- TrackerSearchHit *ap, *bp;
+ TrackerDBIndexItemRank *ap, *bp;
- ap = (TrackerSearchHit *) a;
- bp = (TrackerSearchHit *) b;
+ ap = (TrackerDBIndexItemRank *) a;
+ bp = (TrackerDBIndexItemRank *) b;
return (bp->score - ap->score);
}
@@ -867,7 +868,7 @@
g_return_val_if_fail (priv->tree != NULL, NULL);
table = get_node_hits (tree, priv->tree);
- array = g_array_sized_new (TRUE, TRUE, sizeof (TrackerSearchHit),
+ array = g_array_sized_new (TRUE, TRUE, sizeof (TrackerDBIndexItemRank),
g_hash_table_size (table));
g_hash_table_foreach (table, (GHFunc) get_hits_foreach, array);
@@ -933,23 +934,33 @@
counts = g_array_sized_new (TRUE, TRUE, sizeof (TrackerHitCount), 10);
for (i = 0; i < hits->len; i++) {
- TrackerSearchHit hit;
+ TrackerDBIndexItemRank rank;
+ gpointer p;
gint count, parent_id;
- hit = g_array_index (hits, TrackerSearchHit, i);
- count = GPOINTER_TO_INT (g_hash_table_lookup (table, GINT_TO_POINTER (hit.service_type_id)));
+ rank = g_array_index (hits, TrackerDBIndexItemRank, i);
+ p = g_hash_table_lookup (table,
+ GINT_TO_POINTER (rank.service_type_id));
+ count = GPOINTER_TO_INT (p);
count++;
- g_hash_table_insert (table, GINT_TO_POINTER (hit.service_type_id), GINT_TO_POINTER (count));
-
- /* update service's parent count too (if it has a parent) */
- parent_id = tracker_ontology_get_parent_id_for_service_id (hit.service_type_id);
+ g_hash_table_insert (table,
+ GINT_TO_POINTER (rank.service_type_id),
+ GINT_TO_POINTER (count));
+
+ /* Update service's parent count too (if it has a
+ * parent).
+ */
+ parent_id = tracker_ontology_get_parent_id_for_service_id (rank.service_type_id);
if (parent_id != -1) {
- count = GPOINTER_TO_INT (g_hash_table_lookup (table, GINT_TO_POINTER (parent_id)));
+ p = g_hash_table_lookup (table, GINT_TO_POINTER (parent_id));
+ count = GPOINTER_TO_INT (p);
count++;
- g_hash_table_insert (table, GINT_TO_POINTER (parent_id), GINT_TO_POINTER (count));
+ g_hash_table_insert (table,
+ GINT_TO_POINTER (parent_id),
+ GINT_TO_POINTER (count));
}
}
Modified: branches/indexer-split/tests/libtracker-common/tracker-type-utils-test.c
==============================================================================
--- branches/indexer-split/tests/libtracker-common/tracker-type-utils-test.c (original)
+++ branches/indexer-split/tests/libtracker-common/tracker-type-utils-test.c Thu Aug 7 08:53:24 2008
@@ -17,13 +17,16 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-#include <glib.h>
-#include <glib/gtestutils.h>
#include <time.h>
#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <glib/gtestutils.h>
+
#include <libtracker-common/tracker-type-utils.h>
+
#include <tracker-test-helpers.h>
static void
Modified: branches/indexer-split/tests/tracker-indexer/Makefile.am
==============================================================================
--- branches/indexer-split/tests/tracker-indexer/Makefile.am (original)
+++ branches/indexer-split/tests/tracker-indexer/Makefile.am Thu Aug 7 08:53:24 2008
@@ -17,11 +17,11 @@
tracker_index_SOURCES = \
- tracker-index-test.c \
- $(top_srcdir)/src/tracker-indexer/tracker-index.c
+ tracker-index-test.c
-tracker_index_LDADD = \
+tracker_index_LDADD = \
$(top_builddir)/src/libtracker-common/libtracker-common.la \
+ $(top_builddir)/src/libtracker-db/libtracker-db.la \
$(top_builddir)/tests/common/libtracker-testcommon.la \
$(QDBM_LIBS) \
$(GMODULE_LIBS) \
Modified: branches/indexer-split/tests/tracker-indexer/tracker-index-test.c
==============================================================================
--- branches/indexer-split/tests/tracker-indexer/tracker-index-test.c (original)
+++ branches/indexer-split/tests/tracker-indexer/tracker-index-test.c Thu Aug 7 08:53:24 2008
@@ -1,10 +1,12 @@
+#include <qdbm/depot.h>
+
#include <glib.h>
+#include <glib-object.h>
#include <glib/gtestutils.h>
#include <glib/gstdio.h>
-#include <tracker-indexer/tracker-index.h>
-#include <libtracker-common/tracker-index-item.h>
-#include <qdbm/depot.h>
+#include <libtracker-db/tracker-db-index.h>
+#include <libtracker-db/tracker-db-index-item.h>
#define BUCKET_COUNT 100
@@ -36,7 +38,7 @@
dpclose (index);
- return result / sizeof (TrackerIndexItem);
+ return result / sizeof (TrackerDBIndexItem);
}
gint
@@ -44,19 +46,19 @@
{
DEPOT *index;
gint tsiz;
- TrackerIndexItem *results;
+ TrackerDBIndexItem *results;
gint score;
index = dpopen (index_file, DP_OREADER, BUCKET_COUNT);
- results = (TrackerIndexItem *)dpget (index, word, -1, 0, -1, &tsiz);
+ results = (TrackerDBIndexItem *)dpget (index, word, -1, 0, -1, &tsiz);
dpclose (index);
- g_return_val_if_fail ((tsiz / sizeof (TrackerIndexItem)) == 1, -1);
+ g_return_val_if_fail ((tsiz / sizeof (TrackerDBIndexItem)) == 1, -1);
g_return_val_if_fail (results, -1);
- score = tracker_index_item_get_score (&results[0]);
+ score = tracker_db_index_item_get_score (&results[0]);
g_free (results);
return score;
@@ -68,7 +70,7 @@
DEPOT *index;
gint rsiz, elements, i;
gchar *iter;
- TrackerIndexItem *results;
+ TrackerDBIndexItem *results;
g_print ("Contents of %s\n", index_file);
@@ -78,13 +80,13 @@
while ((iter = dpiternext (index, NULL)) != NULL) {
g_print ("word: %s doc_ids:", iter);
- results = (TrackerIndexItem *)dpget (index, iter, -1, 0, -1, &rsiz);
+ results = (TrackerDBIndexItem *)dpget (index, iter, -1, 0, -1, &rsiz);
if (!results) {
g_print ("[No results]\n");
continue;
} else {
- elements = rsiz / sizeof (TrackerIndexItem);
+ elements = rsiz / sizeof (TrackerDBIndexItem);
for (i = 0; i < elements; i++) {
g_print ("%d ", results[i].id);
}
@@ -102,15 +104,15 @@
static void
test_add_one_word ()
{
- TrackerIndex *index;
+ TrackerDBIndex *index;
const gchar *indexname = "test-add-one-word.index";
g_remove (indexname);
- index = tracker_index_new (indexname, BUCKET_COUNT);
+ index = tracker_db_index_new (indexname, 0, BUCKET_COUNT, FALSE);
- tracker_index_add_word (index, "word1", 1, 1, 1);
- tracker_index_flush (index);
- tracker_index_free (index);
+ tracker_db_index_add_word (index, "word1", 1, 1, 1);
+ tracker_db_index_flush (index);
+ g_object_unref (index);
g_assert_cmpint (get_number_words_in_index (indexname), ==, 1);
g_assert_cmpint (get_results_for_word (indexname, "word1"), ==, 1);
@@ -122,7 +124,7 @@
static void
test_add_n_words ()
{
- TrackerIndex *index;
+ TrackerDBIndex *index;
const gchar *indexname = "test-add-n-words.index";
gint i;
gchar *word;
@@ -130,16 +132,16 @@
g_remove (indexname);
g_remove (indexname);
- index = tracker_index_new (indexname, BUCKET_COUNT);
+ index = tracker_db_index_new (indexname, 0, BUCKET_COUNT, FALSE);
for ( i = 0; i < 20; i++) {
word = g_strdup_printf ("word%d", i);
- tracker_index_add_word (index, word, 1, 1, 1);
+ tracker_db_index_add_word (index, word, 1, 1, 1);
g_free (word);
}
- tracker_index_flush (index);
- tracker_index_free (index);
+ tracker_db_index_flush (index);
+ g_object_unref (index);
g_assert_cmpint (get_number_words_in_index (indexname), ==, 20);
g_assert_cmpint (get_results_for_word (indexname, "word5"), ==, 1);
@@ -149,19 +151,19 @@
static void
test_add_word_n_times ()
{
- TrackerIndex *index;
+ TrackerDBIndex *index;
gint i;
const gchar *indexname = "test-add-word-n-times.index";
g_remove (indexname);
- index = tracker_index_new (indexname, BUCKET_COUNT);
+ index = tracker_db_index_new (indexname, 0, BUCKET_COUNT, FALSE);
for ( i = 0; i < 20; i++) {
- tracker_index_add_word (index, "test-word", i, 1, 1);
+ tracker_db_index_add_word (index, "test-word", i, 1, 1);
}
- tracker_index_flush (index);
- tracker_index_free (index);
+ tracker_db_index_flush (index);
+ g_object_unref (index);
g_assert_cmpint (get_number_words_in_index (indexname), ==, 1);
g_assert_cmpint (get_results_for_word (indexname, "test-word"), ==, 20);
@@ -172,19 +174,19 @@
static void
test_add_word_multiple_occurrences ()
{
- TrackerIndex *index;
+ TrackerDBIndex *index;
gint i;
const gchar *indexname = "test-word-multiple-ocurrences.index";
g_remove (indexname);
- index = tracker_index_new (indexname, BUCKET_COUNT);
+ index = tracker_db_index_new (indexname, 0, BUCKET_COUNT, FALSE);
for ( i = 0; i < 20; i++) {
- tracker_index_add_word (index, "test-word", 1, 1, 1);
+ tracker_db_index_add_word (index, "test-word", 1, 1, 1);
}
- tracker_index_flush (index);
- tracker_index_free (index);
+ tracker_db_index_flush (index);
+ g_object_unref (index);
g_assert_cmpint (get_number_words_in_index (indexname), ==, 1);
@@ -197,7 +199,7 @@
}
gint
-insert_in_index (TrackerIndex *index, const gchar *text)
+insert_in_index (TrackerDBIndex *index, const gchar *text)
{
gchar **pieces;
gint i;
@@ -207,7 +209,7 @@
pieces = g_strsplit (text, " ", -1);
for (i = 0; pieces[i] != NULL; i++) {
- tracker_index_add_word (index, pieces[i], doc, 1, 1);
+ tracker_db_index_add_word (index, pieces[i], doc, 1, 1);
}
g_strfreev (pieces);
@@ -218,24 +220,24 @@
test_add_with_flushs ()
{
- TrackerIndex *index;
+ TrackerDBIndex *index;
const gchar *indexname = "test-add-with-flush.index";
const gchar *text1 = "this is a text to try a kind of real use case of the indexer";
const gchar *text2 = "this is another text with some common words";
g_remove (indexname);
- index = tracker_index_new (indexname, BUCKET_COUNT);
+ index = tracker_db_index_new (indexname, 0, BUCKET_COUNT, FALSE);
/* Text 1 */
insert_in_index (index, text1);
- tracker_index_flush (index);
+ tracker_db_index_flush (index);
/* Text 2 */
insert_in_index (index, text2);
- tracker_index_flush (index);
+ tracker_db_index_flush (index);
- tracker_index_free (index);
+ g_object_unref (index);
g_assert_cmpint (get_number_words_in_index (indexname), ==, 18);
g_assert_cmpint (get_results_for_word (indexname, "this"), ==, 2);
@@ -246,7 +248,7 @@
}
void
-remove_in_index (TrackerIndex *index, const gchar *text, gint docid)
+remove_in_index (TrackerDBIndex *index, const gchar *text, gint docid)
{
gchar **pieces;
gint i;
@@ -254,7 +256,7 @@
pieces = g_strsplit (text, " ", -1);
for (i = 0; pieces[i] != NULL; i++) {
- tracker_index_add_word (index, pieces[i], docid, 1, -1);
+ tracker_db_index_add_word (index, pieces[i], docid, 1, -1);
}
g_strfreev (pieces);
@@ -265,7 +267,7 @@
static void
test_remove_document ()
{
- TrackerIndex *index;
+ TrackerDBIndex *index;
const gchar *indexname = "test-remove-document.index";
gint id1, id2;
@@ -274,27 +276,27 @@
g_remove (indexname);
- index = tracker_index_new (indexname, BUCKET_COUNT);
+ index = tracker_db_index_new (indexname, 0, BUCKET_COUNT, FALSE);
/* Doc 1 */
id1 = insert_in_index (index, doc1);
- tracker_index_flush (index);
+ tracker_db_index_flush (index);
/* Doc 2 */
id2 = insert_in_index (index, doc2);
- tracker_index_flush (index);
+ tracker_db_index_flush (index);
- tracker_index_free (index);
+ g_object_unref (index);
g_assert_cmpint (get_number_words_in_index (indexname), ==, 18);
- index = tracker_index_new (indexname, BUCKET_COUNT);
+ index = tracker_db_index_new (indexname, 0, BUCKET_COUNT, FALSE);
/* Remove doc1 */
remove_in_index (index, doc1, id1);
- tracker_index_flush (index);
+ tracker_db_index_flush (index);
- tracker_index_free (index);
+ g_object_unref (index);
g_assert_cmpint (get_number_words_in_index (indexname), ==, 8);
@@ -304,7 +306,7 @@
static void
test_remove_before_flush (void)
{
- TrackerIndex *index;
+ TrackerDBIndex *index;
const gchar *indexname = "test-remove-before-flush.index";
gint id1;
@@ -312,7 +314,7 @@
g_remove (indexname);
- index = tracker_index_new (indexname, BUCKET_COUNT);
+ index = tracker_db_index_new (indexname, 0, BUCKET_COUNT, FALSE);
/* Doc 1 */
id1 = insert_in_index (index, doc1);
@@ -320,9 +322,9 @@
/* Remove before flush */
remove_in_index (index, doc1, id1);
- tracker_index_flush (index);
+ tracker_db_index_flush (index);
- tracker_index_free (index);
+ g_object_unref (index);
g_assert_cmpint (get_number_words_in_index (indexname), ==, 0);
Modified: branches/indexer-split/utils/qdbm/Makefile.am
==============================================================================
--- branches/indexer-split/utils/qdbm/Makefile.am (original)
+++ branches/indexer-split/utils/qdbm/Makefile.am Thu Aug 7 08:53:24 2008
@@ -1,23 +1,25 @@
noinst_PROGRAMS = print search
-INCLUDES = \
- -DG_LOG_DOMAIN=\"Tracker\" \
- -I$(top_srcdir)/src \
- $(QDBM_CFLAGS) \
+INCLUDES = \
+ -DG_LOG_DOMAIN=\"Tracker\" \
+ -I$(top_srcdir)/src \
+ $(QDBM_CFLAGS) \
$(GLIB2_CFLAGS)
-print_SOURCES = \
+print_SOURCES = \
print-words.c
print_LDADD = \
$(top_builddir)/src/libtracker-common/libtracker-common.la \
+ $(top_builddir)/src/libtracker-db/libtracker-db.la \
$(QDBM_LIBS) \
$(GLIB2_LIBS)
-search_SOURCES = \
+search_SOURCES = \
search-word.c
-search_LDADD = \
- $(QDBM_LIBS) \
+search_LDADD = \
+ $(top_builddir)/src/libtracker-db/libtracker-db.la \
+ $(QDBM_LIBS) \
$(GLIB2_LIBS)
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 08:53:24 2008
@@ -1,11 +1,34 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia
+
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
#include <depot.h>
+
#include <glib.h>
-#include <libtracker-common/tracker-index-item.h>
+
+#include <libtracker-db/tracker-db-index-item.h>
#define USAGE "Usage: print -f qdbm-file\n"
-static gchar *filename = NULL;
-static gboolean print_services = FALSE;
+static gchar *filename;
+static gboolean print_services;
static GOptionEntry entries_qdbm[] = {
{ "index-file", 'f', 0,
@@ -19,15 +42,14 @@
{ NULL }
};
-
-TrackerIndexItem *
-tracker_indexer_get_word_hits (DEPOT *index,
- const gchar *word,
- guint *count)
+TrackerDBIndexItem *
+get_word_hits (DEPOT *index,
+ const gchar *word,
+ guint *count)
{
- TrackerIndexItem *details;
- gint tsiz;
- gchar *tmp;
+ TrackerDBIndexItem *details;
+ gint tsiz;
+ gchar *tmp;
g_return_val_if_fail (word != NULL, NULL);
@@ -38,11 +60,11 @@
}
if ((tmp = dpget (index, word, -1, 0, 100, &tsiz)) != NULL) {
- if (tsiz >= (gint) sizeof (TrackerIndexItem)) {
- details = (TrackerIndexItem *) tmp;
+ if (tsiz >= (gint) sizeof (TrackerDBIndexItem)) {
+ details = (TrackerDBIndexItem *) tmp;
if (count) {
- *count = tsiz / sizeof (TrackerIndexItem);
+ *count = tsiz / sizeof (TrackerDBIndexItem);
}
}
}
@@ -51,37 +73,38 @@
}
void
-load_terms_from_index (gchar* filename)
+load_terms_from_index (gchar *filename)
{
- DEPOT *depot;
- char *key;
- guint hits, i;
- TrackerIndexItem *results;
+ DEPOT *depot;
+ gchar *key;
+ guint hits, i;
+ TrackerDBIndexItem *results;
depot = dpopen (filename, DP_OREADER | DP_ONOLCK, -1);
- if ( depot == NULL ) {
- g_print ("Unable to open file: %s (Could be a lock problem: is tracker running?)\n", filename);
- g_print ("Using version %s of qdbm\n", dpversion);
+ if (depot == NULL) {
+ g_print ("Unable to open file: %s "
+ "(Could be a lock problem: is tracker running?)\n",
+ filename);
+ g_print ("Using version %s of qdbm\n",
+ dpversion);
return;
}
-
dpiterinit (depot);
key = dpiternext (depot, NULL);
- while ( key != NULL ) {
-
+ while (key != NULL) {
g_print (" - %s ", key);
if (print_services) {
- results = tracker_indexer_get_word_hits (depot, key, &hits);
+ results = get_word_hits (depot, key, &hits);
for (i = 0; i < hits; i++) {
g_print (" (id:%d t:%d s:%d) ",
- tracker_index_item_get_id (&results[i]),
- tracker_index_item_get_service_type (&results[i]),
- tracker_index_item_get_score (&results[i]));
+ tracker_db_index_item_get_id (&results[i]),
+ tracker_db_index_item_get_service_type (&results[i]),
+ tracker_db_index_item_get_score (&results[i]));
}
}
@@ -92,17 +115,14 @@
g_print ("Total: %d terms.\n", dprnum (depot));
dpclose (depot);
-
}
-
int
main (gint argc, gchar** argv)
{
-
GOptionContext *context;
- GOptionGroup *group;
- GError *error = NULL;
+ GOptionGroup *group;
+ GError *error = NULL;
context = g_option_context_new ("- QDBM index printer");
/* Daemon group */
@@ -130,6 +150,7 @@
load_terms_from_index (filename);
- g_print ("ok\n");
- return 0;
+ g_print ("OK\n");
+
+ return EXIT_SUCCESS;
}
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 08:53:24 2008
@@ -1,12 +1,33 @@
-#include <depot.h>
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia
+
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
#include <glib.h>
-#define USAGE "Usage: print -f qdbm-file -w word\n"
+#include <depot.h>
+
+#include <libtracker-db/tracker-db-index-item.h>
-static gchar *filename = NULL;
-static gchar *word = NULL;
+static gchar *filename;
+static gchar *word;
-static GOptionEntry entries_qdbm[] = {
+static GOptionEntry entries[] = {
{ "index-file", 'f', 0,
G_OPTION_ARG_STRING, &filename,
"QDBM index file",
@@ -18,86 +39,68 @@
{ NULL }
};
-
-typedef struct {
- /* Service ID number of the document */
- guint32 id;
-
- /* Amalgamation of service_type and score of the word in the
- * document's metadata.
- */
- gint amalgamated;
-} TrackerIndexerWordDetails;
-
-TrackerIndexerWordDetails *
-tracker_indexer_get_word_hits (DEPOT *index,
- const gchar *word,
- guint *count)
+TrackerDBIndexItem *
+get_word_hits (DEPOT *index,
+ const gchar *word,
+ guint *count)
{
- TrackerIndexerWordDetails *details;
- gint tsiz;
- gchar *tmp;
-
+ TrackerDBIndexItem *items;
+ gchar *tmp;
+ gint tsiz;
+
g_return_val_if_fail (word != NULL, NULL);
- details = NULL;
+ items = NULL;
if (count) {
*count = 0;
}
if ((tmp = dpget (index, word, -1, 0, 1000000, &tsiz)) != NULL) {
- if (tsiz >= (gint) sizeof (TrackerIndexerWordDetails)) {
- details = (TrackerIndexerWordDetails *) tmp;
+ if (tsiz >= (gint) sizeof (TrackerDBIndexItem)) {
+ items = (TrackerDBIndexItem *) tmp;
if (count) {
- *count = tsiz / sizeof (TrackerIndexerWordDetails);
+ *count = tsiz / sizeof (TrackerDBIndexItem);
}
}
}
- return details;
-}
-
-
-guint8
-tracker_indexer_word_details_get_service_type (TrackerIndexerWordDetails *details)
-{
- g_return_val_if_fail (details != NULL, 0);
-
- return (details->amalgamated >> 24) & 0xFF;
+ return items;
}
-
void
-show_term_in_index (const gchar* filename, const gchar *word){
-
- DEPOT *depot;
- gint hits, i;
- TrackerIndexerWordDetails *results;
+show_term_in_index (const gchar *filename,
+ const gchar *word)
+{
+ TrackerDBIndexItem *items;
+ DEPOT *depot;
+ guint hits, i;
depot = dpopen (filename, DP_OREADER, -1);
- if ( depot == NULL ) {
- g_print ("Unable to open file: %s (Could be a lock problem: is tracker running?)\n", filename);
- g_print ("Using version %s of qdbm\n", dpversion);
+ if (depot == NULL) {
+ g_print ("Unable to open file: %s "
+ "(Could be a lock problem: is tracker running?)\n",
+ filename);
+ g_print ("Using version %s of qdbm\n",
+ dpversion);
return;
}
-
- results = tracker_indexer_get_word_hits (depot, word, &hits);
+ items = get_word_hits (depot, word, &hits);
if (hits < 1 ) {
g_print ("No results for %s\n", word);
return;
}
- g_print (" - %s ", word);
+ g_print (" - %s ", word);
for (i = 0; i < hits; i++) {
g_print (" (id:%d t:%d) ",
- results[i].id,
- tracker_indexer_word_details_get_service_type (&results[i]));
+ items[i].id,
+ tracker_db_index_item_get_service_type (&items[i]));
}
g_print ("\n");
@@ -107,41 +110,39 @@
}
-
int
main (gint argc, gchar** argv)
{
-
GOptionContext *context;
- GOptionGroup *group;
- GError *error = NULL;
- context = g_option_context_new ("- QDBM index searcher");
-
- /* Daemon group */
- group = g_option_group_new ("qdbm",
- "QDBM searcher Options",
- "Show searcher options",
- NULL,
- NULL);
- g_option_group_add_entries (group, entries_qdbm);
- g_option_context_add_group (context, group);
+ GError *error = NULL;
+ context = g_option_context_new ("- QDBM index searcher");
+ g_option_context_add_main_entries (context, entries, NULL);
g_option_context_parse (context, &argc, &argv, &error);
- g_option_context_free (context);
if (error) {
g_printerr ("Invalid arguments, %s\n", error->message);
+ g_option_context_free (context);
g_clear_error (&error);
return EXIT_FAILURE;
}
- if (!filename || !word) {
- g_printerr (USAGE);
+ if (!filename || !word) {
+ gchar *help;
+
+ help = g_option_context_get_help (context, TRUE, NULL);
+ g_option_context_free (context);
+ g_free (help);
+ g_printerr (help);
+
return EXIT_FAILURE;
}
+ g_option_context_free (context);
+
show_term_in_index (filename, word);
- g_print ("ok\n");
+ g_print ("OK\n");
+
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]