[tracker/rss-enclosures] tracker-store, libtracker-bus, -client: Implement get_value_types for steroids
- From: Roberto Guido <rguido src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/rss-enclosures] tracker-store, libtracker-bus, -client: Implement get_value_types for steroids
- Date: Wed, 24 Nov 2010 01:44:26 +0000 (UTC)
commit 23c493734c911cf4b8478c77a4545c5068c9a282
Author: Philip Van Hoof <philip codeminded be>
Date: Thu Sep 9 14:36:31 2010 +0200
tracker-store, libtracker-bus, -client: Implement get_value_types for steroids
src/libtracker-bus/tracker-bus-fd-cursor.c | 33 +++++++++++++++++-----------
src/libtracker-client/tracker.c | 8 ++++++-
src/tracker-store/tracker-steroids.c | 13 +++++++++++
3 files changed, 40 insertions(+), 14 deletions(-)
---
diff --git a/src/libtracker-bus/tracker-bus-fd-cursor.c b/src/libtracker-bus/tracker-bus-fd-cursor.c
index 6b678f9..44b4363 100644
--- a/src/libtracker-bus/tracker-bus-fd-cursor.c
+++ b/src/libtracker-bus/tracker-bus-fd-cursor.c
@@ -51,6 +51,7 @@ struct TrackerBusFDCursor {
guint n_columns;
int *offsets;
+ int *types;
char *data;
};
@@ -95,15 +96,23 @@ tracker_bus_fd_cursor_iter_next (TrackerBusFDCursor *cursor,
/* So, the make up on each cursor segment is:
*
* iteration = [4 bytes for number of columns,
- * 4 bytes for last offset]
+ * columns x 4 bytes for types
+ * columns x 4 bytes for offsets]
*/
cursor->n_columns = buffer_read_int (cursor);
+
+ /* Storage of ints that will be casted to TrackerSparqlValueType enums,
+ * also see tracker_bus_fd_cursor_get_value_type */
+ cursor->types = (int *)(cursor->buffer + cursor->buffer_index);
+ cursor->buffer_index += sizeof (int) * (cursor->n_columns);
+
cursor->offsets = (int *)(cursor->buffer + cursor->buffer_index);
cursor->buffer_index += sizeof (int) * (cursor->n_columns - 1);
-
last_offset = buffer_read_int (cursor);
+
cursor->data = cursor->buffer + cursor->buffer_index;
+
cursor->buffer_index += last_offset + 1;
return TRUE;
@@ -161,13 +170,8 @@ tracker_bus_fd_cursor_get_n_columns (TrackerBusFDCursor *cursor)
static TrackerSparqlValueType
tracker_bus_fd_cursor_get_value_type (TrackerBusFDCursor *cursor, guint column)
{
- /* TODO: Implement */
-
- g_critical ("Unimplemented");
-
- g_return_val_if_reached (TRACKER_SPARQL_VALUE_TYPE_UNBOUND);
-
- return TRACKER_SPARQL_VALUE_TYPE_UNBOUND;
+ /* Cast from int to enum */
+ return (TrackerSparqlValueType) cursor->types[column - 1];
}
static const gchar*
@@ -282,12 +286,15 @@ tracker_bus_fd_query (DBusGConnection *gconnection,
cursor = g_object_new (TRACKER_TYPE_BUS_FD_CURSOR, NULL);
+ /* Cast from long* to gssize*, no idea why the API isn't matching. Silencing
+ * compiler-warning. In tracker.c it's gssize* all the way */
+
tracker_dbus_send_and_splice (connection,
message,
pipefd[0],
cancellable,
(void **) &cursor->buffer,
- &cursor->buffer_size,
+ (gssize *) &cursor->buffer_size,
&inner_error);
/* message is destroyed by tracker_dbus_send_and_splice */
@@ -300,8 +307,8 @@ tracker_bus_fd_query (DBusGConnection *gconnection,
}
return TRACKER_SPARQL_CURSOR (cursor);
#else /* HAVE_DBUS_FD_PASSING */
- g_assert_not_reached ();
- return NULL;
+ g_assert_not_reached ();
+ return NULL;
#endif /* HAVE_DBUS_FD_PASSING */
}
@@ -389,7 +396,7 @@ tracker_bus_fd_query_async (DBusGConnection *gconnection,
query_async_cb, res);
/* message is destroyed by tracker_dbus_send_and_splice_async */
#else /* HAVE_DBUS_FD_PASSING */
- g_assert_not_reached ();
+ g_assert_not_reached ();
#endif /* HAVE_DBUS_FD_PASSING */
}
diff --git a/src/libtracker-client/tracker.c b/src/libtracker-client/tracker.c
index 1e7fd9d..081b43e 100644
--- a/src/libtracker-client/tracker.c
+++ b/src/libtracker-client/tracker.c
@@ -178,6 +178,7 @@ struct TrackerResultIterator {
guint n_columns;
gint *offsets;
+ gint *types;
gchar *data;
#else /* HAVE_DBUS_FD_PASSING */
GPtrArray *results;
@@ -1935,9 +1936,14 @@ tracker_result_iterator_next (TrackerResultIterator *iterator)
/* So, the make up on each iterator segment is:
*
* iteration = [4 bytes for number of columns,
- * 4 bytes for last offset]
+ * columns x 4 bytes for types
+ * columns x 4 bytes for offsets]
*/
iterator->n_columns = iterator_buffer_read_int (iterator);
+
+ iterator->types = (int *)(iterator->buffer + iterator->buffer_index);
+ iterator->buffer_index += sizeof (int) * (iterator->n_columns);
+
iterator->offsets = (int *)(iterator->buffer + iterator->buffer_index);
iterator->buffer_index += sizeof (int) * (iterator->n_columns - 1);
diff --git a/src/tracker-store/tracker-steroids.c b/src/tracker-store/tracker-steroids.c
index 3802aaf..646d44c 100644
--- a/src/tracker-store/tracker-steroids.c
+++ b/src/tracker-store/tracker-steroids.c
@@ -245,6 +245,7 @@ query_inthread (TrackerDBCursor *cursor,
guint n_columns;
gint *column_sizes;
gint *column_offsets;
+ gint *column_types;
const gchar **column_data;
ptr = g_slice_new0 (InThreadPtr);
@@ -268,6 +269,7 @@ query_inthread (TrackerDBCursor *cursor,
column_sizes = alloca (n_columns * sizeof (gint));
column_offsets = alloca (n_columns * sizeof (gint));
column_data = alloca (n_columns * sizeof (gchar*));
+ column_types = alloca (n_columns * sizeof (gchar*));
while (tracker_db_cursor_iter_next (cursor, cancellable, &loop_error)) {
gint i;
@@ -285,6 +287,9 @@ query_inthread (TrackerDBCursor *cursor,
column_sizes[i] = str ? strlen (str) : 0;
column_data[i] = str;
+ /* Cast from enum to int */
+ column_types[i] = (gint) tracker_db_cursor_get_value_type (cursor, i);
+
last_offset += column_sizes[i] + 1;
column_offsets[i] = last_offset;
}
@@ -304,6 +309,14 @@ query_inthread (TrackerDBCursor *cursor,
for (i = 0; i < n_columns; i++) {
g_data_output_stream_put_int32 (data_output_stream,
+ column_types[i],
+ NULL,
+ &loop_error);
+ if (loop_error) {
+ goto end_query_inthread;
+ }
+
+ g_data_output_stream_put_int32 (data_output_stream,
column_offsets[i],
NULL,
&loop_error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]