/// <summary>
        /// Partitions the operator state of a <see cref="DataStream{TElement}"/> by the given key positions.
        /// </summary>
        /// <param name="fields">The position of the fields on which the <see cref="DataStream{TElement}"/> will be grouped.</param>
        /// <returns>The <see cref="DataStream{TElement}"/> with partitioned state (i.e. <see cref="KeyedStream{T,TKey}"/>)</returns>
        public KeyedStream <TElement, int> KeyBy(params int[] fields)
        {
            if (Type is BasicArrayTypeInfo <TElement> ||
                Type is PrimitiveArrayTypeInfo <TElement> )
            {
                return(KeyBy(KeySelectorUtil.GetSelectorForArray <TElement, int>(fields, Type)));
            }

            return(KeyBy <int>(new Keys <TElement> .ExpressionKeys <TElement>(fields, Type)));
        }
 private KeyedStream <TElement, TKey> KeyBy <TKey>(Keys <TElement> keys) => new KeyedStream <TElement, TKey>(this, Clean(KeySelectorUtil.GetSelectorForKeys <TElement, TKey>(keys,
                                                                                                                                                                             Type, ExecutionConfig)));