(arr, slice_index, start, count)
return getitem_impl
Provides parallel implementation of getting a const slice from arrays of different types

    Arguments:
    arr -- part of the input array processed by this processor
    slice_index -- start and stop of the slice in the input array (same on all ranks)
    start -- position of first arr element in the input array
    count -- lenght of the part of the array processed by this processor

    Return value:
    Function providing implementation basing on arr type. The function should implement
    logic of fetching const slice from the array distributed over multiple processes.
Provides parallel implementation of getting a const slice from arrays of different types
Provides parallel implementation of getting a const slice from arrays of different types
def const_slice_getitem_overload(arr, slice_index, start, count):
    '''Provides parallel implementation of getting a const slice from arrays of different types

    Arguments:
    arr -- part of the input array processed by this processor
    slice_index -- start and stop of the slice in the input array (same on all ranks)
    start -- position of first arr element in the input array
    count -- lenght of the part of the array processed by this processor

    Return value:
    Function providing implementation basing on arr type. The function should implement
    logic of fetching const slice from the array distributed over multiple processes.
    '''

    # TODO: should this also handle slices not staring from zero?
    if arr == string_array_type:
        reduce_op = Reduce_Type.Sum.value

        def getitem_str_impl(arr, slice_index, start, count):
            rank = sdc.distributed_api.get_rank()
            k = slice_index.stop

            # get total characters for allocation
            n_chars = np.uint64(0)
            if k > start:
                # if slice end is beyond the start of this subset we have to send our elements
                my_end = min(count, k - start)
                my_arr = arr[:my_end]
            else:
                my_arr = arr[:0]

            # get the total number of chars in our array, then gather all arrays into one
            # and compute total number of chars in all arrays
            n_chars = num_total_chars(my_arr)
            my_arr = sdc.distributed_api.gatherv(my_arr)
            n_chars = sdc.distributed_api.dist_reduce(n_chars, np.int32(reduce_op))

            if rank != 0:
                out_arr = pre_alloc_string_array(k, n_chars)
            else:
                out_arr = my_arr

            # actual communication
            sdc.distributed_api.bcast(out_arr)
            return out_arr

        return getitem_str_impl

    def getitem_impl(arr, slice_index, start, count):
        rank = sdc.distributed_api.get_rank()
        k = slice_index.stop

        out_arr = np.empty(k, arr.dtype)
        if k > start:
            # if slice end is beyond the start of this subset we have to send our elements
            my_end = min(count, k - start)
            my_arr = arr[:my_end]
        else:
            my_arr = arr[:0]

        # gather all subsets from all processors
        my_arr = sdc.distributed_api.gatherv(my_arr)

        if rank == 0:
            out_arr = my_arr

        # actual communication
        sdc.distributed_api.bcast(out_arr)
        return out_arr

    return getitem_impl
def const_slice_getitem_overload ( arr , slice_index , start , count ) : # TODO: should this also handle slices not staring from zero? if arr == string_array_type : reduce_op = Reduce_Type . Sum . value def getitem_str_impl ( arr , slice_index , start , count ) : rank = sdc . distributed_api . get_rank ( ) k = slice_index . stop # get total characters for allocation n_chars = np . uint64 ( 0 ) if k > start : # if slice end is beyond the start of this subset we have to send our elements my_end = min ( count , k - start ) my_arr = arr [ : my_end ] else : my_arr = arr [ : 0 ] # get the total number of chars in our array, then gather all arrays into one # and compute total number of chars in all arrays n_chars = num_total_chars ( my_arr ) my_arr = sdc . distributed_api . gatherv ( my_arr ) n_chars = sdc . distributed_api . dist_reduce ( n_chars , np . int32 ( reduce_op ) ) if rank != 0 : out_arr = pre_alloc_string_array ( k , n_chars ) else : out_arr = my_arr # actual communication sdc . distributed_api . bcast ( out_arr ) return out_arr return getitem_str_impl def getitem_impl ( arr , slice_index , start , count ) : rank = sdc . distributed_api . get_rank ( ) k = slice_index . stop out_arr = np . empty ( k , arr . dtype ) if k > start : # if slice end is beyond the start of this subset we have to send our elements my_end = min ( count , k - start ) my_arr = arr [ : my_end ] else : my_arr = arr [ : 0 ] # gather all subsets from all processors my_arr = sdc . distributed_api . gatherv ( my_arr ) if rank == 0 : out_arr = my_arr # actual communication sdc . distributed_api . bcast ( out_arr ) return out_arr return getitem_impl