[tracker/ontology-cope] libtracker-data: Added a byte to the transaction format in the journal



commit 79ab1844e702db5ebd4334a36c7f40efc1a4b1c6
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Mar 18 12:21:11 2010 +0100

    libtracker-data: Added a byte to the transaction format in the journal
    
    This byte will be used to store the kind of transaction

 src/libtracker-db/tracker-db-journal.c |   49 ++++++++++++++++++++++++++++++--
 src/libtracker-db/tracker-db-journal.h |    5 ++-
 2 files changed, 50 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-journal.c b/src/libtracker-db/tracker-db-journal.c
index d17dbae..1635d25 100644
--- a/src/libtracker-db/tracker-db-journal.c
+++ b/src/libtracker-db/tracker-db-journal.c
@@ -57,6 +57,11 @@ typedef enum {
 	DATA_FORMAT_GRAPH            = 1 << 3
 } DataFormat;
 
+typedef enum {
+	TRANSACTION_FORMAT_DATA      = 1 << 0,
+	TRANSACTION_FORMAT_ONTOLOGY  = 1 << 0,
+} TransactionFormat;
+
 static struct {
 	gchar *filename;
 	GMappedFile *file;
@@ -335,7 +340,7 @@ tracker_db_journal_start_transaction (time_t time)
 
 	g_return_val_if_fail (writer.journal > 0, FALSE);
 
-	size = sizeof (guint32) * 3;
+	size = sizeof (guint32) * 4;
 	cur_block_maybe_expand (size);
 
 	/* Leave space for size, amount and crc
@@ -350,6 +355,36 @@ tracker_db_journal_start_transaction (time_t time)
 	/* add timestamp */
 	cur_block_maybe_expand (sizeof (gint32));
 	cur_setnum (writer.cur_block, &writer.cur_pos, time);
+	cur_setnum (writer.cur_block, &writer.cur_pos, TRANSACTION_FORMAT_DATA);
+	writer.cur_block_len += sizeof (gint32);
+
+	return TRUE;
+}
+
+
+gboolean
+tracker_db_journal_start_ontology_transaction (time_t time)
+{
+	guint size;
+
+	g_return_val_if_fail (writer.journal > 0, FALSE);
+
+	size = sizeof (guint32) * 4;
+	cur_block_maybe_expand (size);
+
+	/* Leave space for size, amount and crc
+	 * Check and keep in sync the offset variable at
+	 * tracker_db_journal_commit_db_transaction too */
+
+	memset (writer.cur_block, 0, size);
+
+	writer.cur_pos = writer.cur_block_len = size;
+	writer.cur_entry_amount = 0;
+
+	/* add timestamp */
+	cur_block_maybe_expand (sizeof (gint32));
+	cur_setnum (writer.cur_block, &writer.cur_pos, time);
+	cur_setnum (writer.cur_block, &writer.cur_pos, TRANSACTION_FORMAT_ONTOLOGY);
 	writer.cur_block_len += sizeof (gint32);
 
 	return TRUE;
@@ -571,7 +606,7 @@ tracker_db_journal_commit_db_transaction (void)
 
 	begin_pos = 0;
 	size = sizeof (guint32);
-	offset = sizeof (guint32) * 3;
+	offset = sizeof (guint32) * 4;
 
 	/* Expand by uint32 for the size check at the end of the entry */
 	cur_block_maybe_expand (size);
@@ -787,6 +822,7 @@ tracker_db_journal_reader_next (GError **error)
 		guint32 entry_size_check;
 		guint32 crc;
 		guint32 crc_check;
+		TransactionFormat t_kind;
 
 		/* Check the end is not before where we currently are */
 		if (reader.current >= reader.end) {
@@ -872,7 +908,14 @@ tracker_db_journal_reader_next (GError **error)
 		reader.time = read_uint32 (reader.current);
 		reader.current += 4;
 
-		reader.type = TRACKER_DB_JOURNAL_START_TRANSACTION;
+		t_kind = read_uint32 (reader.current);
+		reader.current += 4;
+
+		if (t_kind == TRANSACTION_FORMAT_DATA)
+			reader.type = TRACKER_DB_JOURNAL_START_TRANSACTION;
+		else
+			reader.type = TRACKER_DB_JOURNAL_START_ONTOLOGY_TRANSACTION;
+
 		return TRUE;
 	} else if (reader.amount_of_triples == 0) {
 		/* end of transaction */
diff --git a/src/libtracker-db/tracker-db-journal.h b/src/libtracker-db/tracker-db-journal.h
index 864d6e1..b7b17b7 100644
--- a/src/libtracker-db/tracker-db-journal.h
+++ b/src/libtracker-db/tracker-db-journal.h
@@ -33,12 +33,13 @@ G_BEGIN_DECLS
 typedef enum {
 	TRACKER_DB_JOURNAL_START,
 	TRACKER_DB_JOURNAL_START_TRANSACTION,
+	TRACKER_DB_JOURNAL_START_ONTOLOGY_TRANSACTION,
 	TRACKER_DB_JOURNAL_END_TRANSACTION,
 	TRACKER_DB_JOURNAL_RESOURCE,
 	TRACKER_DB_JOURNAL_INSERT_STATEMENT,
 	TRACKER_DB_JOURNAL_INSERT_STATEMENT_ID,
 	TRACKER_DB_JOURNAL_DELETE_STATEMENT,
-	TRACKER_DB_JOURNAL_DELETE_STATEMENT_ID
+	TRACKER_DB_JOURNAL_DELETE_STATEMENT_ID,
 } TrackerDBJournalEntryType;
 
 GQuark       tracker_db_journal_error_quark                  (void);
@@ -54,6 +55,8 @@ const gchar* tracker_db_journal_get_filename                 (void);
 gsize        tracker_db_journal_get_size                     (void);
 
 gboolean     tracker_db_journal_start_transaction            (time_t       time);
+gboolean     tracker_db_journal_start_ontology_transaction   (time_t       time);
+
 gboolean     tracker_db_journal_append_delete_statement      (gint         g_id,
                                                               gint         s_id,
                                                               gint         p_id,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]