[Groonga-commit] pgroonga/pgroonga at f7d55d7 [master] wal: support the max record size

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Nov 3 16:37:35 JST 2016


Kouhei Sutou	2016-11-03 16:37:35 +0900 (Thu, 03 Nov 2016)

  New Revision: f7d55d78f4c26a7549bf2cbea599fb767e632bbe
  https://github.com/pgroonga/pgroonga/commit/f7d55d78f4c26a7549bf2cbea599fb767e632bbe

  Message:
    wal: support the max record size

  Modified files:
    src/pgrn_index_status.c

  Modified: src/pgrn_index_status.c (+29 -7)
===================================================================
--- src/pgrn_index_status.c    2016-11-03 16:37:14 +0900 (63d5478)
+++ src/pgrn_index_status.c    2016-11-03 16:37:35 +0900 (8028d3b)
@@ -3,6 +3,7 @@
 #include "pgrn_global.h"
 #include "pgrn_groonga.h"
 #include "pgrn_index_status.h"
+#include "pgrn_wal.h"
 
 #include <miscadmin.h>
 
@@ -53,16 +54,32 @@ PGrnInitializeIndexStatus(void)
 }
 
 static grn_id
-PGrnIndexStatusGetRecordID(Relation index)
+PGrnIndexStatusGetRecordIDWithWAL(Relation index,
+								  PGrnWALData **walData,
+								  size_t nColumns)
 {
 	grn_obj *table;
+	const void *key;
+	size_t keySize;
+	grn_id id;
 
 	table = PGrnLookupWithSize(TABLE_NAME, TABLE_NAME_SIZE, ERROR);
-	return grn_table_add(ctx,
-						 table,
-						 &(index->rd_node.relNode),
-						 sizeof(uint32_t),
-						 NULL);
+	key = &(index->rd_node.relNode);
+	keySize = sizeof(uint32_t);
+	id = grn_table_add(ctx, table, key, keySize, NULL);
+	if (id != GRN_ID_NIL && walData)
+	{
+		*walData = PGrnWALStart(index);
+		PGrnWALInsertStart(*walData, table, nColumns);
+		PGrnWALInsertKeyRaw(*walData, key, keySize);
+	}
+	return id;
+}
+
+static grn_id
+PGrnIndexStatusGetRecordID(Relation index)
+{
+	return PGrnIndexStatusGetRecordIDWithWAL(index, NULL, 0);
 }
 
 uint32_t
@@ -86,12 +103,17 @@ PGrnIndexStatusSetMaxRecordSize(Relation index, uint32_t size)
 	grn_id id;
 	grn_obj *column;
 	grn_obj *maxRecordSize = &(buffers->maxRecordSize);
+	PGrnWALData *walData = NULL;
+	size_t nColumns = 2;
 
-	id = PGrnIndexStatusGetRecordID(index);
+	id = PGrnIndexStatusGetRecordIDWithWAL(index, &walData, nColumns);
 	column = PGrnLookup(TABLE_NAME "." MAX_RECORD_SIZE_COLUMN_NAME,
 						ERROR);
 	GRN_UINT32_SET(ctx, maxRecordSize, size);
 	grn_obj_set_value(ctx, column, id, maxRecordSize, GRN_OBJ_SET);
+
+	PGrnWALInsertColumn(walData, column, maxRecordSize);
+	PGrnWALFinish(walData);
 }
 
 void
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index