public void InitializeState(IFunctionInitializationContext context)
        {
            _checkpointedCount =
                context.OperatorStateStore.GetListState(new ListStateDescriptor <long>("count", default));

            if (context.IsRestored)
            {
                foreach (var count in _checkpointedCount.Get())
                {
                    _counter = count;
                }
            }
        }
        public void InitializeState(IFunctionInitializationContext context)
        {
            Preconditions.CheckState(_checkpointedState != null, $"The {GetType()} has not been properly initialized.");

            _checkpointedState = context.OperatorStateStore
                                 .GetListState(new ListStateDescriptor <int>("from-elements-state"));

            if (context.IsRestored)
            {
                var retrievedStates = new List <int>();
                foreach (var entry in _checkpointedState.Get())
                {
                    retrievedStates.Add(entry);
                }

                // given that the parallelism of the function is 1, we can only have 1 state.
                Preconditions.CheckArgument(retrievedStates.Count == 1, $"The {GetType()} retrieved invalid state.");

                _numElementsToSkip = retrievedStates[0];
            }
        }