<commit_before>---
title:  Running the Function
---

In this section you create an `Execution` object and use its methods to define and run the function. To run a function with high availability, you call `getResult` from the results collector returned from the `execute` method.

<a id="running-function__section_8BC7F999141A40E389B8DC276EAB9F7E"></a>
## Configuring and Running a Function

You specify the members that run the function and, optionally, the data set over which the functions run.

-   **Servers**. Execute the function in a single server or a set of servers, specified by the server pool. To specify data sets for this type of function, pass arguments in to the function.
-   **Data set**. Specify a region and possibly a set of keys on which to run.

In every client where you want to execute the function and process the results:

1.  Use one of the `FunctionService on*` methods to create an `Execution` object. The `on*` methods, `onRegion`, `onServer` and `onServers`, define the highest level where the function is run. If you use `onRegion` you can further narrow your run scope by setting key filters. The function run using `onRegion` is a data dependent function – the others are data-independent functions.

    You can run a data dependent function against custom partitioned and colocated partitioned regions. From the client, provide the appropriate key sets to the function call.

2.  Use the `Execution` object as needed for additional function configuration. You can:

    -   Provide a set of data keys to `withFilter` to narrow the execution scope. This works only for `onRegion Execution` objects.
    -   Provide function arguments to `withArgs`.
    -   Define a custom `ResultCollector` to `withCollector`. See [Programming to Get Function Results](handling-function-results.html#handling-function-results).

3.  Call the `Execution` object execute method to run the function.
4.  To run a function with high availability, call `getResult` from the results collector returned from `execute`. Calling a highly available function without using `getResult` disables the high availability functionality.

## Running a Function on a Region (C++)<commit_msg>Review NC Function Execution Section of Geode markdown [#124828981]<commit_after>---
title:  Running the Function
---

In this section you create an `Execution` object and use its methods to define and run the function. To run a function with high availability, you call `getResult` from the results collector returned from the `execute` method.

<a id="running-function__section_8BC7F999141A40E389B8DC276EAB9F7E"></a>
## Configuring and Running a Function

You specify the members that run the function and, optionally, the data set over which the functions run.

-   **Servers**. Execute the function in a single server or a set of servers, specified by the server pool. To specify data sets for this type of function, pass arguments in to the function.
-   **Data set**. Specify a region and possibly a set of keys on which to run.

In every client where you want to execute the function and process the results:

1.  Use one of the `FunctionService on*` methods to create an `Execution` object. The `on*` methods, `onRegion`, `onServer` and `onServers`, define the highest level where the function is run. If you use `onRegion` you can further narrow your run scope by setting key filters. The function run using `onRegion` is a data dependent function – the others are data-independent functions.

    You can run a data dependent function against custom partitioned and colocated partitioned regions. From the client, provide the appropriate key sets to the function call.

2.  Use the `Execution` object as needed for additional function configuration. You can:
    -   Provide a set of data keys to `withFilter` to narrow the execution scope. This works only for `onRegion Execution` objects.
    -   Provide function arguments to `withArgs`.
    -   Define a custom `ResultCollector` to `withCollector`. See [Programming to Get Function Results](handling-function-results.html#handling-function-results).

3.  Call the `Execution` object execute method to run the function.
4.  To run a function with high availability, call `getResult` from the results collector returned from `execute`. Calling a highly available function without using `getResult` disables the high availability functionality.

## Running a Function on a Region (C++)
{'fraction_non_alphanumeric': 0.06150033791394458, 'fraction_numerical': 0.012390177968010813, 'mean_word_length': 4.388349514563107, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5215530', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1077, 'n_words': 633}