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 authored and a-h-abdelsalam committed Sep 5, 2024
1 parent 4bf1407 commit 40ddc0c
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 @@ -10313,6 +10313,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 10331 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10331

Added line #L10331 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 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

if (group_column)
g_string_append_printf (xml,

Check warning on line 10343 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10343

Added line #L10343 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 10356 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10356

Added line #L10356 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 10368 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10368

Added line #L10368 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 10378 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10378

Added line #L10378 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 10393 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10391-L10393

Added lines #L10391 - L10393 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 10405 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10405

Added line #L10405 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 10417 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10417

Added line #L10417 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 10429 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10429

Added line #L10429 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 10441 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10441

Added line #L10441 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 10460 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10458-L10460

Added lines #L10458 - L10460 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 10474 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10474

Added line #L10474 was not covered by tests
}

/**
* @brief Buffer XML for an aggregate.
*
Expand Down Expand Up @@ -10763,141 +10924,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 10927 in src/gmp.c

View check run for this annotation

Codecov / codecov/patch

src/gmp.c#L10927

Added line #L10927 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 40ddc0c

Please sign in to comment.