public List <ElementValuesCollection> SplitForCorrectGrpcMessageSize()
        {
            if (DoubleValues.Count < MaxArrayLength && UintValues.Count < MaxArrayLength && ObjectValues.Length < MaxByteStringLength)
            {
                return(new List <ElementValuesCollection> {
                    this
                });
            }

            var result = new List <ElementValuesCollection>();

            int doubleIndex     = 0;
            int uintIndex       = 0;
            int objectIndex     = 0;
            int objectByteIndex = 0;
            ElementValuesCollection?prevElementValuesCollection = null;

            while (doubleIndex < DoubleAliases.Count ||
                   uintIndex < UintAliases.Count ||
                   objectIndex < ObjectAliases.Count ||
                   objectByteIndex < ObjectValues.Length)
            {
                var elementValuesCollection = new ElementValuesCollection();
                if (prevElementValuesCollection is not null)
                {
                    string guid = System.Guid.NewGuid().ToString();
                    prevElementValuesCollection.NextCollectionGuid = guid;
                    elementValuesCollection.Guid = guid;
                }

                elementValuesCollection.DoubleAliases.AddRange(DoubleAliases.Skip(doubleIndex).Take(MaxArrayLength));
                elementValuesCollection.DoubleValueStatusCodes.AddRange(DoubleValueStatusCodes.Skip(doubleIndex).Take(MaxArrayLength));
                elementValuesCollection.DoubleTimestamps.AddRange(DoubleTimestamps.Skip(doubleIndex).Take(MaxArrayLength));
                elementValuesCollection.DoubleValues.AddRange(DoubleValues.Skip(doubleIndex).Take(MaxArrayLength));

                elementValuesCollection.UintAliases.AddRange(UintAliases.Skip(uintIndex).Take(MaxArrayLength));
                elementValuesCollection.UintValueStatusCodes.AddRange(UintValueStatusCodes.Skip(uintIndex).Take(MaxArrayLength));
                elementValuesCollection.UintTimestamps.AddRange(UintTimestamps.Skip(uintIndex).Take(MaxArrayLength));
                elementValuesCollection.UintValues.AddRange(UintValues.Skip(uintIndex).Take(MaxArrayLength));

                elementValuesCollection.ObjectAliases.AddRange(ObjectAliases.Skip(objectIndex).Take(MaxArrayLength));
                elementValuesCollection.ObjectValueStatusCodes.AddRange(ObjectValueStatusCodes.Skip(objectIndex).Take(MaxArrayLength));
                elementValuesCollection.ObjectTimestamps.AddRange(ObjectTimestamps.Skip(objectIndex).Take(MaxArrayLength));
                elementValuesCollection.ObjectValues = Google.Protobuf.ByteString.CopyFrom(
                    ObjectValues.Skip(objectByteIndex).Take(MaxByteStringLength).ToArray());

                result.Add(elementValuesCollection);
                doubleIndex                += MaxArrayLength;
                uintIndex                  += MaxArrayLength;
                objectIndex                += MaxArrayLength;
                objectByteIndex            += MaxByteStringLength;
                prevElementValuesCollection = elementValuesCollection;
            }

            return(result);
        }
Exemplo n.º 2
0
        public void CombineWith(ElementValuesJournal nextElementValuesJournal)
        {
            DoubleValueStatusCodes.Add(nextElementValuesJournal.DoubleValueStatusCodes);
            DoubleTimestamps.Add(nextElementValuesJournal.DoubleTimestamps);
            DoubleValues.Add(nextElementValuesJournal.DoubleValues);

            UintValueStatusCodes.Add(nextElementValuesJournal.UintValueStatusCodes);
            UintTimestamps.Add(nextElementValuesJournal.UintTimestamps);
            UintValues.Add(nextElementValuesJournal.UintValues);
        }
        public void CombineWith(ElementValuesCollection nextElementValuesCollection)
        {
            Guid = nextElementValuesCollection.Guid;
            NextCollectionGuid = nextElementValuesCollection.NextCollectionGuid;

            DoubleAliases.Add(nextElementValuesCollection.DoubleAliases);
            DoubleValueStatusCodes.Add(nextElementValuesCollection.DoubleValueStatusCodes);
            DoubleTimestamps.Add(nextElementValuesCollection.DoubleTimestamps);
            DoubleValues.Add(nextElementValuesCollection.DoubleValues);

            UintAliases.Add(nextElementValuesCollection.UintAliases);
            UintValueStatusCodes.Add(nextElementValuesCollection.UintValueStatusCodes);
            UintTimestamps.Add(nextElementValuesCollection.UintTimestamps);
            UintValues.Add(nextElementValuesCollection.UintValues);

            ObjectAliases.Add(nextElementValuesCollection.ObjectAliases);
            ObjectValueStatusCodes.Add(nextElementValuesCollection.ObjectValueStatusCodes);
            ObjectTimestamps.Add(nextElementValuesCollection.ObjectTimestamps);
            ObjectValues = Google.Protobuf.ByteString.CopyFrom(
                ObjectValues.Concat(nextElementValuesCollection.ObjectValues).ToArray()
                );
        }