[Groonga-commit] pgroonga/pgroonga at fc3fd75 [master] Support ambuildempty

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Jan 18 00:26:16 JST 2015


Kouhei Sutou	2015-01-18 00:26:16 +0900 (Sun, 18 Jan 2015)

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

  Message:
    Support ambuildempty
    
    It's not tested but it will work.

  Modified files:
    pgroonga--0.2.0.sql
    pgroonga.c
    pgroonga.h

  Modified: pgroonga--0.2.0.sql (+2 -1)
===================================================================
--- pgroonga--0.2.0.sql    2015-01-18 00:08:18 +0900 (931d6a0)
+++ pgroonga--0.2.0.sql    2015-01-18 00:26:16 +0900 (37f4e0e)
@@ -32,6 +32,7 @@ CREATE FUNCTION pgroonga.getbitmap(internal) RETURNS bigint AS 'MODULE_PATHNAME'
 CREATE FUNCTION pgroonga.rescan(internal) RETURNS void AS 'MODULE_PATHNAME','pgroonga_rescan' LANGUAGE C;
 CREATE FUNCTION pgroonga.endscan(internal) RETURNS void AS 'MODULE_PATHNAME','pgroonga_endscan' LANGUAGE C;
 CREATE FUNCTION pgroonga.build(internal) RETURNS internal AS 'MODULE_PATHNAME','pgroonga_build' LANGUAGE C;
+CREATE FUNCTION pgroonga.buildempty(internal) RETURNS internal AS 'MODULE_PATHNAME','pgroonga_buildempty' LANGUAGE C;
 CREATE FUNCTION pgroonga.bulkdelete(internal) RETURNS internal AS 'MODULE_PATHNAME','pgroonga_bulkdelete' LANGUAGE C;
 CREATE FUNCTION pgroonga.vacuumcleanup(internal) RETURNS internal AS 'MODULE_PATHNAME','pgroonga_vacuumcleanup' LANGUAGE C;
 CREATE FUNCTION pgroonga.costestimate(internal) RETURNS internal AS 'MODULE_PATHNAME','pgroonga_costestimate' LANGUAGE C;
@@ -84,7 +85,7 @@ INSERT INTO pg_catalog.pg_am VALUES(
 	0,		-- ammarkpos,
 	0,		-- amrestrpos,
 	'pgroonga.build',	-- ambuild
-	0,		-- ambuildempty
+	'pgroonga.buildempty',	-- ambuildempty
 	'pgroonga.bulkdelete',	-- ambulkdelete
 	'pgroonga.vacuumcleanup',	-- amvacuumcleanup
 	0,		-- amcanreturn

  Modified: pgroonga.c (+33 -2)
===================================================================
--- pgroonga.c    2015-01-18 00:08:18 +0900 (c9e3ad3)
+++ pgroonga.c    2015-01-18 00:26:16 +0900 (a9df422)
@@ -50,6 +50,7 @@ PG_FUNCTION_INFO_V1(pgroonga_getbitmap);
 PG_FUNCTION_INFO_V1(pgroonga_rescan);
 PG_FUNCTION_INFO_V1(pgroonga_endscan);
 PG_FUNCTION_INFO_V1(pgroonga_build);
+PG_FUNCTION_INFO_V1(pgroonga_buildempty);
 PG_FUNCTION_INFO_V1(pgroonga_bulkdelete);
 PG_FUNCTION_INFO_V1(pgroonga_vacuumcleanup);
 PG_FUNCTION_INFO_V1(pgroonga_costestimate);
@@ -936,6 +937,36 @@ pgroonga_build(PG_FUNCTION_ARGS)
 	PG_RETURN_POINTER(result);
 }
 
+/**
+ * pgroonga.buildempty() -- ambuildempty
+ */
+Datum
+pgroonga_buildempty(PG_FUNCTION_ARGS)
+{
+	Relation index = (Relation) PG_GETARG_POINTER(0);
+	grn_obj *idsTable = NULL;
+	grn_obj *lexicon = NULL;
+	grn_obj *indexColumn = NULL;
+
+	PG_TRY();
+	{
+		GrnCreate(index, &idsTable, &lexicon, &indexColumn);
+	}
+	PG_CATCH();
+	{
+		if (indexColumn)
+			grn_obj_remove(ctx, indexColumn);
+		if (lexicon)
+			grn_obj_remove(ctx, lexicon);
+		if (idsTable)
+			grn_obj_remove(ctx, idsTable);
+		PG_RE_THROW();
+	}
+	PG_END_TRY();
+
+	PG_RETURN_VOID();
+}
+
 static IndexBulkDeleteResult *
 GrnBulkDeleteResult(IndexVacuumInfo *info, grn_obj *idsTable)
 {
@@ -989,12 +1020,12 @@ pgroonga_bulkdelete(PG_FUNCTION_ARGS)
 		while (grn_table_cursor_next(ctx, cursor) != GRN_ID_NIL)
 		{
 			ItemPointerData	ctid;
-			uint64 key;
+			uint64 *key;
 
 			CHECK_FOR_INTERRUPTS();
 
 			grn_table_cursor_get_key(ctx, cursor, (void **) &key);
-			ctid = UInt64ToCtid(key);
+			ctid = UInt64ToCtid(*key);
 			if (callback(&ctid, callback_state))
 			{
 				GrnLock(index, ExclusiveLock);

  Modified: pgroonga.h (+1 -0)
===================================================================
--- pgroonga.h    2015-01-18 00:08:18 +0900 (31039a7)
+++ pgroonga.h    2015-01-18 00:26:16 +0900 (23b6d34)
@@ -47,6 +47,7 @@ extern Datum PGDLLEXPORT pgroonga_getbitmap(PG_FUNCTION_ARGS);
 extern Datum PGDLLEXPORT pgroonga_rescan(PG_FUNCTION_ARGS);
 extern Datum PGDLLEXPORT pgroonga_endscan(PG_FUNCTION_ARGS);
 extern Datum PGDLLEXPORT pgroonga_build(PG_FUNCTION_ARGS);
+extern Datum PGDLLEXPORT pgroonga_buildempty(PG_FUNCTION_ARGS);
 extern Datum PGDLLEXPORT pgroonga_bulkdelete(PG_FUNCTION_ARGS);
 extern Datum PGDLLEXPORT pgroonga_vacuumcleanup(PG_FUNCTION_ARGS);
 extern Datum PGDLLEXPORT pgroonga_costestimate(PG_FUNCTION_ARGS);
-------------- next part --------------
HTML����������������������������...
Download 



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