Beispiel #1
0
        internal static TimeSeriesOperation Parse(BlittableJsonReaderObject input)
        {
            if (input.TryGet(nameof(Name), out string name) == false || name == null)
            {
                ThrowMissingProperty(nameof(Name));
            }

            var result = new TimeSeriesOperation
            {
                Name = name
            };

            if (input.TryGet(nameof(Appends), out BlittableJsonReaderArray operations) && operations != null)
            {
                var sorted = new SortedList <long, AppendOperation>();

                foreach (var op in operations)
                {
                    if (!(op is BlittableJsonReaderObject bjro))
                    {
                        ThrowNotBlittableJsonReaderObjectOperation(op);
                        return(null); //never hit
                    }

                    var append = AppendOperation.Parse(bjro);

                    sorted[append.Timestamp.Ticks] = append;
                }

                result._appends = sorted;
            }

            if (input.TryGet(nameof(Deletes), out operations) && operations != null)
            {
                result.Deletes = new List <DeleteOperation>();

                foreach (var op in operations)
                {
                    if (!(op is BlittableJsonReaderObject bjro))
                    {
                        ThrowNotBlittableJsonReaderObjectOperation(op);
                        return(null); //never hit
                    }

                    result.Deletes.Add(DeleteOperation.Parse(bjro));
                }
            }

            return(result);
        }