MCPcopy Create free account
hub / github.com/apache/arrow / garrow_aggregate_node_options_new

Function garrow_aggregate_node_options_new

c_glib/arrow-glib/compute.cpp:1740–1784  ·  view source on GitHub ↗

* garrow_aggregate_node_options_new: * @aggregations: (element-type GArrowAggregation): A list of #GArrowAggregation. * @keys: (nullable) (array length=n_keys): Group keys. * @n_keys: The number of @keys. * @error: (nullable): Return location for a #GError or %NULL. * * Returns: (nullable): A newly created #GArrowAggregateNodeOptions on success, * %NULL otherwise. * * Since: 6.0.0 */

Source from the content-addressed store, hash-verified

1738 * Since: 6.0.0
1739 */
1740GArrowAggregateNodeOptions *
1741garrow_aggregate_node_options_new(GList *aggregations,
1742 const gchar **keys,
1743 gsize n_keys,
1744 GError **error)
1745{
1746 std::vector<arrow::compute::Aggregate> arrow_aggregates;
1747 std::vector<arrow::FieldRef> arrow_keys;
1748 for (auto node = aggregations; node; node = node->next) {
1749 auto aggregation_priv = GARROW_AGGREGATION_GET_PRIVATE(node->data);
1750 arrow::compute::FunctionOptions *function_options = nullptr;
1751 if (aggregation_priv->options) {
1752 function_options = garrow_function_options_get_raw(aggregation_priv->options);
1753 };
1754 std::vector<arrow::FieldRef> arrow_targets;
1755 if (!garrow_field_refs_add(arrow_targets,
1756 aggregation_priv->input,
1757 error,
1758 "[aggregate-node-options][new][input]")) {
1759 return NULL;
1760 }
1761 arrow_aggregates.push_back({
1762 aggregation_priv->function,
1763 function_options ? function_options->Copy() : nullptr,
1764 arrow_targets[0],
1765 aggregation_priv->output,
1766 });
1767 }
1768 for (gsize i = 0; i < n_keys; ++i) {
1769 if (!garrow_field_refs_add(arrow_keys,
1770 keys[i],
1771 error,
1772 "[aggregate-node-options][new][key]")) {
1773 return NULL;
1774 }
1775 }
1776 auto arrow_options = new arrow::acero::AggregateNodeOptions(std::move(arrow_aggregates),
1777 std::move(arrow_keys));
1778 auto options =
1779 g_object_new(GARROW_TYPE_AGGREGATE_NODE_OPTIONS, "options", arrow_options, nullptr);
1780 auto priv = GARROW_AGGREGATE_NODE_OPTIONS_GET_PRIVATE(options);
1781 priv->aggregations =
1782 g_list_copy_deep(aggregations, reinterpret_cast<GCopyFunc>(g_object_ref), nullptr);
1783 return GARROW_AGGREGATE_NODE_OPTIONS(options);
1784}
1785
1786/**
1787 * garrow_aggregate_node_options_get_aggregations:

Callers

nothing calls this directly

Calls 4

garrow_field_refs_addFunction · 0.85
push_backMethod · 0.80
CopyMethod · 0.45

Tested by

no test coverage detected