Skip to content

Commit

Permalink
Use function to buffer column_info in buffer_aggregate_xml
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmundell committed Aug 15, 2024
1 parent 2af344d commit 8b517a7
Showing 1 changed file with 166 additions and 135 deletions.
301 changes: 166 additions & 135 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10310,6 +10310,167 @@ buffer_aggregate_subgroup_value (gchar *key,
return FALSE;
}

/**
* @brief Buffer XML for an aggregate.
*
* @param[in] xml Buffer into which to buffer aggregate.
* @param[in] type The aggregated type.
* @param[in] group_column Column the data are grouped by.
* @param[in] group_column_type Type of the group_column.
* @param[in] subgroup_column Column the data are further grouped by.
* @param[in] subgroup_column_type
* @param[in] data_columns Columns statistics are calculated for.
* @param[in] data_column_types Types of the data_columns.
* @param[in] text_columns Columns used for labels.
* @param[in] text_column_types Types of the text_columns.
*/
static void
buffer_aggregate_column_info (GString *xml, const gchar *type,

Check warning on line 10328 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10328

Added line #L10328 was not covered by tests
const char *group_column, const char *group_column_type,
const char *subgroup_column,
const char *subgroup_column_type,
GArray *data_columns, GArray *data_column_types,
GArray *text_columns, GArray *text_column_types)
{
int index;

g_string_append (xml, "<column_info>");

Check warning on line 10337 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10337

Added line #L10337 was not covered by tests

if (group_column)
g_string_append_printf (xml,

Check warning on line 10340 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10340

Added line #L10340 was not covered by tests
"<aggregate_column>"
"<name>value</name>"
"<stat>value</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
type,
group_column,
group_column_type);

if (subgroup_column)
g_string_append_printf (xml,

Check warning on line 10353 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10353

Added line #L10353 was not covered by tests
"<aggregate_column>"
"<name>subgroup_value</name>"
"<stat>value</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
type,
subgroup_column,
subgroup_column_type);

g_string_append_printf (xml,

Check warning on line 10365 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10365

Added line #L10365 was not covered by tests
"<aggregate_column>"
"<name>count</name>"
"<stat>count</stat>"
"<type>%s</type>"
"<column></column>"
"<data_type>integer</data_type>"
"</aggregate_column>",
type);

g_string_append_printf (xml,

Check warning on line 10375 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10375

Added line #L10375 was not covered by tests
"<aggregate_column>"
"<name>c_count</name>"
"<stat>c_count</stat>"
"<type>%s</type>"
"<column></column>"
"<data_type>integer</data_type>"
"</aggregate_column>",
type);

for (index = 0; index < data_columns->len; index++)
{
gchar *column_name, *column_type;
column_name = g_array_index (data_columns, gchar*, index);
column_type = g_array_index (data_column_types, gchar*, index);
g_string_append_printf (xml,

Check warning on line 10390 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10388-L10390

Added lines #L10388 - L10390 were not covered by tests
"<aggregate_column>"
"<name>%s_min</name>"
"<stat>min</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
column_name,
type,
column_name,
column_type);
g_string_append_printf (xml,

Check warning on line 10402 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10402

Added line #L10402 was not covered by tests
"<aggregate_column>"
"<name>%s_max</name>"
"<stat>max</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
column_name,
type,
column_name,
column_type);
g_string_append_printf (xml,

Check warning on line 10414 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10414

Added line #L10414 was not covered by tests
"<aggregate_column>"
"<name>%s_mean</name>"
"<stat>mean</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
column_name,
type,
column_name,
column_type);
g_string_append_printf (xml,

Check warning on line 10426 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10426

Added line #L10426 was not covered by tests
"<aggregate_column>"
"<name>%s_sum</name>"
"<stat>sum</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
column_name,
type,
column_name,
column_type);
g_string_append_printf (xml,

Check warning on line 10438 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10438

Added line #L10438 was not covered by tests
"<aggregate_column>"
"<name>%s_c_sum</name>"
"<stat>c_sum</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
column_name,
type,
column_name,
column_type);
}

for (index = 0; index < text_columns->len; index++)
{
gchar *column_name, *column_type;
column_name = g_array_index (text_columns, gchar*, index);
column_type = g_array_index (text_column_types, gchar*, index);
g_string_append_printf (xml,

Check warning on line 10457 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10455-L10457

Added lines #L10455 - L10457 were not covered by tests
"<aggregate_column>"
"<name>%s</name>"
"<stat>text</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
column_name,
type,
column_name,
column_type);
}

g_string_append (xml, "</column_info>");

Check warning on line 10471 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10471

Added line #L10471 was not covered by tests
}

/**
* @brief Buffer XML for an aggregate.
*
Expand Down Expand Up @@ -10760,141 +10921,11 @@ buffer_aggregate_xml (GString *xml, iterator_t* aggregate, const gchar* type,
"</subgroups>");
}

g_string_append (xml, "<column_info>");

if (group_column)
g_string_append_printf (xml,
"<aggregate_column>"
"<name>value</name>"
"<stat>value</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
type,
group_column,
group_column_type);

if (subgroup_column)
g_string_append_printf (xml,
"<aggregate_column>"
"<name>subgroup_value</name>"
"<stat>value</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
type,
subgroup_column,
subgroup_column_type);

g_string_append_printf (xml,
"<aggregate_column>"
"<name>count</name>"
"<stat>count</stat>"
"<type>%s</type>"
"<column></column>"
"<data_type>integer</data_type>"
"</aggregate_column>",
type);

g_string_append_printf (xml,
"<aggregate_column>"
"<name>c_count</name>"
"<stat>c_count</stat>"
"<type>%s</type>"
"<column></column>"
"<data_type>integer</data_type>"
"</aggregate_column>",
type);

for (index = 0; index < data_columns->len; index++)
{
gchar *column_name, *column_type;
column_name = g_array_index (data_columns, gchar*, index);
column_type = g_array_index (data_column_types, gchar*, index);
g_string_append_printf (xml,
"<aggregate_column>"
"<name>%s_min</name>"
"<stat>min</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
column_name,
type,
column_name,
column_type);
g_string_append_printf (xml,
"<aggregate_column>"
"<name>%s_max</name>"
"<stat>max</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
column_name,
type,
column_name,
column_type);
g_string_append_printf (xml,
"<aggregate_column>"
"<name>%s_mean</name>"
"<stat>mean</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
column_name,
type,
column_name,
column_type);
g_string_append_printf (xml,
"<aggregate_column>"
"<name>%s_sum</name>"
"<stat>sum</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
column_name,
type,
column_name,
column_type);
g_string_append_printf (xml,
"<aggregate_column>"
"<name>%s_c_sum</name>"
"<stat>c_sum</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
column_name,
type,
column_name,
column_type);
}

for (index = 0; index < text_columns->len; index++)
{
gchar *column_name, *column_type;
column_name = g_array_index (text_columns, gchar*, index);
column_type = g_array_index (text_column_types, gchar*, index);
g_string_append_printf (xml,
"<aggregate_column>"
"<name>%s</name>"
"<stat>text</stat>"
"<type>%s</type>"
"<column>%s</column>"
"<data_type>%s</data_type>"
"</aggregate_column>",
column_name,
type,
column_name,
column_type);
}

g_string_append (xml, "</column_info>");
buffer_aggregate_column_info (xml, type,

Check warning on line 10924 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10924

Added line #L10924 was not covered by tests
group_column, group_column_type,
subgroup_column, subgroup_column_type,
data_columns, data_column_types,
text_columns, text_column_types);

g_string_append (xml, "</aggregate>");

Expand Down

0 comments on commit 8b517a7

Please sign in to comment.