[Groonga-commit] pgroonga/pgroonga at 6d25367 [master] jsonb: export lookup functions

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Aug 27 21:33:17 JST 2016


Kouhei Sutou	2016-08-27 21:33:17 +0900 (Sat, 27 Aug 2016)

  New Revision: 6d2536717f691c33b47f7efa7960c69533fe94f5
  https://github.com/pgroonga/pgroonga/commit/6d2536717f691c33b47f7efa7960c69533fe94f5

  Message:
    jsonb: export lookup functions

  Modified files:
    src/pgrn_jsonb.c
    src/pgrn_jsonb.h

  Modified: src/pgrn_jsonb.c (+90 -12)
===================================================================
--- src/pgrn_jsonb.c    2016-08-27 21:32:41 +0900 (9859193)
+++ src/pgrn_jsonb.c    2016-08-27 21:33:17 +0900 (1070848)
@@ -60,10 +60,23 @@ static grn_obj *tmpPathsTable = NULL;
 static grn_obj *tmpTypesTable = NULL;
 static grn_obj *tmpValuesTable = NULL;
 
-static grn_obj *
-PGrnLookupJSONPathsTable(Relation index,
-						 unsigned int nthAttribute,
-						 int errorLevel)
+grn_obj *
+PGrnJSONBLookupValuesTable(Relation index,
+						   unsigned int nthAttribute,
+						   int errorLevel)
+{
+	char name[GRN_TABLE_MAX_KEY_SIZE];
+
+	snprintf(name, sizeof(name),
+			 PGrnJSONValuesTableNameFormat,
+			 index->rd_node.relNode, nthAttribute);
+	return PGrnLookup(name, errorLevel);
+}
+
+grn_obj *
+PGrnJSONBLookupPathsTable(Relation index,
+						  unsigned int nthAttribute,
+						  int errorLevel)
 {
 	char name[GRN_TABLE_MAX_KEY_SIZE];
 
@@ -73,19 +86,84 @@ PGrnLookupJSONPathsTable(Relation index,
 	return PGrnLookup(name, errorLevel);
 }
 
-static grn_obj *
-PGrnLookupJSONValuesTable(Relation index,
+grn_obj *
+PGrnJSONBLookupTypesTable(Relation index,
 						  unsigned int nthAttribute,
 						  int errorLevel)
 {
 	char name[GRN_TABLE_MAX_KEY_SIZE];
 
 	snprintf(name, sizeof(name),
-			 PGrnJSONValuesTableNameFormat,
+			 PGrnJSONTypesTableNameFormat,
 			 index->rd_node.relNode, nthAttribute);
 	return PGrnLookup(name, errorLevel);
 }
 
+grn_obj *
+PGrnJSONBLookupFullTextSearchLexicon(Relation index,
+									 unsigned int nthAttribute,
+									 int errorLevel)
+{
+	char name[GRN_TABLE_MAX_KEY_SIZE];
+
+	snprintf(name, sizeof(name),
+			 PGrnJSONValueLexiconNameFormat,
+			 "FullTextSearch", index->rd_node.relNode, nthAttribute);
+	return PGrnLookup(name, errorLevel);
+}
+
+grn_obj *
+PGrnJSONBLookupStringLexicon(Relation index,
+							 unsigned int nthAttribute,
+							 int errorLevel)
+{
+	char name[GRN_TABLE_MAX_KEY_SIZE];
+
+	snprintf(name, sizeof(name),
+			 PGrnJSONValueLexiconNameFormat,
+			 "String", index->rd_node.relNode, nthAttribute);
+	return PGrnLookup(name, errorLevel);
+}
+
+grn_obj *
+PGrnJSONBLookupNumberLexicon(Relation index,
+							 unsigned int nthAttribute,
+							 int errorLevel)
+{
+	char name[GRN_TABLE_MAX_KEY_SIZE];
+
+	snprintf(name, sizeof(name),
+			 PGrnJSONValueLexiconNameFormat,
+			 "Number", index->rd_node.relNode, nthAttribute);
+	return PGrnLookup(name, errorLevel);
+}
+
+grn_obj *
+PGrnJSONBLookupBooleanLexicon(Relation index,
+							  unsigned int nthAttribute,
+							  int errorLevel)
+{
+	char name[GRN_TABLE_MAX_KEY_SIZE];
+
+	snprintf(name, sizeof(name),
+			 PGrnJSONValueLexiconNameFormat,
+			 "Boolean", index->rd_node.relNode, nthAttribute);
+	return PGrnLookup(name, errorLevel);
+}
+
+grn_obj *
+PGrnJSONBLookupSizeLexicon(Relation index,
+						   unsigned int nthAttribute,
+						   int errorLevel)
+{
+	char name[GRN_TABLE_MAX_KEY_SIZE];
+
+	snprintf(name, sizeof(name),
+			 PGrnJSONValueLexiconNameFormat,
+			 "Size", index->rd_node.relNode, nthAttribute);
+	return PGrnLookup(name, errorLevel);
+}
+
 static grn_obj *
 PGrnJSONBCreatePathsTable(const char *name)
 {
@@ -773,7 +851,7 @@ PGrnJSONBSetSources(Relation index,
 {
 	grn_obj *jsonPathsTable;
 
-	jsonPathsTable = PGrnLookupJSONPathsTable(index, nthAttribute, ERROR);
+	jsonPathsTable = PGrnJSONBLookupPathsTable(index, nthAttribute, ERROR);
 
 	{
 		grn_obj *source;
@@ -818,7 +896,7 @@ PGrnJSONBSetSource(Relation index, unsigned int i)
 	grn_obj *jsonValuesTable;
 	grn_obj *indexColumn;
 
-	jsonValuesTable = PGrnLookupJSONValuesTable(index, i, ERROR);
+	jsonValuesTable = PGrnJSONBLookupValuesTable(index, i, ERROR);
 	PGrnJSONBSetSources(index, jsonValuesTable, i);
 	indexColumn = PGrnLookupColumn(jsonValuesTable,
 								   PGrnIndexColumnName,
@@ -922,8 +1000,8 @@ PGrnJSONBInsert(Relation index,
 	Jsonb *jsonb;
 	JsonbIterator *iter;
 
-	data.pathsTable  = PGrnLookupJSONPathsTable(index, nthValue, ERROR);
-	data.valuesTable = PGrnLookupJSONValuesTable(index, nthValue, ERROR);
+	data.pathsTable  = PGrnJSONBLookupPathsTable(index, nthValue, ERROR);
+	data.valuesTable = PGrnJSONBLookupValuesTable(index, nthValue, ERROR);
 	data.valueIDs = valueIDs;
 	grn_obj_reinit(ctx, data.valueIDs,
 				   grn_obj_id(ctx, data.valuesTable),
@@ -1270,7 +1348,7 @@ PGrnJSONBBulkDeleteInit(PGrnJSONBBulkDeleteData *data)
 	data->sourcesValuesColumn = PGrnLookupColumn(data->sourcesTable,
 												 attribute->attname.data,
 												 ERROR);
-	data->valuesTable = PGrnLookupJSONValuesTable(index, 0, ERROR);
+	data->valuesTable = PGrnJSONBLookupValuesTable(index, 0, ERROR);
 	data->valuesIndexColumn = PGrnLookupColumn(data->valuesTable,
 											   PGrnIndexColumnName,
 											   ERROR);

  Modified: src/pgrn_jsonb.h (+25 -0)
===================================================================
--- src/pgrn_jsonb.h    2016-08-27 21:32:41 +0900 (5903078)
+++ src/pgrn_jsonb.h    2016-08-27 21:33:17 +0900 (23956d0)
@@ -13,6 +13,31 @@ bool PGrnAttributeIsJSONB(Oid id);
 
 void PGrnJSONBCreate(PGrnCreateData *data);
 
+grn_obj *PGrnJSONBLookupValuesTable(Relation index,
+									unsigned int nthAttribute,
+									int errorLevel);
+grn_obj *PGrnJSONBLookupPathsTable(Relation index,
+								   unsigned int nthAttribute,
+								   int errorLevel);
+grn_obj *PGrnJSONBLookupTypesTable(Relation index,
+								   unsigned int nthAttribute,
+								   int errorLevel);
+grn_obj *PGrnJSONBLookupFullTextSearchLexicon(Relation index,
+											  unsigned int nthAttribute,
+											  int errorLevel);
+grn_obj *PGrnJSONBLookupStringLexicon(Relation index,
+									  unsigned int nthAttribute,
+									  int errorLevel);
+grn_obj *PGrnJSONBLookupNumberLexicon(Relation index,
+									  unsigned int nthAttribute,
+									  int errorLevel);
+grn_obj *PGrnJSONBLookupBooleanLexicon(Relation index,
+									   unsigned int nthAttribute,
+									   int errorLevel);
+grn_obj *PGrnJSONBLookupSizeLexicon(Relation index,
+									unsigned int nthAttribute,
+									int errorLevel);
+
 grn_obj *PGrnJSONBSetSource(Relation index, unsigned int i);
 
 void PGrnJSONBInsert(Relation index,
-------------- next part --------------
HTML����������������������������...
Download 



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