コード例 #1
0
ファイル: DataStream.cs プロジェクト: justmine66/FLink.CSharp
        /// <summary>
        /// It creates a new <see cref="KeyedStream{TElement,TKey}"/> that uses the provided key with explicit type information for partitioning its operator states.
        /// </summary>
        /// <typeparam name="TKey"></typeparam>
        /// <param name="selector">The KeySelector to be used for extracting the key for partitioning.</param>
        /// <param name="keyType">The type information describing the key type.</param>
        /// <returns>The <see cref="DataStream{TElement}"/> with partitioned state (i.e. KeyedStream)</returns>
        public KeyedStream <TElement, TKey> KeyBy <TKey>(IKeySelector <TElement, TKey> selector, TypeInformation <TKey> keyType)
        {
            Preconditions.CheckNotNull(selector);
            Preconditions.CheckNotNull(keyType);

            return(new KeyedStream <TElement, TKey>(this, Clean(selector), keyType));
        }
コード例 #2
0
ファイル: CacheUpdater.cs プロジェクト: jmptrader/DynamicData
 public CacheUpdater(ChangeAwareCache <TObject, TKey> cache, IKeySelector <TObject, TKey> keySelector = null)
 {
     if (cache == null)
     {
         throw new ArgumentNullException(nameof(cache));
     }
     _cache       = cache;
     _keySelector = keySelector;
 }
コード例 #3
0
 /// <summary>
 /// Creates a new <see cref="KeyedStream{TElement,TKey}"/> using the given <see cref="IKeySelector{TObject,TKey}"/> and <see cref="TypeInformation{TType}"/> to partition operator state by key, where the partitioning is defined by a <see cref="PartitionTransformation{TElement}"/>.
 /// </summary>
 /// <param name="stream">Base stream of data</param>
 /// <param name="transformation">Function that determines how the keys are distributed to downstream operator(s)</param>
 /// <param name="selector">Function to extract keys from the base stream</param>
 /// <param name="keyType">Defines the type of the extracted keys</param>
 internal KeyedStream(
     DataStream <TElement> stream,
     PartitionTransformation <TElement> transformation,
     IKeySelector <TElement, TKey> selector,
     TypeInformation <TKey> keyType)
     : base(stream.ExecutionEnvironment, transformation)
 {
     KeySelector = Clean(selector);
     KeyType     = ValidateKeyType(keyType);
 }
コード例 #4
0
 /// <summary>
 /// Creates a new <see cref="KeyedStream{TElement,TKey}"/> using the given <see cref="IKeySelector{TObject,TKey}"/> and <see cref="TypeInformation{TType}"/> to partition operator state by key, where the partitioning is defined by a <see cref="PartitionTransformation{TElement}"/>.
 /// </summary>
 /// <param name="stream">Base stream of data</param>
 /// <param name="selector">Function for determining state partitions</param>
 /// <param name="keyType">Defines the type of the extracted keys</param>
 public KeyedStream(DataStream <TElement> stream, IKeySelector <TElement, TKey> selector, TypeInformation <TKey> keyType)
     : this(
         stream,
         new PartitionTransformation <TElement>(
             stream.Transformation,
             new KeyGroupStreamPartitioner <TElement, TKey>(selector, StreamGraphGenerator.DefaultLowerBoundMaxParallelism)),
         selector,
         keyType)
 {
 }
コード例 #5
0
        public SourceUpdater(ICache <TObject, TKey> cache, IKeySelector <TObject, TKey> keySelector)
        {
            if (cache == null)
            {
                throw new ArgumentNullException(nameof(cache));
            }
            if (keySelector == null)
            {
                throw new ArgumentNullException(nameof(keySelector));
            }

            _cache       = cache;
            _keySelector = keySelector;
        }
コード例 #6
0
        public static IPartitionableSubscribable <TSource, TNextKey, IPartitionableSubscribable <TSource, TKey, TInner> > AddPartition <TSource, TKey, TInner, TNextKey>(this IPartitionableSubscribable <TSource, TKey, TInner> source, IKeySelector <TSource, TNextKey> keySelector)
            where TInner : IImmutableBindingHolder <TInner, TSource>
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (keySelector == null)
            {
                throw new ArgumentNullException(nameof(keySelector));
            }

            return(new SimplePartitionableSubscribable <TSource, TNextKey, IPartitionableSubscribable <TSource, TKey, TInner> >(source, keySelector, null));
        }
コード例 #7
0
        public static IPartitionableSubscribable <TSource, TKey, IPartitionableSubscribable <TSource> > AddPartition <TSource, TKey>(this IPartitionableSubscribable <TSource> source, IKeySelector <TSource, TKey> keySelector)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (keySelector == null)
            {
                throw new ArgumentNullException(nameof(keySelector));
            }

            return(new SimplePartitionableSubscribable <TSource, TKey, IPartitionableSubscribable <TSource> >(source, keySelector, null));
        }
コード例 #8
0
ファイル: DataStream.cs プロジェクト: justmine66/FLink.CSharp
        /// <summary>
        /// It creates a new <see cref="KeyedStream{TElement,TKey}"/> that uses the provided key for partitioning its operator states.
        /// </summary>
        /// <typeparam name="TKey"></typeparam>
        /// <param name="selector">The KeySelector to be used for extracting the key for partitioning</param>
        /// <returns>The <see cref="DataStream{TElement}"/> with partitioned state (i.e. KeyedStream)</returns>
        public KeyedStream <TElement, TKey> KeyBy <TKey>(IKeySelector <TElement, TKey> selector)
        {
            Preconditions.CheckNotNull(selector);

            return(new KeyedStream <TElement, TKey>(this, Clean(selector)));
        }
コード例 #9
0
ファイル: KeyBinding.cs プロジェクト: tamirdresher/reaqtor
 public KeyBinding(IKeySelector <TElement, TKey> keySelector, TKey key, IEqualityComparer <TKey> keyComparer)
 {
     KeySelector = keySelector;
     Key         = key;
     KeyComparer = keyComparer;
 }
コード例 #10
0
 public CustomPartitionerWrapper(IPartitioner <TKey> partitioner, IKeySelector <TData, TKey> keySelector)
 {
     this.partitioner = partitioner;
     this.keySelector = keySelector;
 }
コード例 #11
0
 /// <summary>
 /// Creates a new <see cref="KeyedStream{TElement,TKey}"/> using the given <see cref="IKeySelector{TObject,TKey}"/> to partition operator state by key.
 /// </summary>
 /// <param name="stream">Base stream of data</param>
 /// <param name="selector">Function for determining state partitions</param>
 public KeyedStream(DataStream <TElement> stream, IKeySelector <TElement, TKey> selector)
     : this(stream, selector, TypeExtractor.GetKeySelectorTypes(selector, stream.Type))
 {
 }
コード例 #12
0
 public KeyGroupStreamPartitioner(IKeySelector <TElement, TKey> keySelector, int maxParallelism)
 {
     Preconditions.CheckArgument(maxParallelism > 0, "Number of key-groups must be > 0!");
     KeySelector    = Preconditions.CheckNotNull(keySelector);
     MaxParallelism = maxParallelism;
 }
コード例 #13
0
 /// <summary>
 /// KeyBy operation for connected data stream. Assigns keys to the elements of input1 and input2 using keySelector1 and keySelector2.
 /// </summary>
 /// <typeparam name="TKey1"></typeparam>
 /// <typeparam name="TKey2"></typeparam>
 /// <param name="keySelector1">The <see cref="IKeySelector{TObject,TKey}"/> used for grouping the first input</param>
 /// <param name="keySelector2">The <see cref="IKeySelector{TObject,TKey}"/> used for grouping the second input</param>
 /// <returns>The partitioned <see cref="ConnectedStreams{IN1,IN2}"/></returns>
 public ConnectedStreams <TInput1, TInput2> KeyBy <TKey1, TKey2>(IKeySelector <TInput1, TKey1> keySelector1,
                                                                 IKeySelector <TInput2, TKey2> keySelector2) => new ConnectedStreams <TInput1, TInput2>(Environment,
                                                                                                                                                        InputStream1.KeyBy(keySelector1), InputStream2.KeyBy(keySelector2));