[Groonga-commit] groonga/groonga at e972181 [master] Extract drilldown execution code as a function

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Apr 10 16:14:58 JST 2016


Kouhei Sutou	2016-04-10 16:14:58 +0900 (Sun, 10 Apr 2016)

  New Revision: e9721814af05c5d0ada2987c67d97f1ba9c0be3b
  https://github.com/groonga/groonga/commit/e9721814af05c5d0ada2987c67d97f1ba9c0be3b

  Message:
    Extract drilldown execution code as a function

  Modified files:
    lib/proc/proc_select.c

  Modified: lib/proc/proc_select.c (+32 -11)
===================================================================
--- lib/proc/proc_select.c    2016-04-10 16:10:36 +0900 (1c255d0)
+++ lib/proc/proc_select.c    2016-04-10 16:14:58 +0900 (834e590)
@@ -559,32 +559,31 @@ drilldown_info_tsort(grn_ctx *ctx, grn_obj *labels,
   return succeeded;
 }
 
-
-static void
-grn_select_drilldowns(grn_ctx *ctx, grn_obj *table,
-                      drilldown_info *drilldowns, unsigned int n_drilldowns,
-                      grn_obj *condition)
+static grn_table_group_result *
+grn_select_drilldowns_execute(grn_ctx *ctx,
+                              grn_obj *table,
+                              drilldown_info *drilldowns,
+                              unsigned int n_drilldowns,
+                              grn_obj *condition)
 {
-  unsigned int i;
-  grn_table_group_result *results;
+  grn_table_group_result *results = NULL;
   grn_obj *labels = NULL;
   grn_obj tsorted_indexes;
+  unsigned int i;
 
   labels = grn_table_create(ctx, NULL, 0, NULL,
                             GRN_OBJ_TABLE_HASH_KEY,
                             grn_ctx_at(ctx, GRN_DB_SHORT_TEXT),
                             NULL);
   if (!labels) {
-    return;
+    return NULL;
   }
 
   GRN_UINT32_INIT(&tsorted_indexes, GRN_OBJ_VECTOR);
   if (!drilldown_info_tsort(ctx, labels,
                             drilldowns, n_drilldowns, &tsorted_indexes)) {
     /* cyclic */
-    GRN_OBJ_FIN(ctx, &tsorted_indexes);
-    grn_obj_close(ctx, labels);
-    return;
+    goto exit;
   }
 
   results = GRN_PLUGIN_MALLOCN(ctx, grn_table_group_result, n_drilldowns);
@@ -638,9 +637,31 @@ grn_select_drilldowns(grn_ctx *ctx, grn_obj *table,
     grn_table_group(ctx, target_table, keys, n_keys, &(results[j]), 1);
     grn_table_sort_key_close(ctx, keys, n_keys);
   }
+
+exit :
   GRN_OBJ_FIN(ctx, &tsorted_indexes);
   grn_obj_close(ctx, labels);
 
+  return results;
+}
+
+static void
+grn_select_drilldowns(grn_ctx *ctx, grn_obj *table,
+                      drilldown_info *drilldowns, unsigned int n_drilldowns,
+                      grn_obj *condition)
+{
+  unsigned int i;
+  grn_table_group_result *results;
+
+  results = grn_select_drilldowns_execute(ctx,
+                                          table,
+                                          drilldowns,
+                                          n_drilldowns,
+                                          condition);
+  if (!results) {
+    return;
+  }
+
   GRN_OUTPUT_MAP_OPEN("DRILLDOWNS", n_drilldowns);
   for (i = 0; i < n_drilldowns; i++) {
     drilldown_info *drilldown = &(drilldowns[i]);
-------------- next part --------------
HTML����������������������������...
Download 



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